babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. 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;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areLightsDisposed: boolean;
  7692. /** @hidden */
  7693. _areAttributesDirty: boolean;
  7694. /** @hidden */
  7695. _areTexturesDirty: boolean;
  7696. /** @hidden */
  7697. _areFresnelDirty: boolean;
  7698. /** @hidden */
  7699. _areMiscDirty: boolean;
  7700. /** @hidden */
  7701. _areImageProcessingDirty: boolean;
  7702. /** @hidden */
  7703. _normals: boolean;
  7704. /** @hidden */
  7705. _uvs: boolean;
  7706. /** @hidden */
  7707. _needNormals: boolean;
  7708. /** @hidden */
  7709. _needUVs: boolean;
  7710. [id: string]: any;
  7711. /**
  7712. * Specifies if the material needs to be re-calculated
  7713. */
  7714. readonly isDirty: boolean;
  7715. /**
  7716. * Marks the material to indicate that it has been re-calculated
  7717. */
  7718. markAsProcessed(): void;
  7719. /**
  7720. * Marks the material to indicate that it needs to be re-calculated
  7721. */
  7722. markAsUnprocessed(): void;
  7723. /**
  7724. * Marks the material to indicate all of its defines need to be re-calculated
  7725. */
  7726. markAllAsDirty(): void;
  7727. /**
  7728. * Marks the material to indicate that image processing needs to be re-calculated
  7729. */
  7730. markAsImageProcessingDirty(): void;
  7731. /**
  7732. * Marks the material to indicate the lights need to be re-calculated
  7733. * @param disposed Defines whether the light is dirty due to dispose or not
  7734. */
  7735. markAsLightDirty(disposed?: boolean): void;
  7736. /**
  7737. * Marks the attribute state as changed
  7738. */
  7739. markAsAttributesDirty(): void;
  7740. /**
  7741. * Marks the texture state as changed
  7742. */
  7743. markAsTexturesDirty(): void;
  7744. /**
  7745. * Marks the fresnel state as changed
  7746. */
  7747. markAsFresnelDirty(): void;
  7748. /**
  7749. * Marks the misc state as changed
  7750. */
  7751. markAsMiscDirty(): void;
  7752. /**
  7753. * Rebuilds the material defines
  7754. */
  7755. rebuild(): void;
  7756. /**
  7757. * Specifies if two material defines are equal
  7758. * @param other - A material define instance to compare to
  7759. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7760. */
  7761. isEqual(other: MaterialDefines): boolean;
  7762. /**
  7763. * Clones this instance's defines to another instance
  7764. * @param other - material defines to clone values to
  7765. */
  7766. cloneTo(other: MaterialDefines): void;
  7767. /**
  7768. * Resets the material define values
  7769. */
  7770. reset(): void;
  7771. /**
  7772. * Converts the material define values to a string
  7773. * @returns - String of material define information
  7774. */
  7775. toString(): string;
  7776. }
  7777. }
  7778. declare module "babylonjs/Materials/colorCurves" {
  7779. import { Effect } from "babylonjs/Materials/effect";
  7780. /**
  7781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7783. * 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;
  7784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7785. */
  7786. export class ColorCurves {
  7787. private _dirty;
  7788. private _tempColor;
  7789. private _globalCurve;
  7790. private _highlightsCurve;
  7791. private _midtonesCurve;
  7792. private _shadowsCurve;
  7793. private _positiveCurve;
  7794. private _negativeCurve;
  7795. private _globalHue;
  7796. private _globalDensity;
  7797. private _globalSaturation;
  7798. private _globalExposure;
  7799. /**
  7800. * Gets the global Hue value.
  7801. * 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).
  7802. */
  7803. /**
  7804. * Sets the global Hue value.
  7805. * 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).
  7806. */
  7807. globalHue: number;
  7808. /**
  7809. * Gets the global Density value.
  7810. * 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.
  7811. * Values less than zero provide a filter of opposite hue.
  7812. */
  7813. /**
  7814. * Sets the global Density value.
  7815. * 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.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. globalDensity: number;
  7819. /**
  7820. * Gets the global Saturation value.
  7821. * 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.
  7822. */
  7823. /**
  7824. * Sets the global Saturation value.
  7825. * 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.
  7826. */
  7827. globalSaturation: number;
  7828. /**
  7829. * Gets the global Exposure value.
  7830. * 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.
  7831. */
  7832. /**
  7833. * Sets the global Exposure value.
  7834. * 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.
  7835. */
  7836. globalExposure: number;
  7837. private _highlightsHue;
  7838. private _highlightsDensity;
  7839. private _highlightsSaturation;
  7840. private _highlightsExposure;
  7841. /**
  7842. * Gets the highlights Hue value.
  7843. * 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).
  7844. */
  7845. /**
  7846. * Sets the highlights Hue value.
  7847. * 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).
  7848. */
  7849. highlightsHue: number;
  7850. /**
  7851. * Gets the highlights Density value.
  7852. * 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.
  7853. * Values less than zero provide a filter of opposite hue.
  7854. */
  7855. /**
  7856. * Sets the highlights Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. highlightsDensity: number;
  7861. /**
  7862. * Gets the highlights Saturation value.
  7863. * 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.
  7864. */
  7865. /**
  7866. * Sets the highlights Saturation value.
  7867. * 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.
  7868. */
  7869. highlightsSaturation: number;
  7870. /**
  7871. * Gets the highlights Exposure value.
  7872. * 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.
  7873. */
  7874. /**
  7875. * Sets the highlights Exposure value.
  7876. * 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.
  7877. */
  7878. highlightsExposure: number;
  7879. private _midtonesHue;
  7880. private _midtonesDensity;
  7881. private _midtonesSaturation;
  7882. private _midtonesExposure;
  7883. /**
  7884. * Gets the midtones Hue value.
  7885. * 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).
  7886. */
  7887. /**
  7888. * Sets the midtones Hue value.
  7889. * 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).
  7890. */
  7891. midtonesHue: number;
  7892. /**
  7893. * Gets the midtones Density value.
  7894. * 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.
  7895. * Values less than zero provide a filter of opposite hue.
  7896. */
  7897. /**
  7898. * Sets the midtones Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. midtonesDensity: number;
  7903. /**
  7904. * Gets the midtones Saturation value.
  7905. * 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.
  7906. */
  7907. /**
  7908. * Sets the midtones Saturation value.
  7909. * 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.
  7910. */
  7911. midtonesSaturation: number;
  7912. /**
  7913. * Gets the midtones Exposure value.
  7914. * 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.
  7915. */
  7916. /**
  7917. * Sets the midtones Exposure value.
  7918. * 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.
  7919. */
  7920. midtonesExposure: number;
  7921. private _shadowsHue;
  7922. private _shadowsDensity;
  7923. private _shadowsSaturation;
  7924. private _shadowsExposure;
  7925. /**
  7926. * Gets the shadows Hue value.
  7927. * 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).
  7928. */
  7929. /**
  7930. * Sets the shadows Hue value.
  7931. * 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).
  7932. */
  7933. shadowsHue: number;
  7934. /**
  7935. * Gets the shadows Density value.
  7936. * 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.
  7937. * Values less than zero provide a filter of opposite hue.
  7938. */
  7939. /**
  7940. * Sets the shadows Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. shadowsDensity: number;
  7945. /**
  7946. * Gets the shadows Saturation value.
  7947. * 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.
  7948. */
  7949. /**
  7950. * Sets the shadows Saturation value.
  7951. * 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.
  7952. */
  7953. shadowsSaturation: number;
  7954. /**
  7955. * Gets the shadows Exposure value.
  7956. * 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.
  7957. */
  7958. /**
  7959. * Sets the shadows Exposure value.
  7960. * 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.
  7961. */
  7962. shadowsExposure: number;
  7963. /**
  7964. * Returns the class name
  7965. * @returns The class name
  7966. */
  7967. getClassName(): string;
  7968. /**
  7969. * Binds the color curves to the shader.
  7970. * @param colorCurves The color curve to bind
  7971. * @param effect The effect to bind to
  7972. * @param positiveUniform The positive uniform shader parameter
  7973. * @param neutralUniform The neutral uniform shader parameter
  7974. * @param negativeUniform The negative uniform shader parameter
  7975. */
  7976. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7977. /**
  7978. * Prepare the list of uniforms associated with the ColorCurves effects.
  7979. * @param uniformsList The list of uniforms used in the effect
  7980. */
  7981. static PrepareUniforms(uniformsList: string[]): void;
  7982. /**
  7983. * Returns color grading data based on a hue, density, saturation and exposure value.
  7984. * @param filterHue The hue of the color filter.
  7985. * @param filterDensity The density of the color filter.
  7986. * @param saturation The saturation.
  7987. * @param exposure The exposure.
  7988. * @param result The result data container.
  7989. */
  7990. private getColorGradingDataToRef;
  7991. /**
  7992. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7993. * @param value The input slider value in range [-100,100].
  7994. * @returns Adjusted value.
  7995. */
  7996. private static applyColorGradingSliderNonlinear;
  7997. /**
  7998. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7999. * @param hue The hue (H) input.
  8000. * @param saturation The saturation (S) input.
  8001. * @param brightness The brightness (B) input.
  8002. * @result An RGBA color represented as Vector4.
  8003. */
  8004. private static fromHSBToRef;
  8005. /**
  8006. * Returns a value clamped between min and max
  8007. * @param value The value to clamp
  8008. * @param min The minimum of value
  8009. * @param max The maximum of value
  8010. * @returns The clamped value.
  8011. */
  8012. private static clamp;
  8013. /**
  8014. * Clones the current color curve instance.
  8015. * @return The cloned curves
  8016. */
  8017. clone(): ColorCurves;
  8018. /**
  8019. * Serializes the current color curve instance to a json representation.
  8020. * @return a JSON representation
  8021. */
  8022. serialize(): any;
  8023. /**
  8024. * Parses the color curve from a json representation.
  8025. * @param source the JSON source to parse
  8026. * @return The parsed curves
  8027. */
  8028. static Parse(source: any): ColorCurves;
  8029. }
  8030. }
  8031. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8032. import { Observable } from "babylonjs/Misc/observable";
  8033. import { Nullable } from "babylonjs/types";
  8034. import { Color4 } from "babylonjs/Maths/math.color";
  8035. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8036. import { Effect } from "babylonjs/Materials/effect";
  8037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8038. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8039. /**
  8040. * Interface to follow in your material defines to integrate easily the
  8041. * Image proccessing functions.
  8042. * @hidden
  8043. */
  8044. export interface IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. EXPOSURE: boolean;
  8053. COLORCURVES: boolean;
  8054. COLORGRADING: boolean;
  8055. COLORGRADING3D: boolean;
  8056. SAMPLER3DGREENDEPTH: boolean;
  8057. SAMPLER3DBGRMAP: boolean;
  8058. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8059. }
  8060. /**
  8061. * @hidden
  8062. */
  8063. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8064. IMAGEPROCESSING: boolean;
  8065. VIGNETTE: boolean;
  8066. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8067. VIGNETTEBLENDMODEOPAQUE: boolean;
  8068. TONEMAPPING: boolean;
  8069. TONEMAPPING_ACES: boolean;
  8070. CONTRAST: boolean;
  8071. COLORCURVES: boolean;
  8072. COLORGRADING: boolean;
  8073. COLORGRADING3D: boolean;
  8074. SAMPLER3DGREENDEPTH: boolean;
  8075. SAMPLER3DBGRMAP: boolean;
  8076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8077. EXPOSURE: boolean;
  8078. constructor();
  8079. }
  8080. /**
  8081. * This groups together the common properties used for image processing either in direct forward pass
  8082. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8083. * or not.
  8084. */
  8085. export class ImageProcessingConfiguration {
  8086. /**
  8087. * Default tone mapping applied in BabylonJS.
  8088. */
  8089. static readonly TONEMAPPING_STANDARD: number;
  8090. /**
  8091. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8092. * to other engines rendering to increase portability.
  8093. */
  8094. static readonly TONEMAPPING_ACES: number;
  8095. /**
  8096. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8097. */
  8098. colorCurves: Nullable<ColorCurves>;
  8099. private _colorCurvesEnabled;
  8100. /**
  8101. * Gets wether the color curves effect is enabled.
  8102. */
  8103. /**
  8104. * Sets wether the color curves effect is enabled.
  8105. */
  8106. colorCurvesEnabled: boolean;
  8107. private _colorGradingTexture;
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. /**
  8112. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8113. */
  8114. colorGradingTexture: Nullable<BaseTexture>;
  8115. private _colorGradingEnabled;
  8116. /**
  8117. * Gets wether the color grading effect is enabled.
  8118. */
  8119. /**
  8120. * Sets wether the color grading effect is enabled.
  8121. */
  8122. colorGradingEnabled: boolean;
  8123. private _colorGradingWithGreenDepth;
  8124. /**
  8125. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. /**
  8128. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8129. */
  8130. colorGradingWithGreenDepth: boolean;
  8131. private _colorGradingBGR;
  8132. /**
  8133. * Gets wether the color grading texture contains BGR values.
  8134. */
  8135. /**
  8136. * Sets wether the color grading texture contains BGR values.
  8137. */
  8138. colorGradingBGR: boolean;
  8139. /** @hidden */
  8140. _exposure: number;
  8141. /**
  8142. * Gets the Exposure used in the effect.
  8143. */
  8144. /**
  8145. * Sets the Exposure used in the effect.
  8146. */
  8147. exposure: number;
  8148. private _toneMappingEnabled;
  8149. /**
  8150. * Gets wether the tone mapping effect is enabled.
  8151. */
  8152. /**
  8153. * Sets wether the tone mapping effect is enabled.
  8154. */
  8155. toneMappingEnabled: boolean;
  8156. private _toneMappingType;
  8157. /**
  8158. * Gets the type of tone mapping effect.
  8159. */
  8160. /**
  8161. * Sets the type of tone mapping effect used in BabylonJS.
  8162. */
  8163. toneMappingType: number;
  8164. protected _contrast: number;
  8165. /**
  8166. * Gets the contrast used in the effect.
  8167. */
  8168. /**
  8169. * Sets the contrast used in the effect.
  8170. */
  8171. contrast: number;
  8172. /**
  8173. * Vignette stretch size.
  8174. */
  8175. vignetteStretch: number;
  8176. /**
  8177. * Vignette centre X Offset.
  8178. */
  8179. vignetteCentreX: number;
  8180. /**
  8181. * Vignette centre Y Offset.
  8182. */
  8183. vignetteCentreY: number;
  8184. /**
  8185. * Vignette weight or intensity of the vignette effect.
  8186. */
  8187. vignetteWeight: number;
  8188. /**
  8189. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8190. * if vignetteEnabled is set to true.
  8191. */
  8192. vignetteColor: Color4;
  8193. /**
  8194. * Camera field of view used by the Vignette effect.
  8195. */
  8196. vignetteCameraFov: number;
  8197. private _vignetteBlendMode;
  8198. /**
  8199. * Gets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. /**
  8202. * Sets the vignette blend mode allowing different kind of effect.
  8203. */
  8204. vignetteBlendMode: number;
  8205. private _vignetteEnabled;
  8206. /**
  8207. * Gets wether the vignette effect is enabled.
  8208. */
  8209. /**
  8210. * Sets wether the vignette effect is enabled.
  8211. */
  8212. vignetteEnabled: boolean;
  8213. private _applyByPostProcess;
  8214. /**
  8215. * Gets wether the image processing is applied through a post process or not.
  8216. */
  8217. /**
  8218. * Sets wether the image processing is applied through a post process or not.
  8219. */
  8220. applyByPostProcess: boolean;
  8221. private _isEnabled;
  8222. /**
  8223. * Gets wether the image processing is enabled or not.
  8224. */
  8225. /**
  8226. * Sets wether the image processing is enabled or not.
  8227. */
  8228. isEnabled: boolean;
  8229. /**
  8230. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8231. */
  8232. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8233. /**
  8234. * Method called each time the image processing information changes requires to recompile the effect.
  8235. */
  8236. protected _updateParameters(): void;
  8237. /**
  8238. * Gets the current class name.
  8239. * @return "ImageProcessingConfiguration"
  8240. */
  8241. getClassName(): string;
  8242. /**
  8243. * Prepare the list of uniforms associated with the Image Processing effects.
  8244. * @param uniforms The list of uniforms used in the effect
  8245. * @param defines the list of defines currently in use
  8246. */
  8247. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8248. /**
  8249. * Prepare the list of samplers associated with the Image Processing effects.
  8250. * @param samplersList The list of uniforms used in the effect
  8251. * @param defines the list of defines currently in use
  8252. */
  8253. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8254. /**
  8255. * Prepare the list of defines associated to the shader.
  8256. * @param defines the list of defines to complete
  8257. * @param forPostProcess Define if we are currently in post process mode or not
  8258. */
  8259. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8260. /**
  8261. * Returns true if all the image processing information are ready.
  8262. * @returns True if ready, otherwise, false
  8263. */
  8264. isReady(): boolean;
  8265. /**
  8266. * Binds the image processing to the shader.
  8267. * @param effect The effect to bind to
  8268. * @param aspectRatio Define the current aspect ratio of the effect
  8269. */
  8270. bind(effect: Effect, aspectRatio?: number): void;
  8271. /**
  8272. * Clones the current image processing instance.
  8273. * @return The cloned image processing
  8274. */
  8275. clone(): ImageProcessingConfiguration;
  8276. /**
  8277. * Serializes the current image processing instance to a json representation.
  8278. * @return a JSON representation
  8279. */
  8280. serialize(): any;
  8281. /**
  8282. * Parses the image processing from a json representation.
  8283. * @param source the JSON source to parse
  8284. * @return The parsed image processing
  8285. */
  8286. static Parse(source: any): ImageProcessingConfiguration;
  8287. private static _VIGNETTEMODE_MULTIPLY;
  8288. private static _VIGNETTEMODE_OPAQUE;
  8289. /**
  8290. * Used to apply the vignette as a mix with the pixel color.
  8291. */
  8292. static readonly VIGNETTEMODE_MULTIPLY: number;
  8293. /**
  8294. * Used to apply the vignette as a replacement of the pixel color.
  8295. */
  8296. static readonly VIGNETTEMODE_OPAQUE: number;
  8297. }
  8298. }
  8299. declare module "babylonjs/Shaders/postprocess.vertex" {
  8300. /** @hidden */
  8301. export var postprocessVertexShader: {
  8302. name: string;
  8303. shader: string;
  8304. };
  8305. }
  8306. declare module "babylonjs/Maths/math.axis" {
  8307. import { Vector3 } from "babylonjs/Maths/math.vector";
  8308. /** Defines supported spaces */
  8309. export enum Space {
  8310. /** Local (object) space */
  8311. LOCAL = 0,
  8312. /** World space */
  8313. WORLD = 1,
  8314. /** Bone space */
  8315. BONE = 2
  8316. }
  8317. /** Defines the 3 main axes */
  8318. export class Axis {
  8319. /** X axis */
  8320. static X: Vector3;
  8321. /** Y axis */
  8322. static Y: Vector3;
  8323. /** Z axis */
  8324. static Z: Vector3;
  8325. }
  8326. }
  8327. declare module "babylonjs/Cameras/targetCamera" {
  8328. import { Nullable } from "babylonjs/types";
  8329. import { Camera } from "babylonjs/Cameras/camera";
  8330. import { Scene } from "babylonjs/scene";
  8331. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8332. /**
  8333. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8334. * This is the base of the follow, arc rotate cameras and Free camera
  8335. * @see http://doc.babylonjs.com/features/cameras
  8336. */
  8337. export class TargetCamera extends Camera {
  8338. private static _RigCamTransformMatrix;
  8339. private static _TargetTransformMatrix;
  8340. private static _TargetFocalPoint;
  8341. /**
  8342. * Define the current direction the camera is moving to
  8343. */
  8344. cameraDirection: Vector3;
  8345. /**
  8346. * Define the current rotation the camera is rotating to
  8347. */
  8348. cameraRotation: Vector2;
  8349. /**
  8350. * When set, the up vector of the camera will be updated by the rotation of the camera
  8351. */
  8352. updateUpVectorFromRotation: boolean;
  8353. private _tmpQuaternion;
  8354. /**
  8355. * Define the current rotation of the camera
  8356. */
  8357. rotation: Vector3;
  8358. /**
  8359. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8360. */
  8361. rotationQuaternion: Quaternion;
  8362. /**
  8363. * Define the current speed of the camera
  8364. */
  8365. speed: number;
  8366. /**
  8367. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8368. * around all axis.
  8369. */
  8370. noRotationConstraint: boolean;
  8371. /**
  8372. * Define the current target of the camera as an object or a position.
  8373. */
  8374. lockedTarget: any;
  8375. /** @hidden */
  8376. _currentTarget: Vector3;
  8377. /** @hidden */
  8378. _initialFocalDistance: number;
  8379. /** @hidden */
  8380. _viewMatrix: Matrix;
  8381. /** @hidden */
  8382. _camMatrix: Matrix;
  8383. /** @hidden */
  8384. _cameraTransformMatrix: Matrix;
  8385. /** @hidden */
  8386. _cameraRotationMatrix: Matrix;
  8387. /** @hidden */
  8388. _referencePoint: Vector3;
  8389. /** @hidden */
  8390. _transformedReferencePoint: Vector3;
  8391. protected _globalCurrentTarget: Vector3;
  8392. protected _globalCurrentUpVector: Vector3;
  8393. /** @hidden */
  8394. _reset: () => void;
  8395. private _defaultUp;
  8396. /**
  8397. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8398. * This is the base of the follow, arc rotate cameras and Free camera
  8399. * @see http://doc.babylonjs.com/features/cameras
  8400. * @param name Defines the name of the camera in the scene
  8401. * @param position Defines the start position of the camera in the scene
  8402. * @param scene Defines the scene the camera belongs to
  8403. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8404. */
  8405. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8406. /**
  8407. * Gets the position in front of the camera at a given distance.
  8408. * @param distance The distance from the camera we want the position to be
  8409. * @returns the position
  8410. */
  8411. getFrontPosition(distance: number): Vector3;
  8412. /** @hidden */
  8413. _getLockedTargetPosition(): Nullable<Vector3>;
  8414. private _storedPosition;
  8415. private _storedRotation;
  8416. private _storedRotationQuaternion;
  8417. /**
  8418. * Store current camera state of the camera (fov, position, rotation, etc..)
  8419. * @returns the camera
  8420. */
  8421. storeState(): Camera;
  8422. /**
  8423. * Restored camera state. You must call storeState() first
  8424. * @returns whether it was successful or not
  8425. * @hidden
  8426. */
  8427. _restoreStateValues(): boolean;
  8428. /** @hidden */
  8429. _initCache(): void;
  8430. /** @hidden */
  8431. _updateCache(ignoreParentClass?: boolean): void;
  8432. /** @hidden */
  8433. _isSynchronizedViewMatrix(): boolean;
  8434. /** @hidden */
  8435. _computeLocalCameraSpeed(): number;
  8436. /**
  8437. * Defines the target the camera should look at.
  8438. * @param target Defines the new target as a Vector or a mesh
  8439. */
  8440. setTarget(target: Vector3): void;
  8441. /**
  8442. * Return the current target position of the camera. This value is expressed in local space.
  8443. * @returns the target position
  8444. */
  8445. getTarget(): Vector3;
  8446. /** @hidden */
  8447. _decideIfNeedsToMove(): boolean;
  8448. /** @hidden */
  8449. _updatePosition(): void;
  8450. /** @hidden */
  8451. _checkInputs(): void;
  8452. protected _updateCameraRotationMatrix(): void;
  8453. /**
  8454. * 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)
  8455. * @returns the current camera
  8456. */
  8457. private _rotateUpVectorWithCameraRotationMatrix;
  8458. private _cachedRotationZ;
  8459. private _cachedQuaternionRotationZ;
  8460. /** @hidden */
  8461. _getViewMatrix(): Matrix;
  8462. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8463. /**
  8464. * @hidden
  8465. */
  8466. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8467. /**
  8468. * @hidden
  8469. */
  8470. _updateRigCameras(): void;
  8471. private _getRigCamPositionAndTarget;
  8472. /**
  8473. * Gets the current object class name.
  8474. * @return the class name
  8475. */
  8476. getClassName(): string;
  8477. }
  8478. }
  8479. declare module "babylonjs/Events/keyboardEvents" {
  8480. /**
  8481. * Gather the list of keyboard event types as constants.
  8482. */
  8483. export class KeyboardEventTypes {
  8484. /**
  8485. * The keydown event is fired when a key becomes active (pressed).
  8486. */
  8487. static readonly KEYDOWN: number;
  8488. /**
  8489. * The keyup event is fired when a key has been released.
  8490. */
  8491. static readonly KEYUP: number;
  8492. }
  8493. /**
  8494. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8495. */
  8496. export class KeyboardInfo {
  8497. /**
  8498. * Defines the type of event (KeyboardEventTypes)
  8499. */
  8500. type: number;
  8501. /**
  8502. * Defines the related dom event
  8503. */
  8504. event: KeyboardEvent;
  8505. /**
  8506. * Instantiates a new keyboard info.
  8507. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8508. * @param type Defines the type of event (KeyboardEventTypes)
  8509. * @param event Defines the related dom event
  8510. */
  8511. constructor(
  8512. /**
  8513. * Defines the type of event (KeyboardEventTypes)
  8514. */
  8515. type: number,
  8516. /**
  8517. * Defines the related dom event
  8518. */
  8519. event: KeyboardEvent);
  8520. }
  8521. /**
  8522. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8523. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8524. */
  8525. export class KeyboardInfoPre extends KeyboardInfo {
  8526. /**
  8527. * Defines the type of event (KeyboardEventTypes)
  8528. */
  8529. type: number;
  8530. /**
  8531. * Defines the related dom event
  8532. */
  8533. event: KeyboardEvent;
  8534. /**
  8535. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8536. */
  8537. skipOnPointerObservable: boolean;
  8538. /**
  8539. * Instantiates a new keyboard pre info.
  8540. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8541. * @param type Defines the type of event (KeyboardEventTypes)
  8542. * @param event Defines the related dom event
  8543. */
  8544. constructor(
  8545. /**
  8546. * Defines the type of event (KeyboardEventTypes)
  8547. */
  8548. type: number,
  8549. /**
  8550. * Defines the related dom event
  8551. */
  8552. event: KeyboardEvent);
  8553. }
  8554. }
  8555. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8556. import { Nullable } from "babylonjs/types";
  8557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8558. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8559. /**
  8560. * Manage the keyboard inputs to control the movement of a free camera.
  8561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8562. */
  8563. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8564. /**
  8565. * Defines the camera the input is attached to.
  8566. */
  8567. camera: FreeCamera;
  8568. /**
  8569. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8570. */
  8571. keysUp: number[];
  8572. /**
  8573. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8574. */
  8575. keysDown: number[];
  8576. /**
  8577. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8578. */
  8579. keysLeft: number[];
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8582. */
  8583. keysRight: number[];
  8584. private _keys;
  8585. private _onCanvasBlurObserver;
  8586. private _onKeyboardObserver;
  8587. private _engine;
  8588. private _scene;
  8589. /**
  8590. * Attach the input controls to a specific dom element to get the input from.
  8591. * @param element Defines the element the controls should be listened from
  8592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8593. */
  8594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8595. /**
  8596. * Detach the current controls from the specified dom element.
  8597. * @param element Defines the element to stop listening the inputs from
  8598. */
  8599. detachControl(element: Nullable<HTMLElement>): void;
  8600. /**
  8601. * Update the current camera state depending on the inputs that have been used this frame.
  8602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8603. */
  8604. checkInputs(): void;
  8605. /**
  8606. * Gets the class name of the current intput.
  8607. * @returns the class name
  8608. */
  8609. getClassName(): string;
  8610. /** @hidden */
  8611. _onLostFocus(): void;
  8612. /**
  8613. * Get the friendly name associated with the input class.
  8614. * @returns the input friendly name
  8615. */
  8616. getSimpleName(): string;
  8617. }
  8618. }
  8619. declare module "babylonjs/Lights/shadowLight" {
  8620. import { Camera } from "babylonjs/Cameras/camera";
  8621. import { Scene } from "babylonjs/scene";
  8622. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8624. import { Light } from "babylonjs/Lights/light";
  8625. /**
  8626. * Interface describing all the common properties and methods a shadow light needs to implement.
  8627. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8628. * as well as binding the different shadow properties to the effects.
  8629. */
  8630. export interface IShadowLight extends Light {
  8631. /**
  8632. * The light id in the scene (used in scene.findLighById for instance)
  8633. */
  8634. id: string;
  8635. /**
  8636. * The position the shdow will be casted from.
  8637. */
  8638. position: Vector3;
  8639. /**
  8640. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8641. */
  8642. direction: Vector3;
  8643. /**
  8644. * The transformed position. Position of the light in world space taking parenting in account.
  8645. */
  8646. transformedPosition: Vector3;
  8647. /**
  8648. * The transformed direction. Direction of the light in world space taking parenting in account.
  8649. */
  8650. transformedDirection: Vector3;
  8651. /**
  8652. * The friendly name of the light in the scene.
  8653. */
  8654. name: string;
  8655. /**
  8656. * Defines the shadow projection clipping minimum z value.
  8657. */
  8658. shadowMinZ: number;
  8659. /**
  8660. * Defines the shadow projection clipping maximum z value.
  8661. */
  8662. shadowMaxZ: number;
  8663. /**
  8664. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8665. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8666. */
  8667. computeTransformedInformation(): boolean;
  8668. /**
  8669. * Gets the scene the light belongs to.
  8670. * @returns The scene
  8671. */
  8672. getScene(): Scene;
  8673. /**
  8674. * Callback defining a custom Projection Matrix Builder.
  8675. * This can be used to override the default projection matrix computation.
  8676. */
  8677. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8678. /**
  8679. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8680. * @param matrix The materix to updated with the projection information
  8681. * @param viewMatrix The transform matrix of the light
  8682. * @param renderList The list of mesh to render in the map
  8683. * @returns The current light
  8684. */
  8685. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8686. /**
  8687. * Gets the current depth scale used in ESM.
  8688. * @returns The scale
  8689. */
  8690. getDepthScale(): number;
  8691. /**
  8692. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8693. * @returns true if a cube texture needs to be use
  8694. */
  8695. needCube(): boolean;
  8696. /**
  8697. * Detects if the projection matrix requires to be recomputed this frame.
  8698. * @returns true if it requires to be recomputed otherwise, false.
  8699. */
  8700. needProjectionMatrixCompute(): boolean;
  8701. /**
  8702. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8703. */
  8704. forceProjectionMatrixCompute(): void;
  8705. /**
  8706. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8707. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8708. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8709. */
  8710. getShadowDirection(faceIndex?: number): Vector3;
  8711. /**
  8712. * Gets the minZ used for shadow according to both the scene and the light.
  8713. * @param activeCamera The camera we are returning the min for
  8714. * @returns the depth min z
  8715. */
  8716. getDepthMinZ(activeCamera: Camera): number;
  8717. /**
  8718. * Gets the maxZ used for shadow according to both the scene and the light.
  8719. * @param activeCamera The camera we are returning the max for
  8720. * @returns the depth max z
  8721. */
  8722. getDepthMaxZ(activeCamera: Camera): number;
  8723. }
  8724. /**
  8725. * Base implementation IShadowLight
  8726. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8727. */
  8728. export abstract class ShadowLight extends Light implements IShadowLight {
  8729. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8730. protected _position: Vector3;
  8731. protected _setPosition(value: Vector3): void;
  8732. /**
  8733. * Sets the position the shadow will be casted from. Also use as the light position for both
  8734. * point and spot lights.
  8735. */
  8736. /**
  8737. * Sets the position the shadow will be casted from. Also use as the light position for both
  8738. * point and spot lights.
  8739. */
  8740. position: Vector3;
  8741. protected _direction: Vector3;
  8742. protected _setDirection(value: Vector3): void;
  8743. /**
  8744. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8745. * Also use as the light direction on spot and directional lights.
  8746. */
  8747. /**
  8748. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8749. * Also use as the light direction on spot and directional lights.
  8750. */
  8751. direction: Vector3;
  8752. private _shadowMinZ;
  8753. /**
  8754. * Gets the shadow projection clipping minimum z value.
  8755. */
  8756. /**
  8757. * Sets the shadow projection clipping minimum z value.
  8758. */
  8759. shadowMinZ: number;
  8760. private _shadowMaxZ;
  8761. /**
  8762. * Sets the shadow projection clipping maximum z value.
  8763. */
  8764. /**
  8765. * Gets the shadow projection clipping maximum z value.
  8766. */
  8767. shadowMaxZ: number;
  8768. /**
  8769. * Callback defining a custom Projection Matrix Builder.
  8770. * This can be used to override the default projection matrix computation.
  8771. */
  8772. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8773. /**
  8774. * The transformed position. Position of the light in world space taking parenting in account.
  8775. */
  8776. transformedPosition: Vector3;
  8777. /**
  8778. * The transformed direction. Direction of the light in world space taking parenting in account.
  8779. */
  8780. transformedDirection: Vector3;
  8781. private _needProjectionMatrixCompute;
  8782. /**
  8783. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8784. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8785. */
  8786. computeTransformedInformation(): boolean;
  8787. /**
  8788. * Return the depth scale used for the shadow map.
  8789. * @returns the depth scale.
  8790. */
  8791. getDepthScale(): number;
  8792. /**
  8793. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8794. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8795. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8796. */
  8797. getShadowDirection(faceIndex?: number): Vector3;
  8798. /**
  8799. * Returns the ShadowLight absolute position in the World.
  8800. * @returns the position vector in world space
  8801. */
  8802. getAbsolutePosition(): Vector3;
  8803. /**
  8804. * Sets the ShadowLight direction toward the passed target.
  8805. * @param target The point to target in local space
  8806. * @returns the updated ShadowLight direction
  8807. */
  8808. setDirectionToTarget(target: Vector3): Vector3;
  8809. /**
  8810. * Returns the light rotation in euler definition.
  8811. * @returns the x y z rotation in local space.
  8812. */
  8813. getRotation(): Vector3;
  8814. /**
  8815. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8816. * @returns true if a cube texture needs to be use
  8817. */
  8818. needCube(): boolean;
  8819. /**
  8820. * Detects if the projection matrix requires to be recomputed this frame.
  8821. * @returns true if it requires to be recomputed otherwise, false.
  8822. */
  8823. needProjectionMatrixCompute(): boolean;
  8824. /**
  8825. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8826. */
  8827. forceProjectionMatrixCompute(): void;
  8828. /** @hidden */
  8829. _initCache(): void;
  8830. /** @hidden */
  8831. _isSynchronized(): boolean;
  8832. /**
  8833. * Computes the world matrix of the node
  8834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8835. * @returns the world matrix
  8836. */
  8837. computeWorldMatrix(force?: boolean): Matrix;
  8838. /**
  8839. * Gets the minZ used for shadow according to both the scene and the light.
  8840. * @param activeCamera The camera we are returning the min for
  8841. * @returns the depth min z
  8842. */
  8843. getDepthMinZ(activeCamera: Camera): number;
  8844. /**
  8845. * Gets the maxZ used for shadow according to both the scene and the light.
  8846. * @param activeCamera The camera we are returning the max for
  8847. * @returns the depth max z
  8848. */
  8849. getDepthMaxZ(activeCamera: Camera): number;
  8850. /**
  8851. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8852. * @param matrix The materix to updated with the projection information
  8853. * @param viewMatrix The transform matrix of the light
  8854. * @param renderList The list of mesh to render in the map
  8855. * @returns The current light
  8856. */
  8857. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8858. }
  8859. }
  8860. declare module "babylonjs/Materials/materialHelper" {
  8861. import { Nullable } from "babylonjs/types";
  8862. import { Scene } from "babylonjs/scene";
  8863. import { Engine } from "babylonjs/Engines/engine";
  8864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8865. import { Light } from "babylonjs/Lights/light";
  8866. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8867. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8869. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8870. /**
  8871. * "Static Class" containing the most commonly used helper while dealing with material for
  8872. * rendering purpose.
  8873. *
  8874. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8875. *
  8876. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8877. */
  8878. export class MaterialHelper {
  8879. /**
  8880. * Bind the current view position to an effect.
  8881. * @param effect The effect to be bound
  8882. * @param scene The scene the eyes position is used from
  8883. */
  8884. static BindEyePosition(effect: Effect, scene: Scene): void;
  8885. /**
  8886. * Helps preparing the defines values about the UVs in used in the effect.
  8887. * UVs are shared as much as we can accross channels in the shaders.
  8888. * @param texture The texture we are preparing the UVs for
  8889. * @param defines The defines to update
  8890. * @param key The channel key "diffuse", "specular"... used in the shader
  8891. */
  8892. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8893. /**
  8894. * Binds a texture matrix value to its corrsponding uniform
  8895. * @param texture The texture to bind the matrix for
  8896. * @param uniformBuffer The uniform buffer receivin the data
  8897. * @param key The channel key "diffuse", "specular"... used in the shader
  8898. */
  8899. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8900. /**
  8901. * Gets the current status of the fog (should it be enabled?)
  8902. * @param mesh defines the mesh to evaluate for fog support
  8903. * @param scene defines the hosting scene
  8904. * @returns true if fog must be enabled
  8905. */
  8906. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8907. /**
  8908. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8909. * @param mesh defines the current mesh
  8910. * @param scene defines the current scene
  8911. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8912. * @param pointsCloud defines if point cloud rendering has to be turned on
  8913. * @param fogEnabled defines if fog has to be turned on
  8914. * @param alphaTest defines if alpha testing has to be turned on
  8915. * @param defines defines the current list of defines
  8916. */
  8917. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8918. /**
  8919. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8920. * @param scene defines the current scene
  8921. * @param engine defines the current engine
  8922. * @param defines specifies the list of active defines
  8923. * @param useInstances defines if instances have to be turned on
  8924. * @param useClipPlane defines if clip plane have to be turned on
  8925. */
  8926. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8927. /**
  8928. * Prepares the defines for bones
  8929. * @param mesh The mesh containing the geometry data we will draw
  8930. * @param defines The defines to update
  8931. */
  8932. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8933. /**
  8934. * Prepares the defines for morph targets
  8935. * @param mesh The mesh containing the geometry data we will draw
  8936. * @param defines The defines to update
  8937. */
  8938. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8939. /**
  8940. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8944. * @param useBones Precise whether bones should be used or not (override mesh info)
  8945. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8946. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8947. * @returns false if defines are considered not dirty and have not been checked
  8948. */
  8949. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8950. /**
  8951. * Prepares the defines related to multiview
  8952. * @param scene The scene we are intending to draw
  8953. * @param defines The defines to update
  8954. */
  8955. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8956. /**
  8957. * Prepares the defines related to the light information passed in parameter
  8958. * @param scene The scene we are intending to draw
  8959. * @param mesh The mesh the effect is compiling for
  8960. * @param light The light the effect is compiling for
  8961. * @param lightIndex The index of the light
  8962. * @param defines The defines to update
  8963. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8964. * @param state Defines the current state regarding what is needed (normals, etc...)
  8965. */
  8966. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8967. needNormals: boolean;
  8968. needRebuild: boolean;
  8969. shadowEnabled: boolean;
  8970. specularEnabled: boolean;
  8971. lightmapMode: boolean;
  8972. }): void;
  8973. /**
  8974. * Prepares the defines related to the light information passed in parameter
  8975. * @param scene The scene we are intending to draw
  8976. * @param mesh The mesh the effect is compiling for
  8977. * @param defines The defines to update
  8978. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8979. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8980. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8981. * @returns true if normals will be required for the rest of the effect
  8982. */
  8983. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8984. /**
  8985. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8986. * @param lightIndex defines the light index
  8987. * @param uniformsList The uniform list
  8988. * @param samplersList The sampler list
  8989. * @param projectedLightTexture defines if projected texture must be used
  8990. * @param uniformBuffersList defines an optional list of uniform buffers
  8991. */
  8992. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8993. /**
  8994. * Prepares the uniforms and samplers list to be used in the effect
  8995. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8996. * @param samplersList The sampler list
  8997. * @param defines The defines helping in the list generation
  8998. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8999. */
  9000. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9001. /**
  9002. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9003. * @param defines The defines to update while falling back
  9004. * @param fallbacks The authorized effect fallbacks
  9005. * @param maxSimultaneousLights The maximum number of lights allowed
  9006. * @param rank the current rank of the Effect
  9007. * @returns The newly affected rank
  9008. */
  9009. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9010. private static _TmpMorphInfluencers;
  9011. /**
  9012. * Prepares the list of attributes required for morph targets according to the effect defines.
  9013. * @param attribs The current list of supported attribs
  9014. * @param mesh The mesh to prepare the morph targets attributes for
  9015. * @param influencers The number of influencers
  9016. */
  9017. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9018. /**
  9019. * Prepares the list of attributes required for morph targets according to the effect defines.
  9020. * @param attribs The current list of supported attribs
  9021. * @param mesh The mesh to prepare the morph targets attributes for
  9022. * @param defines The current Defines of the effect
  9023. */
  9024. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9025. /**
  9026. * Prepares the list of attributes required for bones according to the effect defines.
  9027. * @param attribs The current list of supported attribs
  9028. * @param mesh The mesh to prepare the bones attributes for
  9029. * @param defines The current Defines of the effect
  9030. * @param fallbacks The current efffect fallback strategy
  9031. */
  9032. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9033. /**
  9034. * Check and prepare the list of attributes required for instances according to the effect defines.
  9035. * @param attribs The current list of supported attribs
  9036. * @param defines The current MaterialDefines of the effect
  9037. */
  9038. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9039. /**
  9040. * Add the list of attributes required for instances to the attribs array.
  9041. * @param attribs The current list of supported attribs
  9042. */
  9043. static PushAttributesForInstances(attribs: string[]): void;
  9044. /**
  9045. * Binds the light shadow information to the effect for the given mesh.
  9046. * @param light The light containing the generator
  9047. * @param scene The scene the lights belongs to
  9048. * @param mesh The mesh we are binding the information to render
  9049. * @param lightIndex The light index in the effect used to render the mesh
  9050. * @param effect The effect we are binding the data to
  9051. */
  9052. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9053. /**
  9054. * Binds the light information to the effect.
  9055. * @param light The light containing the generator
  9056. * @param effect The effect we are binding the data to
  9057. * @param lightIndex The light index in the effect used to render
  9058. */
  9059. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9060. /**
  9061. * Binds the lights information from the scene to the effect for the given mesh.
  9062. * @param light Light to bind
  9063. * @param lightIndex Light index
  9064. * @param scene The scene where the light belongs to
  9065. * @param mesh The mesh we are binding the information to render
  9066. * @param effect The effect we are binding the data to
  9067. * @param useSpecular Defines if specular is supported
  9068. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9070. */
  9071. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param scene The scene the lights belongs to
  9075. * @param mesh The mesh we are binding the information to render
  9076. * @param effect The effect we are binding the data to
  9077. * @param defines The generated defines for the effect
  9078. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9079. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9080. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9081. */
  9082. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9083. private static _tempFogColor;
  9084. /**
  9085. * Binds the fog information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param linearSpace Defines if the fog effect is applied in linear space
  9090. */
  9091. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9092. /**
  9093. * Binds the bones information from the mesh to the effect.
  9094. * @param mesh The mesh we are binding the information to render
  9095. * @param effect The effect we are binding the data to
  9096. */
  9097. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9098. /**
  9099. * Binds the morph targets information from the mesh to the effect.
  9100. * @param abstractMesh The mesh we are binding the information to render
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9104. /**
  9105. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9106. * @param defines The generated defines used in the effect
  9107. * @param effect The effect we are binding the data to
  9108. * @param scene The scene we are willing to render with logarithmic scale for
  9109. */
  9110. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Binds the clip plane information from the scene to the effect.
  9113. * @param scene The scene the clip plane information are extracted from
  9114. * @param effect The effect we are binding the data to
  9115. */
  9116. static BindClipPlane(effect: Effect, scene: Scene): void;
  9117. }
  9118. }
  9119. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9120. /** @hidden */
  9121. export var packingFunctions: {
  9122. name: string;
  9123. shader: string;
  9124. };
  9125. }
  9126. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9127. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9128. /** @hidden */
  9129. export var shadowMapPixelShader: {
  9130. name: string;
  9131. shader: string;
  9132. };
  9133. }
  9134. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9135. /** @hidden */
  9136. export var bonesDeclaration: {
  9137. name: string;
  9138. shader: string;
  9139. };
  9140. }
  9141. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9142. /** @hidden */
  9143. export var morphTargetsVertexGlobalDeclaration: {
  9144. name: string;
  9145. shader: string;
  9146. };
  9147. }
  9148. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9149. /** @hidden */
  9150. export var morphTargetsVertexDeclaration: {
  9151. name: string;
  9152. shader: string;
  9153. };
  9154. }
  9155. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9156. /** @hidden */
  9157. export var instancesDeclaration: {
  9158. name: string;
  9159. shader: string;
  9160. };
  9161. }
  9162. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9163. /** @hidden */
  9164. export var helperFunctions: {
  9165. name: string;
  9166. shader: string;
  9167. };
  9168. }
  9169. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9170. /** @hidden */
  9171. export var morphTargetsVertex: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9177. /** @hidden */
  9178. export var instancesVertex: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9184. /** @hidden */
  9185. export var bonesVertex: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9191. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9192. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9193. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9194. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9195. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9196. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9197. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9198. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9199. /** @hidden */
  9200. export var shadowMapVertexShader: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9206. /** @hidden */
  9207. export var depthBoxBlurPixelShader: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9213. import { Nullable } from "babylonjs/types";
  9214. import { Scene } from "babylonjs/scene";
  9215. import { Matrix } from "babylonjs/Maths/math.vector";
  9216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9218. import { Mesh } from "babylonjs/Meshes/mesh";
  9219. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9220. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9221. import { Effect } from "babylonjs/Materials/effect";
  9222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9223. import "babylonjs/Shaders/shadowMap.fragment";
  9224. import "babylonjs/Shaders/shadowMap.vertex";
  9225. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9226. import { Observable } from "babylonjs/Misc/observable";
  9227. /**
  9228. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9229. */
  9230. export interface ICustomShaderOptions {
  9231. /**
  9232. * Gets or sets the custom shader name to use
  9233. */
  9234. shaderName: string;
  9235. /**
  9236. * The list of attribute names used in the shader
  9237. */
  9238. attributes?: string[];
  9239. /**
  9240. * The list of unifrom names used in the shader
  9241. */
  9242. uniforms?: string[];
  9243. /**
  9244. * The list of sampler names used in the shader
  9245. */
  9246. samplers?: string[];
  9247. /**
  9248. * The list of defines used in the shader
  9249. */
  9250. defines?: string[];
  9251. }
  9252. /**
  9253. * Interface to implement to create a shadow generator compatible with BJS.
  9254. */
  9255. export interface IShadowGenerator {
  9256. /**
  9257. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9258. * @returns The render target texture if present otherwise, null
  9259. */
  9260. getShadowMap(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9263. * @returns The render target texture if the shadow map is present otherwise, null
  9264. */
  9265. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9268. * @param subMesh The submesh we want to render in the shadow map
  9269. * @param useInstances Defines wether will draw in the map using instances
  9270. * @returns true if ready otherwise, false
  9271. */
  9272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9273. /**
  9274. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9275. * @param defines Defines of the material we want to update
  9276. * @param lightIndex Index of the light in the enabled light list of the material
  9277. */
  9278. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9279. /**
  9280. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9281. * defined in the generator but impacting the effect).
  9282. * It implies the unifroms available on the materials are the standard BJS ones.
  9283. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9284. * @param effect The effect we are binfing the information for
  9285. */
  9286. bindShadowLight(lightIndex: string, effect: Effect): void;
  9287. /**
  9288. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9289. * (eq to shadow prjection matrix * light transform matrix)
  9290. * @returns The transform matrix used to create the shadow map
  9291. */
  9292. getTransformMatrix(): Matrix;
  9293. /**
  9294. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9295. * Cube and 2D textures for instance.
  9296. */
  9297. recreateShadowMap(): void;
  9298. /**
  9299. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9300. * @param onCompiled Callback triggered at the and of the effects compilation
  9301. * @param options Sets of optional options forcing the compilation with different modes
  9302. */
  9303. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9304. useInstances: boolean;
  9305. }>): void;
  9306. /**
  9307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9308. * @param options Sets of optional options forcing the compilation with different modes
  9309. * @returns A promise that resolves when the compilation completes
  9310. */
  9311. forceCompilationAsync(options?: Partial<{
  9312. useInstances: boolean;
  9313. }>): Promise<void>;
  9314. /**
  9315. * Serializes the shadow generator setup to a json object.
  9316. * @returns The serialized JSON object
  9317. */
  9318. serialize(): any;
  9319. /**
  9320. * Disposes the Shadow map and related Textures and effects.
  9321. */
  9322. dispose(): void;
  9323. }
  9324. /**
  9325. * Default implementation IShadowGenerator.
  9326. * This is the main object responsible of generating shadows in the framework.
  9327. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9328. */
  9329. export class ShadowGenerator implements IShadowGenerator {
  9330. /**
  9331. * Shadow generator mode None: no filtering applied.
  9332. */
  9333. static readonly FILTER_NONE: number;
  9334. /**
  9335. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9337. */
  9338. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9339. /**
  9340. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9341. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9342. */
  9343. static readonly FILTER_POISSONSAMPLING: number;
  9344. /**
  9345. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9346. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9347. */
  9348. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9349. /**
  9350. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9351. * edge artifacts on steep falloff.
  9352. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9353. */
  9354. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9355. /**
  9356. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9357. * edge artifacts on steep falloff.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode PCF: Percentage Closer Filtering
  9363. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9364. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9365. */
  9366. static readonly FILTER_PCF: number;
  9367. /**
  9368. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9369. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9370. * Contact Hardening
  9371. */
  9372. static readonly FILTER_PCSS: number;
  9373. /**
  9374. * Reserved for PCF and PCSS
  9375. * Highest Quality.
  9376. *
  9377. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9378. *
  9379. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9380. */
  9381. static readonly QUALITY_HIGH: number;
  9382. /**
  9383. * Reserved for PCF and PCSS
  9384. * Good tradeoff for quality/perf cross devices
  9385. *
  9386. * Execute PCF on a 3*3 kernel.
  9387. *
  9388. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9389. */
  9390. static readonly QUALITY_MEDIUM: number;
  9391. /**
  9392. * Reserved for PCF and PCSS
  9393. * The lowest quality but the fastest.
  9394. *
  9395. * Execute PCF on a 1*1 kernel.
  9396. *
  9397. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9398. */
  9399. static readonly QUALITY_LOW: number;
  9400. /** Gets or sets the custom shader name to use */
  9401. customShaderOptions: ICustomShaderOptions;
  9402. /**
  9403. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9404. */
  9405. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9406. /**
  9407. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9408. */
  9409. onAfterShadowMapRenderObservable: Observable<Effect>;
  9410. /**
  9411. * Observable triggered before a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9413. */
  9414. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. /**
  9416. * Observable triggered after a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9418. */
  9419. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. private _bias;
  9421. /**
  9422. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9423. */
  9424. /**
  9425. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9426. */
  9427. bias: number;
  9428. private _normalBias;
  9429. /**
  9430. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9431. */
  9432. /**
  9433. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9434. */
  9435. normalBias: number;
  9436. private _blurBoxOffset;
  9437. /**
  9438. * Gets the blur box offset: offset applied during the blur pass.
  9439. * Only useful if useKernelBlur = false
  9440. */
  9441. /**
  9442. * Sets the blur box offset: offset applied during the blur pass.
  9443. * Only useful if useKernelBlur = false
  9444. */
  9445. blurBoxOffset: number;
  9446. private _blurScale;
  9447. /**
  9448. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9449. * 2 means half of the size.
  9450. */
  9451. /**
  9452. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9453. * 2 means half of the size.
  9454. */
  9455. blurScale: number;
  9456. private _blurKernel;
  9457. /**
  9458. * Gets the blur kernel: kernel size of the blur pass.
  9459. * Only useful if useKernelBlur = true
  9460. */
  9461. /**
  9462. * Sets the blur kernel: kernel size of the blur pass.
  9463. * Only useful if useKernelBlur = true
  9464. */
  9465. blurKernel: number;
  9466. private _useKernelBlur;
  9467. /**
  9468. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9469. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9470. */
  9471. /**
  9472. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9473. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9474. */
  9475. useKernelBlur: boolean;
  9476. private _depthScale;
  9477. /**
  9478. * Gets the depth scale used in ESM mode.
  9479. */
  9480. /**
  9481. * Sets the depth scale used in ESM mode.
  9482. * This can override the scale stored on the light.
  9483. */
  9484. depthScale: number;
  9485. private _filter;
  9486. /**
  9487. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9488. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9489. */
  9490. /**
  9491. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9492. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9493. */
  9494. filter: number;
  9495. /**
  9496. * Gets if the current filter is set to Poisson Sampling.
  9497. */
  9498. /**
  9499. * Sets the current filter to Poisson Sampling.
  9500. */
  9501. usePoissonSampling: boolean;
  9502. /**
  9503. * Gets if the current filter is set to ESM.
  9504. */
  9505. /**
  9506. * Sets the current filter is to ESM.
  9507. */
  9508. useExponentialShadowMap: boolean;
  9509. /**
  9510. * Gets if the current filter is set to filtered ESM.
  9511. */
  9512. /**
  9513. * Gets if the current filter is set to filtered ESM.
  9514. */
  9515. useBlurExponentialShadowMap: boolean;
  9516. /**
  9517. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9518. * exponential to prevent steep falloff artifacts).
  9519. */
  9520. /**
  9521. * Sets the current filter to "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. useCloseExponentialShadowMap: boolean;
  9525. /**
  9526. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. /**
  9530. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9531. * exponential to prevent steep falloff artifacts).
  9532. */
  9533. useBlurCloseExponentialShadowMap: boolean;
  9534. /**
  9535. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9536. */
  9537. /**
  9538. * Sets the current filter to "PCF" (percentage closer filtering).
  9539. */
  9540. usePercentageCloserFiltering: boolean;
  9541. private _filteringQuality;
  9542. /**
  9543. * Gets the PCF or PCSS Quality.
  9544. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9545. */
  9546. /**
  9547. * Sets the PCF or PCSS Quality.
  9548. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9549. */
  9550. filteringQuality: number;
  9551. /**
  9552. * Gets if the current filter is set to "PCSS" (contact hardening).
  9553. */
  9554. /**
  9555. * Sets the current filter to "PCSS" (contact hardening).
  9556. */
  9557. useContactHardeningShadow: boolean;
  9558. private _contactHardeningLightSizeUVRatio;
  9559. /**
  9560. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9561. * Using a ratio helps keeping shape stability independently of the map size.
  9562. *
  9563. * It does not account for the light projection as it was having too much
  9564. * instability during the light setup or during light position changes.
  9565. *
  9566. * Only valid if useContactHardeningShadow is true.
  9567. */
  9568. /**
  9569. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9570. * Using a ratio helps keeping shape stability independently of the map size.
  9571. *
  9572. * It does not account for the light projection as it was having too much
  9573. * instability during the light setup or during light position changes.
  9574. *
  9575. * Only valid if useContactHardeningShadow is true.
  9576. */
  9577. contactHardeningLightSizeUVRatio: number;
  9578. private _darkness;
  9579. /** Gets or sets the actual darkness of a shadow */
  9580. darkness: number;
  9581. /**
  9582. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9583. * 0 means strongest and 1 would means no shadow.
  9584. * @returns the darkness.
  9585. */
  9586. getDarkness(): number;
  9587. /**
  9588. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9589. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9590. * @returns the shadow generator allowing fluent coding.
  9591. */
  9592. setDarkness(darkness: number): ShadowGenerator;
  9593. private _transparencyShadow;
  9594. /** Gets or sets the ability to have transparent shadow */
  9595. transparencyShadow: boolean;
  9596. /**
  9597. * Sets the ability to have transparent shadow (boolean).
  9598. * @param transparent True if transparent else False
  9599. * @returns the shadow generator allowing fluent coding
  9600. */
  9601. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9602. private _shadowMap;
  9603. private _shadowMap2;
  9604. /**
  9605. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9606. * @returns The render target texture if present otherwise, null
  9607. */
  9608. getShadowMap(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9611. * @returns The render target texture if the shadow map is present otherwise, null
  9612. */
  9613. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the class name of that object
  9616. * @returns "ShadowGenerator"
  9617. */
  9618. getClassName(): string;
  9619. /**
  9620. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9621. * @param mesh Mesh to add
  9622. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9623. * @returns the Shadow Generator itself
  9624. */
  9625. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9626. /**
  9627. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9628. * @param mesh Mesh to remove
  9629. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9630. * @returns the Shadow Generator itself
  9631. */
  9632. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9633. /**
  9634. * Controls the extent to which the shadows fade out at the edge of the frustum
  9635. * Used only by directionals and spots
  9636. */
  9637. frustumEdgeFalloff: number;
  9638. private _light;
  9639. /**
  9640. * Returns the associated light object.
  9641. * @returns the light generating the shadow
  9642. */
  9643. getLight(): IShadowLight;
  9644. /**
  9645. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9646. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9647. * It might on the other hand introduce peter panning.
  9648. */
  9649. forceBackFacesOnly: boolean;
  9650. private _scene;
  9651. private _lightDirection;
  9652. private _effect;
  9653. private _viewMatrix;
  9654. private _projectionMatrix;
  9655. private _transformMatrix;
  9656. private _cachedPosition;
  9657. private _cachedDirection;
  9658. private _cachedDefines;
  9659. private _currentRenderID;
  9660. private _boxBlurPostprocess;
  9661. private _kernelBlurXPostprocess;
  9662. private _kernelBlurYPostprocess;
  9663. private _blurPostProcesses;
  9664. private _mapSize;
  9665. private _currentFaceIndex;
  9666. private _currentFaceIndexCache;
  9667. private _textureType;
  9668. private _defaultTextureMatrix;
  9669. /** @hidden */
  9670. static _SceneComponentInitialization: (scene: Scene) => void;
  9671. /**
  9672. * Creates a ShadowGenerator object.
  9673. * A ShadowGenerator is the required tool to use the shadows.
  9674. * Each light casting shadows needs to use its own ShadowGenerator.
  9675. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9676. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9677. * @param light The light object generating the shadows.
  9678. * @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.
  9679. */
  9680. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9681. private _initializeGenerator;
  9682. private _initializeShadowMap;
  9683. private _initializeBlurRTTAndPostProcesses;
  9684. private _renderForShadowMap;
  9685. private _renderSubMeshForShadowMap;
  9686. private _applyFilterValues;
  9687. /**
  9688. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9689. * @param onCompiled Callback triggered at the and of the effects compilation
  9690. * @param options Sets of optional options forcing the compilation with different modes
  9691. */
  9692. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9693. useInstances: boolean;
  9694. }>): void;
  9695. /**
  9696. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9697. * @param options Sets of optional options forcing the compilation with different modes
  9698. * @returns A promise that resolves when the compilation completes
  9699. */
  9700. forceCompilationAsync(options?: Partial<{
  9701. useInstances: boolean;
  9702. }>): Promise<void>;
  9703. /**
  9704. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9705. * @param subMesh The submesh we want to render in the shadow map
  9706. * @param useInstances Defines wether will draw in the map using instances
  9707. * @returns true if ready otherwise, false
  9708. */
  9709. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9710. /**
  9711. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9712. * @param defines Defines of the material we want to update
  9713. * @param lightIndex Index of the light in the enabled light list of the material
  9714. */
  9715. prepareDefines(defines: any, lightIndex: number): void;
  9716. /**
  9717. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9718. * defined in the generator but impacting the effect).
  9719. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9720. * @param effect The effect we are binfing the information for
  9721. */
  9722. bindShadowLight(lightIndex: string, effect: Effect): void;
  9723. /**
  9724. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9725. * (eq to shadow prjection matrix * light transform matrix)
  9726. * @returns The transform matrix used to create the shadow map
  9727. */
  9728. getTransformMatrix(): Matrix;
  9729. /**
  9730. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9731. * Cube and 2D textures for instance.
  9732. */
  9733. recreateShadowMap(): void;
  9734. private _disposeBlurPostProcesses;
  9735. private _disposeRTTandPostProcesses;
  9736. /**
  9737. * Disposes the ShadowGenerator.
  9738. * Returns nothing.
  9739. */
  9740. dispose(): void;
  9741. /**
  9742. * Serializes the shadow generator setup to a json object.
  9743. * @returns The serialized JSON object
  9744. */
  9745. serialize(): any;
  9746. /**
  9747. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9748. * @param parsedShadowGenerator The JSON object to parse
  9749. * @param scene The scene to create the shadow map for
  9750. * @returns The parsed shadow generator
  9751. */
  9752. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9753. }
  9754. }
  9755. declare module "babylonjs/Lights/light" {
  9756. import { Nullable } from "babylonjs/types";
  9757. import { Scene } from "babylonjs/scene";
  9758. import { Vector3 } from "babylonjs/Maths/math.vector";
  9759. import { Color3 } from "babylonjs/Maths/math.color";
  9760. import { Node } from "babylonjs/node";
  9761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9762. import { Effect } from "babylonjs/Materials/effect";
  9763. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9764. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9765. /**
  9766. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9767. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9768. * 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.
  9769. */
  9770. export abstract class Light extends Node {
  9771. /**
  9772. * Falloff Default: light is falling off following the material specification:
  9773. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9774. */
  9775. static readonly FALLOFF_DEFAULT: number;
  9776. /**
  9777. * Falloff Physical: light is falling off following the inverse squared distance law.
  9778. */
  9779. static readonly FALLOFF_PHYSICAL: number;
  9780. /**
  9781. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9782. * to enhance interoperability with other engines.
  9783. */
  9784. static readonly FALLOFF_GLTF: number;
  9785. /**
  9786. * Falloff Standard: light is falling off like in the standard material
  9787. * to enhance interoperability with other materials.
  9788. */
  9789. static readonly FALLOFF_STANDARD: number;
  9790. /**
  9791. * If every light affecting the material is in this lightmapMode,
  9792. * material.lightmapTexture adds or multiplies
  9793. * (depends on material.useLightmapAsShadowmap)
  9794. * after every other light calculations.
  9795. */
  9796. static readonly LIGHTMAP_DEFAULT: number;
  9797. /**
  9798. * material.lightmapTexture as only diffuse lighting from this light
  9799. * adds only specular lighting from this light
  9800. * adds dynamic shadows
  9801. */
  9802. static readonly LIGHTMAP_SPECULAR: number;
  9803. /**
  9804. * material.lightmapTexture as only lighting
  9805. * no light calculation from this light
  9806. * only adds dynamic shadows from this light
  9807. */
  9808. static readonly LIGHTMAP_SHADOWSONLY: number;
  9809. /**
  9810. * Each light type uses the default quantity according to its type:
  9811. * point/spot lights use luminous intensity
  9812. * directional lights use illuminance
  9813. */
  9814. static readonly INTENSITYMODE_AUTOMATIC: number;
  9815. /**
  9816. * lumen (lm)
  9817. */
  9818. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9819. /**
  9820. * candela (lm/sr)
  9821. */
  9822. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9823. /**
  9824. * lux (lm/m^2)
  9825. */
  9826. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9827. /**
  9828. * nit (cd/m^2)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINANCE: number;
  9831. /**
  9832. * Light type const id of the point light.
  9833. */
  9834. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9835. /**
  9836. * Light type const id of the directional light.
  9837. */
  9838. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9839. /**
  9840. * Light type const id of the spot light.
  9841. */
  9842. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9843. /**
  9844. * Light type const id of the hemispheric light.
  9845. */
  9846. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9847. /**
  9848. * Diffuse gives the basic color to an object.
  9849. */
  9850. diffuse: Color3;
  9851. /**
  9852. * Specular produces a highlight color on an object.
  9853. * Note: This is note affecting PBR materials.
  9854. */
  9855. specular: Color3;
  9856. /**
  9857. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9858. * falling off base on range or angle.
  9859. * This can be set to any values in Light.FALLOFF_x.
  9860. *
  9861. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9862. * other types of materials.
  9863. */
  9864. falloffType: number;
  9865. /**
  9866. * Strength of the light.
  9867. * Note: By default it is define in the framework own unit.
  9868. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9869. */
  9870. intensity: number;
  9871. private _range;
  9872. protected _inverseSquaredRange: number;
  9873. /**
  9874. * Defines how far from the source the light is impacting in scene units.
  9875. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9876. */
  9877. /**
  9878. * Defines how far from the source the light is impacting in scene units.
  9879. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9880. */
  9881. range: number;
  9882. /**
  9883. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9884. * of light.
  9885. */
  9886. private _photometricScale;
  9887. private _intensityMode;
  9888. /**
  9889. * Gets the photometric scale used to interpret the intensity.
  9890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9891. */
  9892. /**
  9893. * Sets the photometric scale used to interpret the intensity.
  9894. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9895. */
  9896. intensityMode: number;
  9897. private _radius;
  9898. /**
  9899. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9900. */
  9901. /**
  9902. * sets the light radius used by PBR Materials to simulate soft area lights.
  9903. */
  9904. radius: number;
  9905. private _renderPriority;
  9906. /**
  9907. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9908. * exceeding the number allowed of the materials.
  9909. */
  9910. renderPriority: number;
  9911. private _shadowEnabled;
  9912. /**
  9913. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9914. * the current shadow generator.
  9915. */
  9916. /**
  9917. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9918. * the current shadow generator.
  9919. */
  9920. shadowEnabled: boolean;
  9921. private _includedOnlyMeshes;
  9922. /**
  9923. * Gets the only meshes impacted by this light.
  9924. */
  9925. /**
  9926. * Sets the only meshes impacted by this light.
  9927. */
  9928. includedOnlyMeshes: AbstractMesh[];
  9929. private _excludedMeshes;
  9930. /**
  9931. * Gets the meshes not impacted by this light.
  9932. */
  9933. /**
  9934. * Sets the meshes not impacted by this light.
  9935. */
  9936. excludedMeshes: AbstractMesh[];
  9937. private _excludeWithLayerMask;
  9938. /**
  9939. * Gets the layer id use to find what meshes are not impacted by the light.
  9940. * Inactive if 0
  9941. */
  9942. /**
  9943. * Sets the layer id use to find what meshes are not impacted by the light.
  9944. * Inactive if 0
  9945. */
  9946. excludeWithLayerMask: number;
  9947. private _includeOnlyWithLayerMask;
  9948. /**
  9949. * Gets the layer id use to find what meshes are impacted by the light.
  9950. * Inactive if 0
  9951. */
  9952. /**
  9953. * Sets the layer id use to find what meshes are impacted by the light.
  9954. * Inactive if 0
  9955. */
  9956. includeOnlyWithLayerMask: number;
  9957. private _lightmapMode;
  9958. /**
  9959. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9960. */
  9961. /**
  9962. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9963. */
  9964. lightmapMode: number;
  9965. /**
  9966. * Shadow generator associted to the light.
  9967. * @hidden Internal use only.
  9968. */
  9969. _shadowGenerator: Nullable<IShadowGenerator>;
  9970. /**
  9971. * @hidden Internal use only.
  9972. */
  9973. _excludedMeshesIds: string[];
  9974. /**
  9975. * @hidden Internal use only.
  9976. */
  9977. _includedOnlyMeshesIds: string[];
  9978. /**
  9979. * The current light unifom buffer.
  9980. * @hidden Internal use only.
  9981. */
  9982. _uniformBuffer: UniformBuffer;
  9983. /**
  9984. * Creates a Light object in the scene.
  9985. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9986. * @param name The firendly name of the light
  9987. * @param scene The scene the light belongs too
  9988. */
  9989. constructor(name: string, scene: Scene);
  9990. protected abstract _buildUniformLayout(): void;
  9991. /**
  9992. * Sets the passed Effect "effect" with the Light information.
  9993. * @param effect The effect to update
  9994. * @param lightIndex The index of the light in the effect to update
  9995. * @returns The light
  9996. */
  9997. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9998. /**
  9999. * Sets the passed Effect "effect" with the Light information.
  10000. * @param effect The effect to update
  10001. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10002. * @returns The light
  10003. */
  10004. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10005. /**
  10006. * Returns the string "Light".
  10007. * @returns the class name
  10008. */
  10009. getClassName(): string;
  10010. /** @hidden */
  10011. readonly _isLight: boolean;
  10012. /**
  10013. * Converts the light information to a readable string for debug purpose.
  10014. * @param fullDetails Supports for multiple levels of logging within scene loading
  10015. * @returns the human readable light info
  10016. */
  10017. toString(fullDetails?: boolean): string;
  10018. /** @hidden */
  10019. protected _syncParentEnabledState(): void;
  10020. /**
  10021. * Set the enabled state of this node.
  10022. * @param value - the new enabled state
  10023. */
  10024. setEnabled(value: boolean): void;
  10025. /**
  10026. * Returns the Light associated shadow generator if any.
  10027. * @return the associated shadow generator.
  10028. */
  10029. getShadowGenerator(): Nullable<IShadowGenerator>;
  10030. /**
  10031. * Returns a Vector3, the absolute light position in the World.
  10032. * @returns the world space position of the light
  10033. */
  10034. getAbsolutePosition(): Vector3;
  10035. /**
  10036. * Specifies if the light will affect the passed mesh.
  10037. * @param mesh The mesh to test against the light
  10038. * @return true the mesh is affected otherwise, false.
  10039. */
  10040. canAffectMesh(mesh: AbstractMesh): boolean;
  10041. /**
  10042. * Sort function to order lights for rendering.
  10043. * @param a First Light object to compare to second.
  10044. * @param b Second Light object to compare first.
  10045. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10046. */
  10047. static CompareLightsPriority(a: Light, b: Light): number;
  10048. /**
  10049. * Releases resources associated with this node.
  10050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10052. */
  10053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10054. /**
  10055. * Returns the light type ID (integer).
  10056. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10057. */
  10058. getTypeID(): number;
  10059. /**
  10060. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10061. * @returns the scaled intensity in intensity mode unit
  10062. */
  10063. getScaledIntensity(): number;
  10064. /**
  10065. * Returns a new Light object, named "name", from the current one.
  10066. * @param name The name of the cloned light
  10067. * @returns the new created light
  10068. */
  10069. clone(name: string): Nullable<Light>;
  10070. /**
  10071. * Serializes the current light into a Serialization object.
  10072. * @returns the serialized object.
  10073. */
  10074. serialize(): any;
  10075. /**
  10076. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10077. * This new light is named "name" and added to the passed scene.
  10078. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10079. * @param name The friendly name of the light
  10080. * @param scene The scene the new light will belong to
  10081. * @returns the constructor function
  10082. */
  10083. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10084. /**
  10085. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10086. * @param parsedLight The JSON representation of the light
  10087. * @param scene The scene to create the parsed light in
  10088. * @returns the created light after parsing
  10089. */
  10090. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10091. private _hookArrayForExcluded;
  10092. private _hookArrayForIncludedOnly;
  10093. private _resyncMeshes;
  10094. /**
  10095. * Forces the meshes to update their light related information in their rendering used effects
  10096. * @hidden Internal Use Only
  10097. */
  10098. _markMeshesAsLightDirty(): void;
  10099. /**
  10100. * Recomputes the cached photometric scale if needed.
  10101. */
  10102. private _computePhotometricScale;
  10103. /**
  10104. * Returns the Photometric Scale according to the light type and intensity mode.
  10105. */
  10106. private _getPhotometricScale;
  10107. /**
  10108. * Reorder the light in the scene according to their defined priority.
  10109. * @hidden Internal Use Only
  10110. */
  10111. _reorderLightsInScene(): void;
  10112. /**
  10113. * Prepares the list of defines specific to the light type.
  10114. * @param defines the list of defines
  10115. * @param lightIndex defines the index of the light for the effect
  10116. */
  10117. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10118. }
  10119. }
  10120. declare module "babylonjs/Actions/action" {
  10121. import { Observable } from "babylonjs/Misc/observable";
  10122. import { Condition } from "babylonjs/Actions/condition";
  10123. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10124. import { ActionManager } from "babylonjs/Actions/actionManager";
  10125. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10126. /**
  10127. * Interface used to define Action
  10128. */
  10129. export interface IAction {
  10130. /**
  10131. * Trigger for the action
  10132. */
  10133. trigger: number;
  10134. /** Options of the trigger */
  10135. triggerOptions: any;
  10136. /**
  10137. * Gets the trigger parameters
  10138. * @returns the trigger parameters
  10139. */
  10140. getTriggerParameter(): any;
  10141. /**
  10142. * Internal only - executes current action event
  10143. * @hidden
  10144. */
  10145. _executeCurrent(evt?: ActionEvent): void;
  10146. /**
  10147. * Serialize placeholder for child classes
  10148. * @param parent of child
  10149. * @returns the serialized object
  10150. */
  10151. serialize(parent: any): any;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */
  10156. _prepare(): void;
  10157. /**
  10158. * Internal only - manager for action
  10159. * @hidden
  10160. */
  10161. _actionManager: AbstractActionManager;
  10162. /**
  10163. * Adds action to chain of actions, may be a DoNothingAction
  10164. * @param action defines the next action to execute
  10165. * @returns The action passed in
  10166. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10167. */
  10168. then(action: IAction): IAction;
  10169. }
  10170. /**
  10171. * The action to be carried out following a trigger
  10172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10173. */
  10174. export class Action implements IAction {
  10175. /** the trigger, with or without parameters, for the action */
  10176. triggerOptions: any;
  10177. /**
  10178. * Trigger for the action
  10179. */
  10180. trigger: number;
  10181. /**
  10182. * Internal only - manager for action
  10183. * @hidden
  10184. */
  10185. _actionManager: ActionManager;
  10186. private _nextActiveAction;
  10187. private _child;
  10188. private _condition?;
  10189. private _triggerParameter;
  10190. /**
  10191. * An event triggered prior to action being executed.
  10192. */
  10193. onBeforeExecuteObservable: Observable<Action>;
  10194. /**
  10195. * Creates a new Action
  10196. * @param triggerOptions the trigger, with or without parameters, for the action
  10197. * @param condition an optional determinant of action
  10198. */
  10199. constructor(
  10200. /** the trigger, with or without parameters, for the action */
  10201. triggerOptions: any, condition?: Condition);
  10202. /**
  10203. * Internal only
  10204. * @hidden
  10205. */
  10206. _prepare(): void;
  10207. /**
  10208. * Gets the trigger parameters
  10209. * @returns the trigger parameters
  10210. */
  10211. getTriggerParameter(): any;
  10212. /**
  10213. * Internal only - executes current action event
  10214. * @hidden
  10215. */
  10216. _executeCurrent(evt?: ActionEvent): void;
  10217. /**
  10218. * Execute placeholder for child classes
  10219. * @param evt optional action event
  10220. */
  10221. execute(evt?: ActionEvent): void;
  10222. /**
  10223. * Skips to next active action
  10224. */
  10225. skipToNextActiveAction(): void;
  10226. /**
  10227. * Adds action to chain of actions, may be a DoNothingAction
  10228. * @param action defines the next action to execute
  10229. * @returns The action passed in
  10230. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10231. */
  10232. then(action: Action): Action;
  10233. /**
  10234. * Internal only
  10235. * @hidden
  10236. */
  10237. _getProperty(propertyPath: string): string;
  10238. /**
  10239. * Internal only
  10240. * @hidden
  10241. */
  10242. _getEffectiveTarget(target: any, propertyPath: string): any;
  10243. /**
  10244. * Serialize placeholder for child classes
  10245. * @param parent of child
  10246. * @returns the serialized object
  10247. */
  10248. serialize(parent: any): any;
  10249. /**
  10250. * Internal only called by serialize
  10251. * @hidden
  10252. */
  10253. protected _serialize(serializedAction: any, parent?: any): any;
  10254. /**
  10255. * Internal only
  10256. * @hidden
  10257. */
  10258. static _SerializeValueAsString: (value: any) => string;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10264. name: string;
  10265. targetType: string;
  10266. value: string;
  10267. };
  10268. }
  10269. }
  10270. declare module "babylonjs/Actions/condition" {
  10271. import { ActionManager } from "babylonjs/Actions/actionManager";
  10272. /**
  10273. * A Condition applied to an Action
  10274. */
  10275. export class Condition {
  10276. /**
  10277. * Internal only - manager for action
  10278. * @hidden
  10279. */
  10280. _actionManager: ActionManager;
  10281. /**
  10282. * Internal only
  10283. * @hidden
  10284. */
  10285. _evaluationId: number;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. _currentResult: boolean;
  10291. /**
  10292. * Creates a new Condition
  10293. * @param actionManager the manager of the action the condition is applied to
  10294. */
  10295. constructor(actionManager: ActionManager);
  10296. /**
  10297. * Check if the current condition is valid
  10298. * @returns a boolean
  10299. */
  10300. isValid(): boolean;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. _getProperty(propertyPath: string): string;
  10306. /**
  10307. * Internal only
  10308. * @hidden
  10309. */
  10310. _getEffectiveTarget(target: any, propertyPath: string): any;
  10311. /**
  10312. * Serialize placeholder for child classes
  10313. * @returns the serialized object
  10314. */
  10315. serialize(): any;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. protected _serialize(serializedCondition: any): any;
  10321. }
  10322. /**
  10323. * Defines specific conditional operators as extensions of Condition
  10324. */
  10325. export class ValueCondition extends Condition {
  10326. /** path to specify the property of the target the conditional operator uses */
  10327. propertyPath: string;
  10328. /** the value compared by the conditional operator against the current value of the property */
  10329. value: any;
  10330. /** the conditional operator, default ValueCondition.IsEqual */
  10331. operator: number;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. private static _IsEqual;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. private static _IsDifferent;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. private static _IsGreater;
  10347. /**
  10348. * Internal only
  10349. * @hidden
  10350. */
  10351. private static _IsLesser;
  10352. /**
  10353. * returns the number for IsEqual
  10354. */
  10355. static readonly IsEqual: number;
  10356. /**
  10357. * Returns the number for IsDifferent
  10358. */
  10359. static readonly IsDifferent: number;
  10360. /**
  10361. * Returns the number for IsGreater
  10362. */
  10363. static readonly IsGreater: number;
  10364. /**
  10365. * Returns the number for IsLesser
  10366. */
  10367. static readonly IsLesser: number;
  10368. /**
  10369. * Internal only The action manager for the condition
  10370. * @hidden
  10371. */
  10372. _actionManager: ActionManager;
  10373. /**
  10374. * Internal only
  10375. * @hidden
  10376. */
  10377. private _target;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. private _effectiveTarget;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private _property;
  10388. /**
  10389. * Creates a new ValueCondition
  10390. * @param actionManager manager for the action the condition applies to
  10391. * @param target for the action
  10392. * @param propertyPath path to specify the property of the target the conditional operator uses
  10393. * @param value the value compared by the conditional operator against the current value of the property
  10394. * @param operator the conditional operator, default ValueCondition.IsEqual
  10395. */
  10396. constructor(actionManager: ActionManager, target: any,
  10397. /** path to specify the property of the target the conditional operator uses */
  10398. propertyPath: string,
  10399. /** the value compared by the conditional operator against the current value of the property */
  10400. value: any,
  10401. /** the conditional operator, default ValueCondition.IsEqual */
  10402. operator?: number);
  10403. /**
  10404. * Compares the given value with the property value for the specified conditional operator
  10405. * @returns the result of the comparison
  10406. */
  10407. isValid(): boolean;
  10408. /**
  10409. * Serialize the ValueCondition into a JSON compatible object
  10410. * @returns serialization object
  10411. */
  10412. serialize(): any;
  10413. /**
  10414. * Gets the name of the conditional operator for the ValueCondition
  10415. * @param operator the conditional operator
  10416. * @returns the name
  10417. */
  10418. static GetOperatorName(operator: number): string;
  10419. }
  10420. /**
  10421. * Defines a predicate condition as an extension of Condition
  10422. */
  10423. export class PredicateCondition extends Condition {
  10424. /** defines the predicate function used to validate the condition */
  10425. predicate: () => boolean;
  10426. /**
  10427. * Internal only - manager for action
  10428. * @hidden
  10429. */
  10430. _actionManager: ActionManager;
  10431. /**
  10432. * Creates a new PredicateCondition
  10433. * @param actionManager manager for the action the condition applies to
  10434. * @param predicate defines the predicate function used to validate the condition
  10435. */
  10436. constructor(actionManager: ActionManager,
  10437. /** defines the predicate function used to validate the condition */
  10438. predicate: () => boolean);
  10439. /**
  10440. * @returns the validity of the predicate condition
  10441. */
  10442. isValid(): boolean;
  10443. }
  10444. /**
  10445. * Defines a state condition as an extension of Condition
  10446. */
  10447. export class StateCondition extends Condition {
  10448. /** Value to compare with target state */
  10449. value: string;
  10450. /**
  10451. * Internal only - manager for action
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private _target;
  10460. /**
  10461. * Creates a new StateCondition
  10462. * @param actionManager manager for the action the condition applies to
  10463. * @param target of the condition
  10464. * @param value to compare with target state
  10465. */
  10466. constructor(actionManager: ActionManager, target: any,
  10467. /** Value to compare with target state */
  10468. value: string);
  10469. /**
  10470. * Gets a boolean indicating if the current condition is met
  10471. * @returns the validity of the state
  10472. */
  10473. isValid(): boolean;
  10474. /**
  10475. * Serialize the StateCondition into a JSON compatible object
  10476. * @returns serialization object
  10477. */
  10478. serialize(): any;
  10479. }
  10480. }
  10481. declare module "babylonjs/Actions/directActions" {
  10482. import { Action } from "babylonjs/Actions/action";
  10483. import { Condition } from "babylonjs/Actions/condition";
  10484. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10485. /**
  10486. * This defines an action responsible to toggle a boolean once triggered.
  10487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10488. */
  10489. export class SwitchBooleanAction extends Action {
  10490. /**
  10491. * The path to the boolean property in the target object
  10492. */
  10493. propertyPath: string;
  10494. private _target;
  10495. private _effectiveTarget;
  10496. private _property;
  10497. /**
  10498. * Instantiate the action
  10499. * @param triggerOptions defines the trigger options
  10500. * @param target defines the object containing the boolean
  10501. * @param propertyPath defines the path to the boolean property in the target object
  10502. * @param condition defines the trigger related conditions
  10503. */
  10504. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10505. /** @hidden */
  10506. _prepare(): void;
  10507. /**
  10508. * Execute the action toggle the boolean value.
  10509. */
  10510. execute(): void;
  10511. /**
  10512. * Serializes the actions and its related information.
  10513. * @param parent defines the object to serialize in
  10514. * @returns the serialized object
  10515. */
  10516. serialize(parent: any): any;
  10517. }
  10518. /**
  10519. * This defines an action responsible to set a the state field of the target
  10520. * to a desired value once triggered.
  10521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10522. */
  10523. export class SetStateAction extends Action {
  10524. /**
  10525. * The value to store in the state field.
  10526. */
  10527. value: string;
  10528. private _target;
  10529. /**
  10530. * Instantiate the action
  10531. * @param triggerOptions defines the trigger options
  10532. * @param target defines the object containing the state property
  10533. * @param value defines the value to store in the state field
  10534. * @param condition defines the trigger related conditions
  10535. */
  10536. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10537. /**
  10538. * Execute the action and store the value on the target state property.
  10539. */
  10540. execute(): void;
  10541. /**
  10542. * Serializes the actions and its related information.
  10543. * @param parent defines the object to serialize in
  10544. * @returns the serialized object
  10545. */
  10546. serialize(parent: any): any;
  10547. }
  10548. /**
  10549. * This defines an action responsible to set a property of the target
  10550. * to a desired value once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class SetValueAction extends Action {
  10554. /**
  10555. * The path of the property to set in the target.
  10556. */
  10557. propertyPath: string;
  10558. /**
  10559. * The value to set in the property
  10560. */
  10561. value: any;
  10562. private _target;
  10563. private _effectiveTarget;
  10564. private _property;
  10565. /**
  10566. * Instantiate the action
  10567. * @param triggerOptions defines the trigger options
  10568. * @param target defines the object containing the property
  10569. * @param propertyPath defines the path of the property to set in the target
  10570. * @param value defines the value to set in the property
  10571. * @param condition defines the trigger related conditions
  10572. */
  10573. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10574. /** @hidden */
  10575. _prepare(): void;
  10576. /**
  10577. * Execute the action and set the targetted property to the desired value.
  10578. */
  10579. execute(): void;
  10580. /**
  10581. * Serializes the actions and its related information.
  10582. * @param parent defines the object to serialize in
  10583. * @returns the serialized object
  10584. */
  10585. serialize(parent: any): any;
  10586. }
  10587. /**
  10588. * This defines an action responsible to increment the target value
  10589. * to a desired value once triggered.
  10590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10591. */
  10592. export class IncrementValueAction extends Action {
  10593. /**
  10594. * The path of the property to increment in the target.
  10595. */
  10596. propertyPath: string;
  10597. /**
  10598. * The value we should increment the property by.
  10599. */
  10600. value: any;
  10601. private _target;
  10602. private _effectiveTarget;
  10603. private _property;
  10604. /**
  10605. * Instantiate the action
  10606. * @param triggerOptions defines the trigger options
  10607. * @param target defines the object containing the property
  10608. * @param propertyPath defines the path of the property to increment in the target
  10609. * @param value defines the value value we should increment the property by
  10610. * @param condition defines the trigger related conditions
  10611. */
  10612. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10613. /** @hidden */
  10614. _prepare(): void;
  10615. /**
  10616. * Execute the action and increment the target of the value amount.
  10617. */
  10618. execute(): void;
  10619. /**
  10620. * Serializes the actions and its related information.
  10621. * @param parent defines the object to serialize in
  10622. * @returns the serialized object
  10623. */
  10624. serialize(parent: any): any;
  10625. }
  10626. /**
  10627. * This defines an action responsible to start an animation once triggered.
  10628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10629. */
  10630. export class PlayAnimationAction extends Action {
  10631. /**
  10632. * Where the animation should start (animation frame)
  10633. */
  10634. from: number;
  10635. /**
  10636. * Where the animation should stop (animation frame)
  10637. */
  10638. to: number;
  10639. /**
  10640. * Define if the animation should loop or stop after the first play.
  10641. */
  10642. loop?: boolean;
  10643. private _target;
  10644. /**
  10645. * Instantiate the action
  10646. * @param triggerOptions defines the trigger options
  10647. * @param target defines the target animation or animation name
  10648. * @param from defines from where the animation should start (animation frame)
  10649. * @param end defines where the animation should stop (animation frame)
  10650. * @param loop defines if the animation should loop or stop after the first play
  10651. * @param condition defines the trigger related conditions
  10652. */
  10653. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10654. /** @hidden */
  10655. _prepare(): void;
  10656. /**
  10657. * Execute the action and play the animation.
  10658. */
  10659. execute(): void;
  10660. /**
  10661. * Serializes the actions and its related information.
  10662. * @param parent defines the object to serialize in
  10663. * @returns the serialized object
  10664. */
  10665. serialize(parent: any): any;
  10666. }
  10667. /**
  10668. * This defines an action responsible to stop an animation once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class StopAnimationAction extends Action {
  10672. private _target;
  10673. /**
  10674. * Instantiate the action
  10675. * @param triggerOptions defines the trigger options
  10676. * @param target defines the target animation or animation name
  10677. * @param condition defines the trigger related conditions
  10678. */
  10679. constructor(triggerOptions: any, target: any, condition?: Condition);
  10680. /** @hidden */
  10681. _prepare(): void;
  10682. /**
  10683. * Execute the action and stop the animation.
  10684. */
  10685. execute(): void;
  10686. /**
  10687. * Serializes the actions and its related information.
  10688. * @param parent defines the object to serialize in
  10689. * @returns the serialized object
  10690. */
  10691. serialize(parent: any): any;
  10692. }
  10693. /**
  10694. * This defines an action responsible that does nothing once triggered.
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10696. */
  10697. export class DoNothingAction extends Action {
  10698. /**
  10699. * Instantiate the action
  10700. * @param triggerOptions defines the trigger options
  10701. * @param condition defines the trigger related conditions
  10702. */
  10703. constructor(triggerOptions?: any, condition?: Condition);
  10704. /**
  10705. * Execute the action and do nothing.
  10706. */
  10707. execute(): void;
  10708. /**
  10709. * Serializes the actions and its related information.
  10710. * @param parent defines the object to serialize in
  10711. * @returns the serialized object
  10712. */
  10713. serialize(parent: any): any;
  10714. }
  10715. /**
  10716. * This defines an action responsible to trigger several actions once triggered.
  10717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10718. */
  10719. export class CombineAction extends Action {
  10720. /**
  10721. * The list of aggregated animations to run.
  10722. */
  10723. children: Action[];
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param children defines the list of aggregated animations to run
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and executes all the aggregated actions.
  10735. */
  10736. execute(evt: ActionEvent): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to run code (external event) once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class ExecuteCodeAction extends Action {
  10749. /**
  10750. * The callback function to run.
  10751. */
  10752. func: (evt: ActionEvent) => void;
  10753. /**
  10754. * Instantiate the action
  10755. * @param triggerOptions defines the trigger options
  10756. * @param func defines the callback function to run
  10757. * @param condition defines the trigger related conditions
  10758. */
  10759. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10760. /**
  10761. * Execute the action and run the attached code.
  10762. */
  10763. execute(evt: ActionEvent): void;
  10764. }
  10765. /**
  10766. * This defines an action responsible to set the parent property of the target once triggered.
  10767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10768. */
  10769. export class SetParentAction extends Action {
  10770. private _parent;
  10771. private _target;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the target containing the parent property
  10776. * @param parent defines from where the animation should start (animation frame)
  10777. * @param condition defines the trigger related conditions
  10778. */
  10779. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10780. /** @hidden */
  10781. _prepare(): void;
  10782. /**
  10783. * Execute the action and set the parent property.
  10784. */
  10785. execute(): void;
  10786. /**
  10787. * Serializes the actions and its related information.
  10788. * @param parent defines the object to serialize in
  10789. * @returns the serialized object
  10790. */
  10791. serialize(parent: any): any;
  10792. }
  10793. }
  10794. declare module "babylonjs/Actions/actionManager" {
  10795. import { Nullable } from "babylonjs/types";
  10796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10797. import { Scene } from "babylonjs/scene";
  10798. import { IAction } from "babylonjs/Actions/action";
  10799. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10800. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10801. /**
  10802. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10803. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class ActionManager extends AbstractActionManager {
  10807. /**
  10808. * Nothing
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10810. */
  10811. static readonly NothingTrigger: number;
  10812. /**
  10813. * On pick
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly OnPickTrigger: number;
  10817. /**
  10818. * On left pick
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10820. */
  10821. static readonly OnLeftPickTrigger: number;
  10822. /**
  10823. * On right pick
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10825. */
  10826. static readonly OnRightPickTrigger: number;
  10827. /**
  10828. * On center pick
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10830. */
  10831. static readonly OnCenterPickTrigger: number;
  10832. /**
  10833. * On pick down
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnPickDownTrigger: number;
  10837. /**
  10838. * On double pick
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnDoublePickTrigger: number;
  10842. /**
  10843. * On pick up
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnPickUpTrigger: number;
  10847. /**
  10848. * On pick out.
  10849. * This trigger will only be raised if you also declared a OnPickDown
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10851. */
  10852. static readonly OnPickOutTrigger: number;
  10853. /**
  10854. * On long press
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnLongPressTrigger: number;
  10858. /**
  10859. * On pointer over
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnPointerOverTrigger: number;
  10863. /**
  10864. * On pointer out
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPointerOutTrigger: number;
  10868. /**
  10869. * On every frame
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnEveryFrameTrigger: number;
  10873. /**
  10874. * On intersection enter
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnIntersectionEnterTrigger: number;
  10878. /**
  10879. * On intersection exit
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnIntersectionExitTrigger: number;
  10883. /**
  10884. * On key down
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnKeyDownTrigger: number;
  10888. /**
  10889. * On key up
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnKeyUpTrigger: number;
  10893. private _scene;
  10894. /**
  10895. * Creates a new action manager
  10896. * @param scene defines the hosting scene
  10897. */
  10898. constructor(scene: Scene);
  10899. /**
  10900. * Releases all associated resources
  10901. */
  10902. dispose(): void;
  10903. /**
  10904. * Gets hosting scene
  10905. * @returns the hosting scene
  10906. */
  10907. getScene(): Scene;
  10908. /**
  10909. * Does this action manager handles actions of any of the given triggers
  10910. * @param triggers defines the triggers to be tested
  10911. * @return a boolean indicating whether one (or more) of the triggers is handled
  10912. */
  10913. hasSpecificTriggers(triggers: number[]): boolean;
  10914. /**
  10915. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10916. * speed.
  10917. * @param triggerA defines the trigger to be tested
  10918. * @param triggerB defines the trigger to be tested
  10919. * @return a boolean indicating whether one (or more) of the triggers is handled
  10920. */
  10921. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10922. /**
  10923. * Does this action manager handles actions of a given trigger
  10924. * @param trigger defines the trigger to be tested
  10925. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10926. * @return whether the trigger is handled
  10927. */
  10928. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10929. /**
  10930. * Does this action manager has pointer triggers
  10931. */
  10932. readonly hasPointerTriggers: boolean;
  10933. /**
  10934. * Does this action manager has pick triggers
  10935. */
  10936. readonly hasPickTriggers: boolean;
  10937. /**
  10938. * Registers an action to this action manager
  10939. * @param action defines the action to be registered
  10940. * @return the action amended (prepared) after registration
  10941. */
  10942. registerAction(action: IAction): Nullable<IAction>;
  10943. /**
  10944. * Unregisters an action to this action manager
  10945. * @param action defines the action to be unregistered
  10946. * @return a boolean indicating whether the action has been unregistered
  10947. */
  10948. unregisterAction(action: IAction): Boolean;
  10949. /**
  10950. * Process a specific trigger
  10951. * @param trigger defines the trigger to process
  10952. * @param evt defines the event details to be processed
  10953. */
  10954. processTrigger(trigger: number, evt?: IActionEvent): void;
  10955. /** @hidden */
  10956. _getEffectiveTarget(target: any, propertyPath: string): any;
  10957. /** @hidden */
  10958. _getProperty(propertyPath: string): string;
  10959. /**
  10960. * Serialize this manager to a JSON object
  10961. * @param name defines the property name to store this manager
  10962. * @returns a JSON representation of this manager
  10963. */
  10964. serialize(name: string): any;
  10965. /**
  10966. * Creates a new ActionManager from a JSON data
  10967. * @param parsedActions defines the JSON data to read from
  10968. * @param object defines the hosting mesh
  10969. * @param scene defines the hosting scene
  10970. */
  10971. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10972. /**
  10973. * Get a trigger name by index
  10974. * @param trigger defines the trigger index
  10975. * @returns a trigger name
  10976. */
  10977. static GetTriggerName(trigger: number): string;
  10978. }
  10979. }
  10980. declare module "babylonjs/Culling/ray" {
  10981. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10982. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10984. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10985. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10986. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10987. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10988. import { Plane } from "babylonjs/Maths/math.plane";
  10989. /**
  10990. * Class representing a ray with position and direction
  10991. */
  10992. export class Ray {
  10993. /** origin point */
  10994. origin: Vector3;
  10995. /** direction */
  10996. direction: Vector3;
  10997. /** length of the ray */
  10998. length: number;
  10999. private static readonly TmpVector3;
  11000. private _tmpRay;
  11001. /**
  11002. * Creates a new ray
  11003. * @param origin origin point
  11004. * @param direction direction
  11005. * @param length length of the ray
  11006. */
  11007. constructor(
  11008. /** origin point */
  11009. origin: Vector3,
  11010. /** direction */
  11011. direction: Vector3,
  11012. /** length of the ray */
  11013. length?: number);
  11014. /**
  11015. * Checks if the ray intersects a box
  11016. * @param minimum bound of the box
  11017. * @param maximum bound of the box
  11018. * @param intersectionTreshold extra extend to be added to the box in all direction
  11019. * @returns if the box was hit
  11020. */
  11021. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11022. /**
  11023. * Checks if the ray intersects a box
  11024. * @param box the bounding box to check
  11025. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11026. * @returns if the box was hit
  11027. */
  11028. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11029. /**
  11030. * If the ray hits a sphere
  11031. * @param sphere the bounding sphere to check
  11032. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11033. * @returns true if it hits the sphere
  11034. */
  11035. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11036. /**
  11037. * If the ray hits a triange
  11038. * @param vertex0 triangle vertex
  11039. * @param vertex1 triangle vertex
  11040. * @param vertex2 triangle vertex
  11041. * @returns intersection information if hit
  11042. */
  11043. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11044. /**
  11045. * Checks if ray intersects a plane
  11046. * @param plane the plane to check
  11047. * @returns the distance away it was hit
  11048. */
  11049. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11050. /**
  11051. * Calculate the intercept of a ray on a given axis
  11052. * @param axis to check 'x' | 'y' | 'z'
  11053. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11054. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11055. */
  11056. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11057. /**
  11058. * Checks if ray intersects a mesh
  11059. * @param mesh the mesh to check
  11060. * @param fastCheck if only the bounding box should checked
  11061. * @returns picking info of the intersecton
  11062. */
  11063. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11064. /**
  11065. * Checks if ray intersects a mesh
  11066. * @param meshes the meshes to check
  11067. * @param fastCheck if only the bounding box should checked
  11068. * @param results array to store result in
  11069. * @returns Array of picking infos
  11070. */
  11071. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11072. private _comparePickingInfo;
  11073. private static smallnum;
  11074. private static rayl;
  11075. /**
  11076. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11077. * @param sega the first point of the segment to test the intersection against
  11078. * @param segb the second point of the segment to test the intersection against
  11079. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11080. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11081. */
  11082. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11083. /**
  11084. * Update the ray from viewport position
  11085. * @param x position
  11086. * @param y y position
  11087. * @param viewportWidth viewport width
  11088. * @param viewportHeight viewport height
  11089. * @param world world matrix
  11090. * @param view view matrix
  11091. * @param projection projection matrix
  11092. * @returns this ray updated
  11093. */
  11094. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11095. /**
  11096. * Creates a ray with origin and direction of 0,0,0
  11097. * @returns the new ray
  11098. */
  11099. static Zero(): Ray;
  11100. /**
  11101. * Creates a new ray from screen space and viewport
  11102. * @param x position
  11103. * @param y y position
  11104. * @param viewportWidth viewport width
  11105. * @param viewportHeight viewport height
  11106. * @param world world matrix
  11107. * @param view view matrix
  11108. * @param projection projection matrix
  11109. * @returns new ray
  11110. */
  11111. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11112. /**
  11113. * 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
  11114. * transformed to the given world matrix.
  11115. * @param origin The origin point
  11116. * @param end The end point
  11117. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11118. * @returns the new ray
  11119. */
  11120. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11121. /**
  11122. * Transforms a ray by a matrix
  11123. * @param ray ray to transform
  11124. * @param matrix matrix to apply
  11125. * @returns the resulting new ray
  11126. */
  11127. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11128. /**
  11129. * Transforms a ray by a matrix
  11130. * @param ray ray to transform
  11131. * @param matrix matrix to apply
  11132. * @param result ray to store result in
  11133. */
  11134. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11135. /**
  11136. * Unproject a ray from screen space to object space
  11137. * @param sourceX defines the screen space x coordinate to use
  11138. * @param sourceY defines the screen space y coordinate to use
  11139. * @param viewportWidth defines the current width of the viewport
  11140. * @param viewportHeight defines the current height of the viewport
  11141. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11142. * @param view defines the view matrix to use
  11143. * @param projection defines the projection matrix to use
  11144. */
  11145. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11146. }
  11147. /**
  11148. * Type used to define predicate used to select faces when a mesh intersection is detected
  11149. */
  11150. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11151. module "babylonjs/scene" {
  11152. interface Scene {
  11153. /** @hidden */
  11154. _tempPickingRay: Nullable<Ray>;
  11155. /** @hidden */
  11156. _cachedRayForTransform: Ray;
  11157. /** @hidden */
  11158. _pickWithRayInverseMatrix: Matrix;
  11159. /** @hidden */
  11160. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11161. /** @hidden */
  11162. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11163. }
  11164. }
  11165. }
  11166. declare module "babylonjs/sceneComponent" {
  11167. import { Scene } from "babylonjs/scene";
  11168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11169. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11170. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11171. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11172. import { Nullable } from "babylonjs/types";
  11173. import { Camera } from "babylonjs/Cameras/camera";
  11174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11175. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11176. import { AbstractScene } from "babylonjs/abstractScene";
  11177. /**
  11178. * Groups all the scene component constants in one place to ease maintenance.
  11179. * @hidden
  11180. */
  11181. export class SceneComponentConstants {
  11182. static readonly NAME_EFFECTLAYER: string;
  11183. static readonly NAME_LAYER: string;
  11184. static readonly NAME_LENSFLARESYSTEM: string;
  11185. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11186. static readonly NAME_PARTICLESYSTEM: string;
  11187. static readonly NAME_GAMEPAD: string;
  11188. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11189. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11190. static readonly NAME_DEPTHRENDERER: string;
  11191. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11192. static readonly NAME_SPRITE: string;
  11193. static readonly NAME_OUTLINERENDERER: string;
  11194. static readonly NAME_PROCEDURALTEXTURE: string;
  11195. static readonly NAME_SHADOWGENERATOR: string;
  11196. static readonly NAME_OCTREE: string;
  11197. static readonly NAME_PHYSICSENGINE: string;
  11198. static readonly NAME_AUDIO: string;
  11199. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11200. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11201. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11202. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11203. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11204. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11205. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11206. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11207. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11208. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11209. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11210. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11211. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11212. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11213. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11214. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11215. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11216. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11217. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11218. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11219. static readonly STEP_AFTERRENDER_AUDIO: number;
  11220. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11221. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11222. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11223. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11224. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11225. static readonly STEP_POINTERMOVE_SPRITE: number;
  11226. static readonly STEP_POINTERDOWN_SPRITE: number;
  11227. static readonly STEP_POINTERUP_SPRITE: number;
  11228. }
  11229. /**
  11230. * This represents a scene component.
  11231. *
  11232. * This is used to decouple the dependency the scene is having on the different workloads like
  11233. * layers, post processes...
  11234. */
  11235. export interface ISceneComponent {
  11236. /**
  11237. * The name of the component. Each component must have a unique name.
  11238. */
  11239. name: string;
  11240. /**
  11241. * The scene the component belongs to.
  11242. */
  11243. scene: Scene;
  11244. /**
  11245. * Register the component to one instance of a scene.
  11246. */
  11247. register(): void;
  11248. /**
  11249. * Rebuilds the elements related to this component in case of
  11250. * context lost for instance.
  11251. */
  11252. rebuild(): void;
  11253. /**
  11254. * Disposes the component and the associated ressources.
  11255. */
  11256. dispose(): void;
  11257. }
  11258. /**
  11259. * This represents a SERIALIZABLE scene component.
  11260. *
  11261. * This extends Scene Component to add Serialization methods on top.
  11262. */
  11263. export interface ISceneSerializableComponent extends ISceneComponent {
  11264. /**
  11265. * Adds all the elements from the container to the scene
  11266. * @param container the container holding the elements
  11267. */
  11268. addFromContainer(container: AbstractScene): void;
  11269. /**
  11270. * Removes all the elements in the container from the scene
  11271. * @param container contains the elements to remove
  11272. * @param dispose if the removed element should be disposed (default: false)
  11273. */
  11274. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11275. /**
  11276. * Serializes the component data to the specified json object
  11277. * @param serializationObject The object to serialize to
  11278. */
  11279. serialize(serializationObject: any): void;
  11280. }
  11281. /**
  11282. * Strong typing of a Mesh related stage step action
  11283. */
  11284. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11285. /**
  11286. * Strong typing of a Evaluate Sub Mesh related stage step action
  11287. */
  11288. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11289. /**
  11290. * Strong typing of a Active Mesh related stage step action
  11291. */
  11292. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11293. /**
  11294. * Strong typing of a Camera related stage step action
  11295. */
  11296. export type CameraStageAction = (camera: Camera) => void;
  11297. /**
  11298. * Strong typing of a Camera Frame buffer related stage step action
  11299. */
  11300. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11301. /**
  11302. * Strong typing of a Render Target related stage step action
  11303. */
  11304. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11305. /**
  11306. * Strong typing of a RenderingGroup related stage step action
  11307. */
  11308. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11309. /**
  11310. * Strong typing of a Mesh Render related stage step action
  11311. */
  11312. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11313. /**
  11314. * Strong typing of a simple stage step action
  11315. */
  11316. export type SimpleStageAction = () => void;
  11317. /**
  11318. * Strong typing of a render target action.
  11319. */
  11320. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11321. /**
  11322. * Strong typing of a pointer move action.
  11323. */
  11324. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11325. /**
  11326. * Strong typing of a pointer up/down action.
  11327. */
  11328. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11329. /**
  11330. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11331. * @hidden
  11332. */
  11333. export class Stage<T extends Function> extends Array<{
  11334. index: number;
  11335. component: ISceneComponent;
  11336. action: T;
  11337. }> {
  11338. /**
  11339. * Hide ctor from the rest of the world.
  11340. * @param items The items to add.
  11341. */
  11342. private constructor();
  11343. /**
  11344. * Creates a new Stage.
  11345. * @returns A new instance of a Stage
  11346. */
  11347. static Create<T extends Function>(): Stage<T>;
  11348. /**
  11349. * Registers a step in an ordered way in the targeted stage.
  11350. * @param index Defines the position to register the step in
  11351. * @param component Defines the component attached to the step
  11352. * @param action Defines the action to launch during the step
  11353. */
  11354. registerStep(index: number, component: ISceneComponent, action: T): void;
  11355. /**
  11356. * Clears all the steps from the stage.
  11357. */
  11358. clear(): void;
  11359. }
  11360. }
  11361. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11362. import { Nullable } from "babylonjs/types";
  11363. import { Observable } from "babylonjs/Misc/observable";
  11364. import { Scene } from "babylonjs/scene";
  11365. import { Sprite } from "babylonjs/Sprites/sprite";
  11366. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11367. import { Ray } from "babylonjs/Culling/ray";
  11368. import { Camera } from "babylonjs/Cameras/camera";
  11369. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11370. import { ISceneComponent } from "babylonjs/sceneComponent";
  11371. module "babylonjs/scene" {
  11372. interface Scene {
  11373. /** @hidden */
  11374. _pointerOverSprite: Nullable<Sprite>;
  11375. /** @hidden */
  11376. _pickedDownSprite: Nullable<Sprite>;
  11377. /** @hidden */
  11378. _tempSpritePickingRay: Nullable<Ray>;
  11379. /**
  11380. * All of the sprite managers added to this scene
  11381. * @see http://doc.babylonjs.com/babylon101/sprites
  11382. */
  11383. spriteManagers: Array<ISpriteManager>;
  11384. /**
  11385. * An event triggered when sprites rendering is about to start
  11386. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11387. */
  11388. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11389. /**
  11390. * An event triggered when sprites rendering is done
  11391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11392. */
  11393. onAfterSpritesRenderingObservable: Observable<Scene>;
  11394. /** @hidden */
  11395. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11396. /** Launch a ray to try to pick a sprite in the scene
  11397. * @param x position on screen
  11398. * @param y position on screen
  11399. * @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
  11400. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11401. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11402. * @returns a PickingInfo
  11403. */
  11404. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11405. /** Use the given ray to pick a sprite in the scene
  11406. * @param ray The ray (in world space) to use to pick meshes
  11407. * @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
  11408. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11409. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11410. * @returns a PickingInfo
  11411. */
  11412. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11413. /** @hidden */
  11414. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11415. /** Launch a ray to try to pick sprites in the scene
  11416. * @param x position on screen
  11417. * @param y position on screen
  11418. * @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
  11419. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11420. * @returns a PickingInfo array
  11421. */
  11422. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11423. /** Use the given ray to pick sprites in the scene
  11424. * @param ray The ray (in world space) to use to pick meshes
  11425. * @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
  11426. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11427. * @returns a PickingInfo array
  11428. */
  11429. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11430. /**
  11431. * Force the sprite under the pointer
  11432. * @param sprite defines the sprite to use
  11433. */
  11434. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11435. /**
  11436. * Gets the sprite under the pointer
  11437. * @returns a Sprite or null if no sprite is under the pointer
  11438. */
  11439. getPointerOverSprite(): Nullable<Sprite>;
  11440. }
  11441. }
  11442. /**
  11443. * Defines the sprite scene component responsible to manage sprites
  11444. * in a given scene.
  11445. */
  11446. export class SpriteSceneComponent implements ISceneComponent {
  11447. /**
  11448. * The component name helpfull to identify the component in the list of scene components.
  11449. */
  11450. readonly name: string;
  11451. /**
  11452. * The scene the component belongs to.
  11453. */
  11454. scene: Scene;
  11455. /** @hidden */
  11456. private _spritePredicate;
  11457. /**
  11458. * Creates a new instance of the component for the given scene
  11459. * @param scene Defines the scene to register the component in
  11460. */
  11461. constructor(scene: Scene);
  11462. /**
  11463. * Registers the component in a given scene
  11464. */
  11465. register(): void;
  11466. /**
  11467. * Rebuilds the elements related to this component in case of
  11468. * context lost for instance.
  11469. */
  11470. rebuild(): void;
  11471. /**
  11472. * Disposes the component and the associated ressources.
  11473. */
  11474. dispose(): void;
  11475. private _pickSpriteButKeepRay;
  11476. private _pointerMove;
  11477. private _pointerDown;
  11478. private _pointerUp;
  11479. }
  11480. }
  11481. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11482. /** @hidden */
  11483. export var fogFragmentDeclaration: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11489. /** @hidden */
  11490. export var fogFragment: {
  11491. name: string;
  11492. shader: string;
  11493. };
  11494. }
  11495. declare module "babylonjs/Shaders/sprites.fragment" {
  11496. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11497. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11498. /** @hidden */
  11499. export var spritesPixelShader: {
  11500. name: string;
  11501. shader: string;
  11502. };
  11503. }
  11504. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11505. /** @hidden */
  11506. export var fogVertexDeclaration: {
  11507. name: string;
  11508. shader: string;
  11509. };
  11510. }
  11511. declare module "babylonjs/Shaders/sprites.vertex" {
  11512. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11513. /** @hidden */
  11514. export var spritesVertexShader: {
  11515. name: string;
  11516. shader: string;
  11517. };
  11518. }
  11519. declare module "babylonjs/Sprites/spriteManager" {
  11520. import { IDisposable, Scene } from "babylonjs/scene";
  11521. import { Nullable } from "babylonjs/types";
  11522. import { Observable } from "babylonjs/Misc/observable";
  11523. import { Sprite } from "babylonjs/Sprites/sprite";
  11524. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11525. import { Camera } from "babylonjs/Cameras/camera";
  11526. import { Texture } from "babylonjs/Materials/Textures/texture";
  11527. import "babylonjs/Shaders/sprites.fragment";
  11528. import "babylonjs/Shaders/sprites.vertex";
  11529. import { Ray } from "babylonjs/Culling/ray";
  11530. /**
  11531. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11532. */
  11533. export interface ISpriteManager extends IDisposable {
  11534. /**
  11535. * Restricts the camera to viewing objects with the same layerMask.
  11536. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11537. */
  11538. layerMask: number;
  11539. /**
  11540. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11541. */
  11542. isPickable: boolean;
  11543. /**
  11544. * Specifies the rendering group id for this mesh (0 by default)
  11545. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11546. */
  11547. renderingGroupId: number;
  11548. /**
  11549. * Defines the list of sprites managed by the manager.
  11550. */
  11551. sprites: Array<Sprite>;
  11552. /**
  11553. * Tests the intersection of a sprite with a specific ray.
  11554. * @param ray The ray we are sending to test the collision
  11555. * @param camera The camera space we are sending rays in
  11556. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11557. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11558. * @returns picking info or null.
  11559. */
  11560. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11561. /**
  11562. * Intersects the sprites with a ray
  11563. * @param ray defines the ray to intersect with
  11564. * @param camera defines the current active camera
  11565. * @param predicate defines a predicate used to select candidate sprites
  11566. * @returns null if no hit or a PickingInfo array
  11567. */
  11568. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11569. /**
  11570. * Renders the list of sprites on screen.
  11571. */
  11572. render(): void;
  11573. }
  11574. /**
  11575. * Class used to manage multiple sprites on the same spritesheet
  11576. * @see http://doc.babylonjs.com/babylon101/sprites
  11577. */
  11578. export class SpriteManager implements ISpriteManager {
  11579. /** defines the manager's name */
  11580. name: string;
  11581. /** Gets the list of sprites */
  11582. sprites: Sprite[];
  11583. /** Gets or sets the rendering group id (0 by default) */
  11584. renderingGroupId: number;
  11585. /** Gets or sets camera layer mask */
  11586. layerMask: number;
  11587. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11588. fogEnabled: boolean;
  11589. /** Gets or sets a boolean indicating if the sprites are pickable */
  11590. isPickable: boolean;
  11591. /** Defines the default width of a cell in the spritesheet */
  11592. cellWidth: number;
  11593. /** Defines the default height of a cell in the spritesheet */
  11594. cellHeight: number;
  11595. /** Associative array from JSON sprite data file */
  11596. private _cellData;
  11597. /** Array of sprite names from JSON sprite data file */
  11598. private _spriteMap;
  11599. /** True when packed cell data from JSON file is ready*/
  11600. private _packedAndReady;
  11601. /**
  11602. * An event triggered when the manager is disposed.
  11603. */
  11604. onDisposeObservable: Observable<SpriteManager>;
  11605. private _onDisposeObserver;
  11606. /**
  11607. * Callback called when the manager is disposed
  11608. */
  11609. onDispose: () => void;
  11610. private _capacity;
  11611. private _fromPacked;
  11612. private _spriteTexture;
  11613. private _epsilon;
  11614. private _scene;
  11615. private _vertexData;
  11616. private _buffer;
  11617. private _vertexBuffers;
  11618. private _indexBuffer;
  11619. private _effectBase;
  11620. private _effectFog;
  11621. /**
  11622. * Gets or sets the spritesheet texture
  11623. */
  11624. texture: Texture;
  11625. /**
  11626. * Creates a new sprite manager
  11627. * @param name defines the manager's name
  11628. * @param imgUrl defines the sprite sheet url
  11629. * @param capacity defines the maximum allowed number of sprites
  11630. * @param cellSize defines the size of a sprite cell
  11631. * @param scene defines the hosting scene
  11632. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11633. * @param samplingMode defines the smapling mode to use with spritesheet
  11634. * @param fromPacked set to false; do not alter
  11635. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11636. */
  11637. constructor(
  11638. /** defines the manager's name */
  11639. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11640. private _makePacked;
  11641. private _appendSpriteVertex;
  11642. /**
  11643. * Intersects the sprites with a ray
  11644. * @param ray defines the ray to intersect with
  11645. * @param camera defines the current active camera
  11646. * @param predicate defines a predicate used to select candidate sprites
  11647. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11648. * @returns null if no hit or a PickingInfo
  11649. */
  11650. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11651. /**
  11652. * Intersects the sprites with a ray
  11653. * @param ray defines the ray to intersect with
  11654. * @param camera defines the current active camera
  11655. * @param predicate defines a predicate used to select candidate sprites
  11656. * @returns null if no hit or a PickingInfo array
  11657. */
  11658. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11659. /**
  11660. * Render all child sprites
  11661. */
  11662. render(): void;
  11663. /**
  11664. * Release associated resources
  11665. */
  11666. dispose(): void;
  11667. }
  11668. }
  11669. declare module "babylonjs/Sprites/sprite" {
  11670. import { Vector3 } from "babylonjs/Maths/math.vector";
  11671. import { Nullable } from "babylonjs/types";
  11672. import { ActionManager } from "babylonjs/Actions/actionManager";
  11673. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11674. import { Color4 } from "babylonjs/Maths/math.color";
  11675. /**
  11676. * Class used to represent a sprite
  11677. * @see http://doc.babylonjs.com/babylon101/sprites
  11678. */
  11679. export class Sprite {
  11680. /** defines the name */
  11681. name: string;
  11682. /** Gets or sets the current world position */
  11683. position: Vector3;
  11684. /** Gets or sets the main color */
  11685. color: Color4;
  11686. /** Gets or sets the width */
  11687. width: number;
  11688. /** Gets or sets the height */
  11689. height: number;
  11690. /** Gets or sets rotation angle */
  11691. angle: number;
  11692. /** Gets or sets the cell index in the sprite sheet */
  11693. cellIndex: number;
  11694. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11695. cellRef: string;
  11696. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11697. invertU: number;
  11698. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11699. invertV: number;
  11700. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11701. disposeWhenFinishedAnimating: boolean;
  11702. /** Gets the list of attached animations */
  11703. animations: Animation[];
  11704. /** Gets or sets a boolean indicating if the sprite can be picked */
  11705. isPickable: boolean;
  11706. /**
  11707. * Gets or sets the associated action manager
  11708. */
  11709. actionManager: Nullable<ActionManager>;
  11710. private _animationStarted;
  11711. private _loopAnimation;
  11712. private _fromIndex;
  11713. private _toIndex;
  11714. private _delay;
  11715. private _direction;
  11716. private _manager;
  11717. private _time;
  11718. private _onAnimationEnd;
  11719. /**
  11720. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11721. */
  11722. isVisible: boolean;
  11723. /**
  11724. * Gets or sets the sprite size
  11725. */
  11726. size: number;
  11727. /**
  11728. * Creates a new Sprite
  11729. * @param name defines the name
  11730. * @param manager defines the manager
  11731. */
  11732. constructor(
  11733. /** defines the name */
  11734. name: string, manager: ISpriteManager);
  11735. /**
  11736. * Starts an animation
  11737. * @param from defines the initial key
  11738. * @param to defines the end key
  11739. * @param loop defines if the animation must loop
  11740. * @param delay defines the start delay (in ms)
  11741. * @param onAnimationEnd defines a callback to call when animation ends
  11742. */
  11743. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11744. /** Stops current animation (if any) */
  11745. stopAnimation(): void;
  11746. /** @hidden */
  11747. _animate(deltaTime: number): void;
  11748. /** Release associated resources */
  11749. dispose(): void;
  11750. }
  11751. }
  11752. declare module "babylonjs/Collisions/pickingInfo" {
  11753. import { Nullable } from "babylonjs/types";
  11754. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11756. import { Sprite } from "babylonjs/Sprites/sprite";
  11757. import { Ray } from "babylonjs/Culling/ray";
  11758. /**
  11759. * Information about the result of picking within a scene
  11760. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11761. */
  11762. export class PickingInfo {
  11763. /** @hidden */
  11764. _pickingUnavailable: boolean;
  11765. /**
  11766. * If the pick collided with an object
  11767. */
  11768. hit: boolean;
  11769. /**
  11770. * Distance away where the pick collided
  11771. */
  11772. distance: number;
  11773. /**
  11774. * The location of pick collision
  11775. */
  11776. pickedPoint: Nullable<Vector3>;
  11777. /**
  11778. * The mesh corresponding the the pick collision
  11779. */
  11780. pickedMesh: Nullable<AbstractMesh>;
  11781. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11782. bu: number;
  11783. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11784. bv: number;
  11785. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11786. faceId: number;
  11787. /** Id of the the submesh that was picked */
  11788. subMeshId: number;
  11789. /** If a sprite was picked, this will be the sprite the pick collided with */
  11790. pickedSprite: Nullable<Sprite>;
  11791. /**
  11792. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11793. */
  11794. originMesh: Nullable<AbstractMesh>;
  11795. /**
  11796. * The ray that was used to perform the picking.
  11797. */
  11798. ray: Nullable<Ray>;
  11799. /**
  11800. * Gets the normal correspodning to the face the pick collided with
  11801. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11802. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11803. * @returns The normal correspodning to the face the pick collided with
  11804. */
  11805. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11806. /**
  11807. * Gets the texture coordinates of where the pick occured
  11808. * @returns the vector containing the coordnates of the texture
  11809. */
  11810. getTextureCoordinates(): Nullable<Vector2>;
  11811. }
  11812. }
  11813. declare module "babylonjs/Events/pointerEvents" {
  11814. import { Nullable } from "babylonjs/types";
  11815. import { Vector2 } from "babylonjs/Maths/math.vector";
  11816. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11817. import { Ray } from "babylonjs/Culling/ray";
  11818. /**
  11819. * Gather the list of pointer event types as constants.
  11820. */
  11821. export class PointerEventTypes {
  11822. /**
  11823. * 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.
  11824. */
  11825. static readonly POINTERDOWN: number;
  11826. /**
  11827. * The pointerup event is fired when a pointer is no longer active.
  11828. */
  11829. static readonly POINTERUP: number;
  11830. /**
  11831. * The pointermove event is fired when a pointer changes coordinates.
  11832. */
  11833. static readonly POINTERMOVE: number;
  11834. /**
  11835. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11836. */
  11837. static readonly POINTERWHEEL: number;
  11838. /**
  11839. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11840. */
  11841. static readonly POINTERPICK: number;
  11842. /**
  11843. * The pointertap event is fired when a the object has been touched and released without drag.
  11844. */
  11845. static readonly POINTERTAP: number;
  11846. /**
  11847. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11848. */
  11849. static readonly POINTERDOUBLETAP: number;
  11850. }
  11851. /**
  11852. * Base class of pointer info types.
  11853. */
  11854. export class PointerInfoBase {
  11855. /**
  11856. * Defines the type of event (PointerEventTypes)
  11857. */
  11858. type: number;
  11859. /**
  11860. * Defines the related dom event
  11861. */
  11862. event: PointerEvent | MouseWheelEvent;
  11863. /**
  11864. * Instantiates the base class of pointers info.
  11865. * @param type Defines the type of event (PointerEventTypes)
  11866. * @param event Defines the related dom event
  11867. */
  11868. constructor(
  11869. /**
  11870. * Defines the type of event (PointerEventTypes)
  11871. */
  11872. type: number,
  11873. /**
  11874. * Defines the related dom event
  11875. */
  11876. event: PointerEvent | MouseWheelEvent);
  11877. }
  11878. /**
  11879. * This class is used to store pointer related info for the onPrePointerObservable event.
  11880. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11881. */
  11882. export class PointerInfoPre extends PointerInfoBase {
  11883. /**
  11884. * Ray from a pointer if availible (eg. 6dof controller)
  11885. */
  11886. ray: Nullable<Ray>;
  11887. /**
  11888. * Defines the local position of the pointer on the canvas.
  11889. */
  11890. localPosition: Vector2;
  11891. /**
  11892. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11893. */
  11894. skipOnPointerObservable: boolean;
  11895. /**
  11896. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11897. * @param type Defines the type of event (PointerEventTypes)
  11898. * @param event Defines the related dom event
  11899. * @param localX Defines the local x coordinates of the pointer when the event occured
  11900. * @param localY Defines the local y coordinates of the pointer when the event occured
  11901. */
  11902. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11903. }
  11904. /**
  11905. * This type contains all the data related to a pointer event in Babylon.js.
  11906. * 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.
  11907. */
  11908. export class PointerInfo extends PointerInfoBase {
  11909. /**
  11910. * Defines the picking info associated to the info (if any)\
  11911. */
  11912. pickInfo: Nullable<PickingInfo>;
  11913. /**
  11914. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11915. * @param type Defines the type of event (PointerEventTypes)
  11916. * @param event Defines the related dom event
  11917. * @param pickInfo Defines the picking info associated to the info (if any)\
  11918. */
  11919. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11920. /**
  11921. * Defines the picking info associated to the info (if any)\
  11922. */
  11923. pickInfo: Nullable<PickingInfo>);
  11924. }
  11925. /**
  11926. * Data relating to a touch event on the screen.
  11927. */
  11928. export interface PointerTouch {
  11929. /**
  11930. * X coordinate of touch.
  11931. */
  11932. x: number;
  11933. /**
  11934. * Y coordinate of touch.
  11935. */
  11936. y: number;
  11937. /**
  11938. * Id of touch. Unique for each finger.
  11939. */
  11940. pointerId: number;
  11941. /**
  11942. * Event type passed from DOM.
  11943. */
  11944. type: any;
  11945. }
  11946. }
  11947. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11948. import { Observable } from "babylonjs/Misc/observable";
  11949. import { Nullable } from "babylonjs/types";
  11950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11952. /**
  11953. * Manage the mouse inputs to control the movement of a free camera.
  11954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11955. */
  11956. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11957. /**
  11958. * Define if touch is enabled in the mouse input
  11959. */
  11960. touchEnabled: boolean;
  11961. /**
  11962. * Defines the camera the input is attached to.
  11963. */
  11964. camera: FreeCamera;
  11965. /**
  11966. * Defines the buttons associated with the input to handle camera move.
  11967. */
  11968. buttons: number[];
  11969. /**
  11970. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11971. */
  11972. angularSensibility: number;
  11973. private _pointerInput;
  11974. private _onMouseMove;
  11975. private _observer;
  11976. private previousPosition;
  11977. /**
  11978. * Observable for when a pointer move event occurs containing the move offset
  11979. */
  11980. onPointerMovedObservable: Observable<{
  11981. offsetX: number;
  11982. offsetY: number;
  11983. }>;
  11984. /**
  11985. * @hidden
  11986. * If the camera should be rotated automatically based on pointer movement
  11987. */
  11988. _allowCameraRotation: boolean;
  11989. /**
  11990. * Manage the mouse inputs to control the movement of a free camera.
  11991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11992. * @param touchEnabled Defines if touch is enabled or not
  11993. */
  11994. constructor(
  11995. /**
  11996. * Define if touch is enabled in the mouse input
  11997. */
  11998. touchEnabled?: boolean);
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Called on JS contextmenu event.
  12007. * Override this method to provide functionality.
  12008. */
  12009. protected onContextMenu(evt: PointerEvent): void;
  12010. /**
  12011. * Detach the current controls from the specified dom element.
  12012. * @param element Defines the element to stop listening the inputs from
  12013. */
  12014. detachControl(element: Nullable<HTMLElement>): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12028. import { Nullable } from "babylonjs/types";
  12029. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12031. /**
  12032. * Manage the touch inputs to control the movement of a free camera.
  12033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12034. */
  12035. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12036. /**
  12037. * Defines the camera the input is attached to.
  12038. */
  12039. camera: FreeCamera;
  12040. /**
  12041. * Defines the touch sensibility for rotation.
  12042. * The higher the faster.
  12043. */
  12044. touchAngularSensibility: number;
  12045. /**
  12046. * Defines the touch sensibility for move.
  12047. * The higher the faster.
  12048. */
  12049. touchMoveSensibility: number;
  12050. private _offsetX;
  12051. private _offsetY;
  12052. private _pointerPressed;
  12053. private _pointerInput;
  12054. private _observer;
  12055. private _onLostFocus;
  12056. /**
  12057. * Attach the input controls to a specific dom element to get the input from.
  12058. * @param element Defines the element the controls should be listened from
  12059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12060. */
  12061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12062. /**
  12063. * Detach the current controls from the specified dom element.
  12064. * @param element Defines the element to stop listening the inputs from
  12065. */
  12066. detachControl(element: Nullable<HTMLElement>): void;
  12067. /**
  12068. * Update the current camera state depending on the inputs that have been used this frame.
  12069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12070. */
  12071. checkInputs(): void;
  12072. /**
  12073. * Gets the class name of the current intput.
  12074. * @returns the class name
  12075. */
  12076. getClassName(): string;
  12077. /**
  12078. * Get the friendly name associated with the input class.
  12079. * @returns the input friendly name
  12080. */
  12081. getSimpleName(): string;
  12082. }
  12083. }
  12084. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12085. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12086. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12087. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12088. import { Nullable } from "babylonjs/types";
  12089. /**
  12090. * Default Inputs manager for the FreeCamera.
  12091. * It groups all the default supported inputs for ease of use.
  12092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12093. */
  12094. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12095. /**
  12096. * @hidden
  12097. */
  12098. _mouseInput: Nullable<FreeCameraMouseInput>;
  12099. /**
  12100. * Instantiates a new FreeCameraInputsManager.
  12101. * @param camera Defines the camera the inputs belong to
  12102. */
  12103. constructor(camera: FreeCamera);
  12104. /**
  12105. * Add keyboard input support to the input manager.
  12106. * @returns the current input manager
  12107. */
  12108. addKeyboard(): FreeCameraInputsManager;
  12109. /**
  12110. * Add mouse input support to the input manager.
  12111. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12112. * @returns the current input manager
  12113. */
  12114. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12115. /**
  12116. * Removes the mouse input support from the manager
  12117. * @returns the current input manager
  12118. */
  12119. removeMouse(): FreeCameraInputsManager;
  12120. /**
  12121. * Add touch input support to the input manager.
  12122. * @returns the current input manager
  12123. */
  12124. addTouch(): FreeCameraInputsManager;
  12125. /**
  12126. * Remove all attached input methods from a camera
  12127. */
  12128. clear(): void;
  12129. }
  12130. }
  12131. declare module "babylonjs/Cameras/freeCamera" {
  12132. import { Vector3 } from "babylonjs/Maths/math.vector";
  12133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12134. import { Scene } from "babylonjs/scene";
  12135. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12136. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12137. /**
  12138. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12139. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12140. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12141. */
  12142. export class FreeCamera extends TargetCamera {
  12143. /**
  12144. * Define the collision ellipsoid of the camera.
  12145. * This is helpful to simulate a camera body like the player body around the camera
  12146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12147. */
  12148. ellipsoid: Vector3;
  12149. /**
  12150. * Define an offset for the position of the ellipsoid around the camera.
  12151. * This can be helpful to determine the center of the body near the gravity center of the body
  12152. * instead of its head.
  12153. */
  12154. ellipsoidOffset: Vector3;
  12155. /**
  12156. * Enable or disable collisions of the camera with the rest of the scene objects.
  12157. */
  12158. checkCollisions: boolean;
  12159. /**
  12160. * Enable or disable gravity on the camera.
  12161. */
  12162. applyGravity: boolean;
  12163. /**
  12164. * Define the input manager associated to the camera.
  12165. */
  12166. inputs: FreeCameraInputsManager;
  12167. /**
  12168. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12169. * Higher values reduce sensitivity.
  12170. */
  12171. /**
  12172. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12173. * Higher values reduce sensitivity.
  12174. */
  12175. angularSensibility: number;
  12176. /**
  12177. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12178. */
  12179. keysUp: number[];
  12180. /**
  12181. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12182. */
  12183. keysDown: number[];
  12184. /**
  12185. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12186. */
  12187. keysLeft: number[];
  12188. /**
  12189. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12190. */
  12191. keysRight: number[];
  12192. /**
  12193. * Event raised when the camera collide with a mesh in the scene.
  12194. */
  12195. onCollide: (collidedMesh: AbstractMesh) => void;
  12196. private _collider;
  12197. private _needMoveForGravity;
  12198. private _oldPosition;
  12199. private _diffPosition;
  12200. private _newPosition;
  12201. /** @hidden */
  12202. _localDirection: Vector3;
  12203. /** @hidden */
  12204. _transformedDirection: Vector3;
  12205. /**
  12206. * Instantiates a Free Camera.
  12207. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12208. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12210. * @param name Define the name of the camera in the scene
  12211. * @param position Define the start position of the camera in the scene
  12212. * @param scene Define the scene the camera belongs to
  12213. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12214. */
  12215. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12216. /**
  12217. * Attached controls to the current camera.
  12218. * @param element Defines the element the controls should be listened from
  12219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12220. */
  12221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12222. /**
  12223. * Detach the current controls from the camera.
  12224. * The camera will stop reacting to inputs.
  12225. * @param element Defines the element to stop listening the inputs from
  12226. */
  12227. detachControl(element: HTMLElement): void;
  12228. private _collisionMask;
  12229. /**
  12230. * Define a collision mask to limit the list of object the camera can collide with
  12231. */
  12232. collisionMask: number;
  12233. /** @hidden */
  12234. _collideWithWorld(displacement: Vector3): void;
  12235. private _onCollisionPositionChange;
  12236. /** @hidden */
  12237. _checkInputs(): void;
  12238. /** @hidden */
  12239. _decideIfNeedsToMove(): boolean;
  12240. /** @hidden */
  12241. _updatePosition(): void;
  12242. /**
  12243. * Destroy the camera and release the current resources hold by it.
  12244. */
  12245. dispose(): void;
  12246. /**
  12247. * Gets the current object class name.
  12248. * @return the class name
  12249. */
  12250. getClassName(): string;
  12251. }
  12252. }
  12253. declare module "babylonjs/Gamepads/gamepad" {
  12254. import { Observable } from "babylonjs/Misc/observable";
  12255. /**
  12256. * Represents a gamepad control stick position
  12257. */
  12258. export class StickValues {
  12259. /**
  12260. * The x component of the control stick
  12261. */
  12262. x: number;
  12263. /**
  12264. * The y component of the control stick
  12265. */
  12266. y: number;
  12267. /**
  12268. * Initializes the gamepad x and y control stick values
  12269. * @param x The x component of the gamepad control stick value
  12270. * @param y The y component of the gamepad control stick value
  12271. */
  12272. constructor(
  12273. /**
  12274. * The x component of the control stick
  12275. */
  12276. x: number,
  12277. /**
  12278. * The y component of the control stick
  12279. */
  12280. y: number);
  12281. }
  12282. /**
  12283. * An interface which manages callbacks for gamepad button changes
  12284. */
  12285. export interface GamepadButtonChanges {
  12286. /**
  12287. * Called when a gamepad has been changed
  12288. */
  12289. changed: boolean;
  12290. /**
  12291. * Called when a gamepad press event has been triggered
  12292. */
  12293. pressChanged: boolean;
  12294. /**
  12295. * Called when a touch event has been triggered
  12296. */
  12297. touchChanged: boolean;
  12298. /**
  12299. * Called when a value has changed
  12300. */
  12301. valueChanged: boolean;
  12302. }
  12303. /**
  12304. * Represents a gamepad
  12305. */
  12306. export class Gamepad {
  12307. /**
  12308. * The id of the gamepad
  12309. */
  12310. id: string;
  12311. /**
  12312. * The index of the gamepad
  12313. */
  12314. index: number;
  12315. /**
  12316. * The browser gamepad
  12317. */
  12318. browserGamepad: any;
  12319. /**
  12320. * Specifies what type of gamepad this represents
  12321. */
  12322. type: number;
  12323. private _leftStick;
  12324. private _rightStick;
  12325. /** @hidden */
  12326. _isConnected: boolean;
  12327. private _leftStickAxisX;
  12328. private _leftStickAxisY;
  12329. private _rightStickAxisX;
  12330. private _rightStickAxisY;
  12331. /**
  12332. * Triggered when the left control stick has been changed
  12333. */
  12334. private _onleftstickchanged;
  12335. /**
  12336. * Triggered when the right control stick has been changed
  12337. */
  12338. private _onrightstickchanged;
  12339. /**
  12340. * Represents a gamepad controller
  12341. */
  12342. static GAMEPAD: number;
  12343. /**
  12344. * Represents a generic controller
  12345. */
  12346. static GENERIC: number;
  12347. /**
  12348. * Represents an XBox controller
  12349. */
  12350. static XBOX: number;
  12351. /**
  12352. * Represents a pose-enabled controller
  12353. */
  12354. static POSE_ENABLED: number;
  12355. /**
  12356. * Represents an Dual Shock controller
  12357. */
  12358. static DUALSHOCK: number;
  12359. /**
  12360. * Specifies whether the left control stick should be Y-inverted
  12361. */
  12362. protected _invertLeftStickY: boolean;
  12363. /**
  12364. * Specifies if the gamepad has been connected
  12365. */
  12366. readonly isConnected: boolean;
  12367. /**
  12368. * Initializes the gamepad
  12369. * @param id The id of the gamepad
  12370. * @param index The index of the gamepad
  12371. * @param browserGamepad The browser gamepad
  12372. * @param leftStickX The x component of the left joystick
  12373. * @param leftStickY The y component of the left joystick
  12374. * @param rightStickX The x component of the right joystick
  12375. * @param rightStickY The y component of the right joystick
  12376. */
  12377. constructor(
  12378. /**
  12379. * The id of the gamepad
  12380. */
  12381. id: string,
  12382. /**
  12383. * The index of the gamepad
  12384. */
  12385. index: number,
  12386. /**
  12387. * The browser gamepad
  12388. */
  12389. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12390. /**
  12391. * Callback triggered when the left joystick has changed
  12392. * @param callback
  12393. */
  12394. onleftstickchanged(callback: (values: StickValues) => void): void;
  12395. /**
  12396. * Callback triggered when the right joystick has changed
  12397. * @param callback
  12398. */
  12399. onrightstickchanged(callback: (values: StickValues) => void): void;
  12400. /**
  12401. * Gets the left joystick
  12402. */
  12403. /**
  12404. * Sets the left joystick values
  12405. */
  12406. leftStick: StickValues;
  12407. /**
  12408. * Gets the right joystick
  12409. */
  12410. /**
  12411. * Sets the right joystick value
  12412. */
  12413. rightStick: StickValues;
  12414. /**
  12415. * Updates the gamepad joystick positions
  12416. */
  12417. update(): void;
  12418. /**
  12419. * Disposes the gamepad
  12420. */
  12421. dispose(): void;
  12422. }
  12423. /**
  12424. * Represents a generic gamepad
  12425. */
  12426. export class GenericPad extends Gamepad {
  12427. private _buttons;
  12428. private _onbuttondown;
  12429. private _onbuttonup;
  12430. /**
  12431. * Observable triggered when a button has been pressed
  12432. */
  12433. onButtonDownObservable: Observable<number>;
  12434. /**
  12435. * Observable triggered when a button has been released
  12436. */
  12437. onButtonUpObservable: Observable<number>;
  12438. /**
  12439. * Callback triggered when a button has been pressed
  12440. * @param callback Called when a button has been pressed
  12441. */
  12442. onbuttondown(callback: (buttonPressed: number) => void): void;
  12443. /**
  12444. * Callback triggered when a button has been released
  12445. * @param callback Called when a button has been released
  12446. */
  12447. onbuttonup(callback: (buttonReleased: number) => void): void;
  12448. /**
  12449. * Initializes the generic gamepad
  12450. * @param id The id of the generic gamepad
  12451. * @param index The index of the generic gamepad
  12452. * @param browserGamepad The browser gamepad
  12453. */
  12454. constructor(id: string, index: number, browserGamepad: any);
  12455. private _setButtonValue;
  12456. /**
  12457. * Updates the generic gamepad
  12458. */
  12459. update(): void;
  12460. /**
  12461. * Disposes the generic gamepad
  12462. */
  12463. dispose(): void;
  12464. }
  12465. }
  12466. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12467. import { Nullable } from "babylonjs/types";
  12468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12469. import { Scene } from "babylonjs/scene";
  12470. module "babylonjs/Engines/engine" {
  12471. interface Engine {
  12472. /**
  12473. * Creates a raw texture
  12474. * @param data defines the data to store in the texture
  12475. * @param width defines the width of the texture
  12476. * @param height defines the height of the texture
  12477. * @param format defines the format of the data
  12478. * @param generateMipMaps defines if the engine should generate the mip levels
  12479. * @param invertY defines if data must be stored with Y axis inverted
  12480. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12481. * @param compression defines the compression used (null by default)
  12482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12483. * @returns the raw texture inside an InternalTexture
  12484. */
  12485. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12486. /**
  12487. * Update a raw texture
  12488. * @param texture defines the texture to update
  12489. * @param data defines the data to store in the texture
  12490. * @param format defines the format of the data
  12491. * @param invertY defines if data must be stored with Y axis inverted
  12492. */
  12493. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12494. /**
  12495. * Update a raw texture
  12496. * @param texture defines the texture to update
  12497. * @param data defines the data to store in the texture
  12498. * @param format defines the format of the data
  12499. * @param invertY defines if data must be stored with Y axis inverted
  12500. * @param compression defines the compression used (null by default)
  12501. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12502. */
  12503. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12504. /**
  12505. * Creates a new raw cube texture
  12506. * @param data defines the array of data to use to create each face
  12507. * @param size defines the size of the textures
  12508. * @param format defines the format of the data
  12509. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12510. * @param generateMipMaps defines if the engine should generate the mip levels
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12513. * @param compression defines the compression used (null by default)
  12514. * @returns the cube texture as an InternalTexture
  12515. */
  12516. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12517. /**
  12518. * Update a raw cube texture
  12519. * @param texture defines the texture to udpdate
  12520. * @param data defines the data to store
  12521. * @param format defines the data format
  12522. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. */
  12525. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12526. /**
  12527. * Update a raw cube texture
  12528. * @param texture defines the texture to udpdate
  12529. * @param data defines the data to store
  12530. * @param format defines the data format
  12531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12532. * @param invertY defines if data must be stored with Y axis inverted
  12533. * @param compression defines the compression used (null by default)
  12534. */
  12535. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12536. /**
  12537. * Update a raw cube texture
  12538. * @param texture defines the texture to udpdate
  12539. * @param data defines the data to store
  12540. * @param format defines the data format
  12541. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param compression defines the compression used (null by default)
  12544. * @param level defines which level of the texture to update
  12545. */
  12546. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12547. /**
  12548. * Creates a new raw cube texture from a specified url
  12549. * @param url defines the url where the data is located
  12550. * @param scene defines the current scene
  12551. * @param size defines the size of the textures
  12552. * @param format defines the format of the data
  12553. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12554. * @param noMipmap defines if the engine should avoid generating the mip levels
  12555. * @param callback defines a callback used to extract texture data from loaded data
  12556. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12557. * @param onLoad defines a callback called when texture is loaded
  12558. * @param onError defines a callback called if there is an error
  12559. * @returns the cube texture as an InternalTexture
  12560. */
  12561. 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;
  12562. /**
  12563. * Creates a new raw cube texture from a specified url
  12564. * @param url defines the url where the data is located
  12565. * @param scene defines the current scene
  12566. * @param size defines the size of the textures
  12567. * @param format defines the format of the data
  12568. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12569. * @param noMipmap defines if the engine should avoid generating the mip levels
  12570. * @param callback defines a callback used to extract texture data from loaded data
  12571. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12572. * @param onLoad defines a callback called when texture is loaded
  12573. * @param onError defines a callback called if there is an error
  12574. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @returns the cube texture as an InternalTexture
  12577. */
  12578. 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;
  12579. /**
  12580. * Creates a new raw 3D texture
  12581. * @param data defines the data used to create the texture
  12582. * @param width defines the width of the texture
  12583. * @param height defines the height of the texture
  12584. * @param depth defines the depth of the texture
  12585. * @param format defines the format of the texture
  12586. * @param generateMipMaps defines if the engine must generate mip levels
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12589. * @param compression defines the compressed used (can be null)
  12590. * @param textureType defines the compressed used (can be null)
  12591. * @returns a new raw 3D texture (stored in an InternalTexture)
  12592. */
  12593. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12594. /**
  12595. * Update a raw 3D texture
  12596. * @param texture defines the texture to update
  12597. * @param data defines the data to store
  12598. * @param format defines the data format
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. */
  12601. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12602. /**
  12603. * Update a raw 3D texture
  12604. * @param texture defines the texture to update
  12605. * @param data defines the data to store
  12606. * @param format defines the data format
  12607. * @param invertY defines if data must be stored with Y axis inverted
  12608. * @param compression defines the used compression (can be null)
  12609. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12610. */
  12611. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12612. }
  12613. }
  12614. }
  12615. declare module "babylonjs/Materials/Textures/rawTexture" {
  12616. import { Scene } from "babylonjs/scene";
  12617. import { Texture } from "babylonjs/Materials/Textures/texture";
  12618. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12619. /**
  12620. * Raw texture can help creating a texture directly from an array of data.
  12621. * This can be super useful if you either get the data from an uncompressed source or
  12622. * if you wish to create your texture pixel by pixel.
  12623. */
  12624. export class RawTexture extends Texture {
  12625. /**
  12626. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12627. */
  12628. format: number;
  12629. private _engine;
  12630. /**
  12631. * Instantiates a new RawTexture.
  12632. * Raw texture can help creating a texture directly from an array of data.
  12633. * This can be super useful if you either get the data from an uncompressed source or
  12634. * if you wish to create your texture pixel by pixel.
  12635. * @param data define the array of data to use to create the texture
  12636. * @param width define the width of the texture
  12637. * @param height define the height of the texture
  12638. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12639. * @param scene define the scene the texture belongs to
  12640. * @param generateMipMaps define whether mip maps should be generated or not
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12644. */
  12645. constructor(data: ArrayBufferView, width: number, height: number,
  12646. /**
  12647. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12648. */
  12649. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12650. /**
  12651. * Updates the texture underlying data.
  12652. * @param data Define the new data of the texture
  12653. */
  12654. update(data: ArrayBufferView): void;
  12655. /**
  12656. * Creates a luminance texture from some data.
  12657. * @param data Define the texture data
  12658. * @param width Define the width of the texture
  12659. * @param height Define the height of the texture
  12660. * @param scene Define the scene the texture belongs to
  12661. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12662. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12663. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12664. * @returns the luminance texture
  12665. */
  12666. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12667. /**
  12668. * Creates a luminance alpha texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the luminance alpha texture
  12677. */
  12678. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates an alpha texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @returns the alpha texture
  12689. */
  12690. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12691. /**
  12692. * Creates a RGB texture from some data.
  12693. * @param data Define the texture data
  12694. * @param width Define the width of the texture
  12695. * @param height Define the height of the texture
  12696. * @param scene Define the scene the texture belongs to
  12697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12700. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12701. * @returns the RGB alpha texture
  12702. */
  12703. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12704. /**
  12705. * Creates a RGBA texture from some data.
  12706. * @param data Define the texture data
  12707. * @param width Define the width of the texture
  12708. * @param height Define the height of the texture
  12709. * @param scene Define the scene the texture belongs to
  12710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12713. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12714. * @returns the RGBA texture
  12715. */
  12716. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12717. /**
  12718. * Creates a R texture from some data.
  12719. * @param data Define the texture data
  12720. * @param width Define the width of the texture
  12721. * @param height Define the height of the texture
  12722. * @param scene Define the scene the texture belongs to
  12723. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12726. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12727. * @returns the R texture
  12728. */
  12729. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12730. }
  12731. }
  12732. declare module "babylonjs/Maths/math.size" {
  12733. /**
  12734. * Interface for the size containing width and height
  12735. */
  12736. export interface ISize {
  12737. /**
  12738. * Width
  12739. */
  12740. width: number;
  12741. /**
  12742. * Heighht
  12743. */
  12744. height: number;
  12745. }
  12746. /**
  12747. * Size containing widht and height
  12748. */
  12749. export class Size implements ISize {
  12750. /**
  12751. * Width
  12752. */
  12753. width: number;
  12754. /**
  12755. * Height
  12756. */
  12757. height: number;
  12758. /**
  12759. * Creates a Size object from the given width and height (floats).
  12760. * @param width width of the new size
  12761. * @param height height of the new size
  12762. */
  12763. constructor(width: number, height: number);
  12764. /**
  12765. * Returns a string with the Size width and height
  12766. * @returns a string with the Size width and height
  12767. */
  12768. toString(): string;
  12769. /**
  12770. * "Size"
  12771. * @returns the string "Size"
  12772. */
  12773. getClassName(): string;
  12774. /**
  12775. * Returns the Size hash code.
  12776. * @returns a hash code for a unique width and height
  12777. */
  12778. getHashCode(): number;
  12779. /**
  12780. * Updates the current size from the given one.
  12781. * @param src the given size
  12782. */
  12783. copyFrom(src: Size): void;
  12784. /**
  12785. * Updates in place the current Size from the given floats.
  12786. * @param width width of the new size
  12787. * @param height height of the new size
  12788. * @returns the updated Size.
  12789. */
  12790. copyFromFloats(width: number, height: number): Size;
  12791. /**
  12792. * Updates in place the current Size from the given floats.
  12793. * @param width width to set
  12794. * @param height height to set
  12795. * @returns the updated Size.
  12796. */
  12797. set(width: number, height: number): Size;
  12798. /**
  12799. * Multiplies the width and height by numbers
  12800. * @param w factor to multiple the width by
  12801. * @param h factor to multiple the height by
  12802. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12803. */
  12804. multiplyByFloats(w: number, h: number): Size;
  12805. /**
  12806. * Clones the size
  12807. * @returns a new Size copied from the given one.
  12808. */
  12809. clone(): Size;
  12810. /**
  12811. * True if the current Size and the given one width and height are strictly equal.
  12812. * @param other the other size to compare against
  12813. * @returns True if the current Size and the given one width and height are strictly equal.
  12814. */
  12815. equals(other: Size): boolean;
  12816. /**
  12817. * The surface of the Size : width * height (float).
  12818. */
  12819. readonly surface: number;
  12820. /**
  12821. * Create a new size of zero
  12822. * @returns a new Size set to (0.0, 0.0)
  12823. */
  12824. static Zero(): Size;
  12825. /**
  12826. * Sums the width and height of two sizes
  12827. * @param otherSize size to add to this size
  12828. * @returns a new Size set as the addition result of the current Size and the given one.
  12829. */
  12830. add(otherSize: Size): Size;
  12831. /**
  12832. * Subtracts the width and height of two
  12833. * @param otherSize size to subtract to this size
  12834. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12835. */
  12836. subtract(otherSize: Size): Size;
  12837. /**
  12838. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12839. * @param start starting size to lerp between
  12840. * @param end end size to lerp between
  12841. * @param amount amount to lerp between the start and end values
  12842. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12843. */
  12844. static Lerp(start: Size, end: Size, amount: number): Size;
  12845. }
  12846. }
  12847. declare module "babylonjs/Animations/runtimeAnimation" {
  12848. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12849. import { Animatable } from "babylonjs/Animations/animatable";
  12850. import { Scene } from "babylonjs/scene";
  12851. /**
  12852. * Defines a runtime animation
  12853. */
  12854. export class RuntimeAnimation {
  12855. private _events;
  12856. /**
  12857. * The current frame of the runtime animation
  12858. */
  12859. private _currentFrame;
  12860. /**
  12861. * The animation used by the runtime animation
  12862. */
  12863. private _animation;
  12864. /**
  12865. * The target of the runtime animation
  12866. */
  12867. private _target;
  12868. /**
  12869. * The initiating animatable
  12870. */
  12871. private _host;
  12872. /**
  12873. * The original value of the runtime animation
  12874. */
  12875. private _originalValue;
  12876. /**
  12877. * The original blend value of the runtime animation
  12878. */
  12879. private _originalBlendValue;
  12880. /**
  12881. * The offsets cache of the runtime animation
  12882. */
  12883. private _offsetsCache;
  12884. /**
  12885. * The high limits cache of the runtime animation
  12886. */
  12887. private _highLimitsCache;
  12888. /**
  12889. * Specifies if the runtime animation has been stopped
  12890. */
  12891. private _stopped;
  12892. /**
  12893. * The blending factor of the runtime animation
  12894. */
  12895. private _blendingFactor;
  12896. /**
  12897. * The BabylonJS scene
  12898. */
  12899. private _scene;
  12900. /**
  12901. * The current value of the runtime animation
  12902. */
  12903. private _currentValue;
  12904. /** @hidden */
  12905. _animationState: _IAnimationState;
  12906. /**
  12907. * The active target of the runtime animation
  12908. */
  12909. private _activeTargets;
  12910. private _currentActiveTarget;
  12911. private _directTarget;
  12912. /**
  12913. * The target path of the runtime animation
  12914. */
  12915. private _targetPath;
  12916. /**
  12917. * The weight of the runtime animation
  12918. */
  12919. private _weight;
  12920. /**
  12921. * The ratio offset of the runtime animation
  12922. */
  12923. private _ratioOffset;
  12924. /**
  12925. * The previous delay of the runtime animation
  12926. */
  12927. private _previousDelay;
  12928. /**
  12929. * The previous ratio of the runtime animation
  12930. */
  12931. private _previousRatio;
  12932. private _enableBlending;
  12933. private _keys;
  12934. private _minFrame;
  12935. private _maxFrame;
  12936. private _minValue;
  12937. private _maxValue;
  12938. private _targetIsArray;
  12939. /**
  12940. * Gets the current frame of the runtime animation
  12941. */
  12942. readonly currentFrame: number;
  12943. /**
  12944. * Gets the weight of the runtime animation
  12945. */
  12946. readonly weight: number;
  12947. /**
  12948. * Gets the current value of the runtime animation
  12949. */
  12950. readonly currentValue: any;
  12951. /**
  12952. * Gets the target path of the runtime animation
  12953. */
  12954. readonly targetPath: string;
  12955. /**
  12956. * Gets the actual target of the runtime animation
  12957. */
  12958. readonly target: any;
  12959. /** @hidden */
  12960. _onLoop: () => void;
  12961. /**
  12962. * Create a new RuntimeAnimation object
  12963. * @param target defines the target of the animation
  12964. * @param animation defines the source animation object
  12965. * @param scene defines the hosting scene
  12966. * @param host defines the initiating Animatable
  12967. */
  12968. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12969. private _preparePath;
  12970. /**
  12971. * Gets the animation from the runtime animation
  12972. */
  12973. readonly animation: Animation;
  12974. /**
  12975. * Resets the runtime animation to the beginning
  12976. * @param restoreOriginal defines whether to restore the target property to the original value
  12977. */
  12978. reset(restoreOriginal?: boolean): void;
  12979. /**
  12980. * Specifies if the runtime animation is stopped
  12981. * @returns Boolean specifying if the runtime animation is stopped
  12982. */
  12983. isStopped(): boolean;
  12984. /**
  12985. * Disposes of the runtime animation
  12986. */
  12987. dispose(): void;
  12988. /**
  12989. * Apply the interpolated value to the target
  12990. * @param currentValue defines the value computed by the animation
  12991. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12992. */
  12993. setValue(currentValue: any, weight: number): void;
  12994. private _getOriginalValues;
  12995. private _setValue;
  12996. /**
  12997. * Gets the loop pmode of the runtime animation
  12998. * @returns Loop Mode
  12999. */
  13000. private _getCorrectLoopMode;
  13001. /**
  13002. * Move the current animation to a given frame
  13003. * @param frame defines the frame to move to
  13004. */
  13005. goToFrame(frame: number): void;
  13006. /**
  13007. * @hidden Internal use only
  13008. */
  13009. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13010. /**
  13011. * Execute the current animation
  13012. * @param delay defines the delay to add to the current frame
  13013. * @param from defines the lower bound of the animation range
  13014. * @param to defines the upper bound of the animation range
  13015. * @param loop defines if the current animation must loop
  13016. * @param speedRatio defines the current speed ratio
  13017. * @param weight defines the weight of the animation (default is -1 so no weight)
  13018. * @param onLoop optional callback called when animation loops
  13019. * @returns a boolean indicating if the animation is running
  13020. */
  13021. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13022. }
  13023. }
  13024. declare module "babylonjs/Animations/animatable" {
  13025. import { Animation } from "babylonjs/Animations/animation";
  13026. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13027. import { Nullable } from "babylonjs/types";
  13028. import { Observable } from "babylonjs/Misc/observable";
  13029. import { Scene } from "babylonjs/scene";
  13030. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13031. import { Node } from "babylonjs/node";
  13032. /**
  13033. * Class used to store an actual running animation
  13034. */
  13035. export class Animatable {
  13036. /** defines the target object */
  13037. target: any;
  13038. /** defines the starting frame number (default is 0) */
  13039. fromFrame: number;
  13040. /** defines the ending frame number (default is 100) */
  13041. toFrame: number;
  13042. /** defines if the animation must loop (default is false) */
  13043. loopAnimation: boolean;
  13044. /** defines a callback to call when animation ends if it is not looping */
  13045. onAnimationEnd?: (() => void) | null | undefined;
  13046. /** defines a callback to call when animation loops */
  13047. onAnimationLoop?: (() => void) | null | undefined;
  13048. private _localDelayOffset;
  13049. private _pausedDelay;
  13050. private _runtimeAnimations;
  13051. private _paused;
  13052. private _scene;
  13053. private _speedRatio;
  13054. private _weight;
  13055. private _syncRoot;
  13056. /**
  13057. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13058. * This will only apply for non looping animation (default is true)
  13059. */
  13060. disposeOnEnd: boolean;
  13061. /**
  13062. * Gets a boolean indicating if the animation has started
  13063. */
  13064. animationStarted: boolean;
  13065. /**
  13066. * Observer raised when the animation ends
  13067. */
  13068. onAnimationEndObservable: Observable<Animatable>;
  13069. /**
  13070. * Observer raised when the animation loops
  13071. */
  13072. onAnimationLoopObservable: Observable<Animatable>;
  13073. /**
  13074. * Gets the root Animatable used to synchronize and normalize animations
  13075. */
  13076. readonly syncRoot: Nullable<Animatable>;
  13077. /**
  13078. * Gets the current frame of the first RuntimeAnimation
  13079. * Used to synchronize Animatables
  13080. */
  13081. readonly masterFrame: number;
  13082. /**
  13083. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13084. */
  13085. weight: number;
  13086. /**
  13087. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13088. */
  13089. speedRatio: number;
  13090. /**
  13091. * Creates a new Animatable
  13092. * @param scene defines the hosting scene
  13093. * @param target defines the target object
  13094. * @param fromFrame defines the starting frame number (default is 0)
  13095. * @param toFrame defines the ending frame number (default is 100)
  13096. * @param loopAnimation defines if the animation must loop (default is false)
  13097. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13098. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13099. * @param animations defines a group of animation to add to the new Animatable
  13100. * @param onAnimationLoop defines a callback to call when animation loops
  13101. */
  13102. constructor(scene: Scene,
  13103. /** defines the target object */
  13104. target: any,
  13105. /** defines the starting frame number (default is 0) */
  13106. fromFrame?: number,
  13107. /** defines the ending frame number (default is 100) */
  13108. toFrame?: number,
  13109. /** defines if the animation must loop (default is false) */
  13110. loopAnimation?: boolean, speedRatio?: number,
  13111. /** defines a callback to call when animation ends if it is not looping */
  13112. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13113. /** defines a callback to call when animation loops */
  13114. onAnimationLoop?: (() => void) | null | undefined);
  13115. /**
  13116. * Synchronize and normalize current Animatable with a source Animatable
  13117. * This is useful when using animation weights and when animations are not of the same length
  13118. * @param root defines the root Animatable to synchronize with
  13119. * @returns the current Animatable
  13120. */
  13121. syncWith(root: Animatable): Animatable;
  13122. /**
  13123. * Gets the list of runtime animations
  13124. * @returns an array of RuntimeAnimation
  13125. */
  13126. getAnimations(): RuntimeAnimation[];
  13127. /**
  13128. * Adds more animations to the current animatable
  13129. * @param target defines the target of the animations
  13130. * @param animations defines the new animations to add
  13131. */
  13132. appendAnimations(target: any, animations: Animation[]): void;
  13133. /**
  13134. * Gets the source animation for a specific property
  13135. * @param property defines the propertyu to look for
  13136. * @returns null or the source animation for the given property
  13137. */
  13138. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13139. /**
  13140. * Gets the runtime animation for a specific property
  13141. * @param property defines the propertyu to look for
  13142. * @returns null or the runtime animation for the given property
  13143. */
  13144. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13145. /**
  13146. * Resets the animatable to its original state
  13147. */
  13148. reset(): void;
  13149. /**
  13150. * Allows the animatable to blend with current running animations
  13151. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13152. * @param blendingSpeed defines the blending speed to use
  13153. */
  13154. enableBlending(blendingSpeed: number): void;
  13155. /**
  13156. * Disable animation blending
  13157. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13158. */
  13159. disableBlending(): void;
  13160. /**
  13161. * Jump directly to a given frame
  13162. * @param frame defines the frame to jump to
  13163. */
  13164. goToFrame(frame: number): void;
  13165. /**
  13166. * Pause the animation
  13167. */
  13168. pause(): void;
  13169. /**
  13170. * Restart the animation
  13171. */
  13172. restart(): void;
  13173. private _raiseOnAnimationEnd;
  13174. /**
  13175. * Stop and delete the current animation
  13176. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13177. * @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)
  13178. */
  13179. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13180. /**
  13181. * Wait asynchronously for the animation to end
  13182. * @returns a promise which will be fullfilled when the animation ends
  13183. */
  13184. waitAsync(): Promise<Animatable>;
  13185. /** @hidden */
  13186. _animate(delay: number): boolean;
  13187. }
  13188. module "babylonjs/scene" {
  13189. interface Scene {
  13190. /** @hidden */
  13191. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13192. /** @hidden */
  13193. _processLateAnimationBindingsForMatrices(holder: {
  13194. totalWeight: number;
  13195. animations: RuntimeAnimation[];
  13196. originalValue: Matrix;
  13197. }): any;
  13198. /** @hidden */
  13199. _processLateAnimationBindingsForQuaternions(holder: {
  13200. totalWeight: number;
  13201. animations: RuntimeAnimation[];
  13202. originalValue: Quaternion;
  13203. }, refQuaternion: Quaternion): Quaternion;
  13204. /** @hidden */
  13205. _processLateAnimationBindings(): void;
  13206. /**
  13207. * Will start the animation sequence of a given target
  13208. * @param target defines the target
  13209. * @param from defines from which frame should animation start
  13210. * @param to defines until which frame should animation run.
  13211. * @param weight defines the weight to apply to the animation (1.0 by default)
  13212. * @param loop defines if the animation loops
  13213. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13214. * @param onAnimationEnd defines the function to be executed when the animation ends
  13215. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13216. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13217. * @param onAnimationLoop defines the callback to call when an animation loops
  13218. * @returns the animatable object created for this animation
  13219. */
  13220. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13221. /**
  13222. * Will start the animation sequence of a given target
  13223. * @param target defines the target
  13224. * @param from defines from which frame should animation start
  13225. * @param to defines until which frame should animation run.
  13226. * @param loop defines if the animation loops
  13227. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13228. * @param onAnimationEnd defines the function to be executed when the animation ends
  13229. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13230. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13231. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13232. * @param onAnimationLoop defines the callback to call when an animation loops
  13233. * @returns the animatable object created for this animation
  13234. */
  13235. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13236. /**
  13237. * Will start the animation sequence of a given target and its hierarchy
  13238. * @param target defines the target
  13239. * @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.
  13240. * @param from defines from which frame should animation start
  13241. * @param to defines until which frame should animation run.
  13242. * @param loop defines if the animation loops
  13243. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13244. * @param onAnimationEnd defines the function to be executed when the animation ends
  13245. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13246. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13247. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13248. * @param onAnimationLoop defines the callback to call when an animation loops
  13249. * @returns the list of created animatables
  13250. */
  13251. 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[];
  13252. /**
  13253. * Begin a new animation on a given node
  13254. * @param target defines the target where the animation will take place
  13255. * @param animations defines the list of animations to start
  13256. * @param from defines the initial value
  13257. * @param to defines the final value
  13258. * @param loop defines if you want animation to loop (off by default)
  13259. * @param speedRatio defines the speed ratio to apply to all animations
  13260. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13261. * @param onAnimationLoop defines the callback to call when an animation loops
  13262. * @returns the list of created animatables
  13263. */
  13264. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13265. /**
  13266. * Begin a new animation on a given node and its hierarchy
  13267. * @param target defines the root node where the animation will take place
  13268. * @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.
  13269. * @param animations defines the list of animations to start
  13270. * @param from defines the initial value
  13271. * @param to defines the final value
  13272. * @param loop defines if you want animation to loop (off by default)
  13273. * @param speedRatio defines the speed ratio to apply to all animations
  13274. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13275. * @param onAnimationLoop defines the callback to call when an animation loops
  13276. * @returns the list of animatables created for all nodes
  13277. */
  13278. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13279. /**
  13280. * Gets the animatable associated with a specific target
  13281. * @param target defines the target of the animatable
  13282. * @returns the required animatable if found
  13283. */
  13284. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13285. /**
  13286. * Gets all animatables associated with a given target
  13287. * @param target defines the target to look animatables for
  13288. * @returns an array of Animatables
  13289. */
  13290. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13291. /**
  13292. * Stops and removes all animations that have been applied to the scene
  13293. */
  13294. stopAllAnimations(): void;
  13295. }
  13296. }
  13297. module "babylonjs/Bones/bone" {
  13298. interface Bone {
  13299. /**
  13300. * Copy an animation range from another bone
  13301. * @param source defines the source bone
  13302. * @param rangeName defines the range name to copy
  13303. * @param frameOffset defines the frame offset
  13304. * @param rescaleAsRequired defines if rescaling must be applied if required
  13305. * @param skelDimensionsRatio defines the scaling ratio
  13306. * @returns true if operation was successful
  13307. */
  13308. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13309. }
  13310. }
  13311. }
  13312. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13313. /**
  13314. * Class used to override all child animations of a given target
  13315. */
  13316. export class AnimationPropertiesOverride {
  13317. /**
  13318. * Gets or sets a value indicating if animation blending must be used
  13319. */
  13320. enableBlending: boolean;
  13321. /**
  13322. * Gets or sets the blending speed to use when enableBlending is true
  13323. */
  13324. blendingSpeed: number;
  13325. /**
  13326. * Gets or sets the default loop mode to use
  13327. */
  13328. loopMode: number;
  13329. }
  13330. }
  13331. declare module "babylonjs/Bones/skeleton" {
  13332. import { Bone } from "babylonjs/Bones/bone";
  13333. import { Observable } from "babylonjs/Misc/observable";
  13334. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13335. import { Scene } from "babylonjs/scene";
  13336. import { Nullable } from "babylonjs/types";
  13337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13338. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13339. import { Animatable } from "babylonjs/Animations/animatable";
  13340. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13341. import { Animation } from "babylonjs/Animations/animation";
  13342. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13343. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13344. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13345. /**
  13346. * Class used to handle skinning animations
  13347. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13348. */
  13349. export class Skeleton implements IAnimatable {
  13350. /** defines the skeleton name */
  13351. name: string;
  13352. /** defines the skeleton Id */
  13353. id: string;
  13354. /**
  13355. * Defines the list of child bones
  13356. */
  13357. bones: Bone[];
  13358. /**
  13359. * Defines an estimate of the dimension of the skeleton at rest
  13360. */
  13361. dimensionsAtRest: Vector3;
  13362. /**
  13363. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13364. */
  13365. needInitialSkinMatrix: boolean;
  13366. /**
  13367. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13368. */
  13369. overrideMesh: Nullable<AbstractMesh>;
  13370. /**
  13371. * Gets the list of animations attached to this skeleton
  13372. */
  13373. animations: Array<Animation>;
  13374. private _scene;
  13375. private _isDirty;
  13376. private _transformMatrices;
  13377. private _transformMatrixTexture;
  13378. private _meshesWithPoseMatrix;
  13379. private _animatables;
  13380. private _identity;
  13381. private _synchronizedWithMesh;
  13382. private _ranges;
  13383. private _lastAbsoluteTransformsUpdateId;
  13384. private _canUseTextureForBones;
  13385. private _uniqueId;
  13386. /** @hidden */
  13387. _numBonesWithLinkedTransformNode: number;
  13388. /** @hidden */
  13389. _hasWaitingData: Nullable<boolean>;
  13390. /**
  13391. * Specifies if the skeleton should be serialized
  13392. */
  13393. doNotSerialize: boolean;
  13394. private _useTextureToStoreBoneMatrices;
  13395. /**
  13396. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13397. * Please note that this option is not available if the hardware does not support it
  13398. */
  13399. useTextureToStoreBoneMatrices: boolean;
  13400. private _animationPropertiesOverride;
  13401. /**
  13402. * Gets or sets the animation properties override
  13403. */
  13404. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13405. /**
  13406. * List of inspectable custom properties (used by the Inspector)
  13407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13408. */
  13409. inspectableCustomProperties: IInspectable[];
  13410. /**
  13411. * An observable triggered before computing the skeleton's matrices
  13412. */
  13413. onBeforeComputeObservable: Observable<Skeleton>;
  13414. /**
  13415. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13416. */
  13417. readonly isUsingTextureForMatrices: boolean;
  13418. /**
  13419. * Gets the unique ID of this skeleton
  13420. */
  13421. readonly uniqueId: number;
  13422. /**
  13423. * Creates a new skeleton
  13424. * @param name defines the skeleton name
  13425. * @param id defines the skeleton Id
  13426. * @param scene defines the hosting scene
  13427. */
  13428. constructor(
  13429. /** defines the skeleton name */
  13430. name: string,
  13431. /** defines the skeleton Id */
  13432. id: string, scene: Scene);
  13433. /**
  13434. * Gets the current object class name.
  13435. * @return the class name
  13436. */
  13437. getClassName(): string;
  13438. /**
  13439. * Returns an array containing the root bones
  13440. * @returns an array containing the root bones
  13441. */
  13442. getChildren(): Array<Bone>;
  13443. /**
  13444. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13445. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13446. * @returns a Float32Array containing matrices data
  13447. */
  13448. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13449. /**
  13450. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13451. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13452. * @returns a raw texture containing the data
  13453. */
  13454. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13455. /**
  13456. * Gets the current hosting scene
  13457. * @returns a scene object
  13458. */
  13459. getScene(): Scene;
  13460. /**
  13461. * Gets a string representing the current skeleton data
  13462. * @param fullDetails defines a boolean indicating if we want a verbose version
  13463. * @returns a string representing the current skeleton data
  13464. */
  13465. toString(fullDetails?: boolean): string;
  13466. /**
  13467. * Get bone's index searching by name
  13468. * @param name defines bone's name to search for
  13469. * @return the indice of the bone. Returns -1 if not found
  13470. */
  13471. getBoneIndexByName(name: string): number;
  13472. /**
  13473. * Creater a new animation range
  13474. * @param name defines the name of the range
  13475. * @param from defines the start key
  13476. * @param to defines the end key
  13477. */
  13478. createAnimationRange(name: string, from: number, to: number): void;
  13479. /**
  13480. * Delete a specific animation range
  13481. * @param name defines the name of the range
  13482. * @param deleteFrames defines if frames must be removed as well
  13483. */
  13484. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13485. /**
  13486. * Gets a specific animation range
  13487. * @param name defines the name of the range to look for
  13488. * @returns the requested animation range or null if not found
  13489. */
  13490. getAnimationRange(name: string): Nullable<AnimationRange>;
  13491. /**
  13492. * Gets the list of all animation ranges defined on this skeleton
  13493. * @returns an array
  13494. */
  13495. getAnimationRanges(): Nullable<AnimationRange>[];
  13496. /**
  13497. * Copy animation range from a source skeleton.
  13498. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13499. * @param source defines the source skeleton
  13500. * @param name defines the name of the range to copy
  13501. * @param rescaleAsRequired defines if rescaling must be applied if required
  13502. * @returns true if operation was successful
  13503. */
  13504. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13505. /**
  13506. * Forces the skeleton to go to rest pose
  13507. */
  13508. returnToRest(): void;
  13509. private _getHighestAnimationFrame;
  13510. /**
  13511. * Begin a specific animation range
  13512. * @param name defines the name of the range to start
  13513. * @param loop defines if looping must be turned on (false by default)
  13514. * @param speedRatio defines the speed ratio to apply (1 by default)
  13515. * @param onAnimationEnd defines a callback which will be called when animation will end
  13516. * @returns a new animatable
  13517. */
  13518. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13519. /** @hidden */
  13520. _markAsDirty(): void;
  13521. /** @hidden */
  13522. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13523. /** @hidden */
  13524. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13525. private _computeTransformMatrices;
  13526. /**
  13527. * Build all resources required to render a skeleton
  13528. */
  13529. prepare(): void;
  13530. /**
  13531. * Gets the list of animatables currently running for this skeleton
  13532. * @returns an array of animatables
  13533. */
  13534. getAnimatables(): IAnimatable[];
  13535. /**
  13536. * Clone the current skeleton
  13537. * @param name defines the name of the new skeleton
  13538. * @param id defines the id of the new skeleton
  13539. * @returns the new skeleton
  13540. */
  13541. clone(name: string, id: string): Skeleton;
  13542. /**
  13543. * Enable animation blending for this skeleton
  13544. * @param blendingSpeed defines the blending speed to apply
  13545. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13546. */
  13547. enableBlending(blendingSpeed?: number): void;
  13548. /**
  13549. * Releases all resources associated with the current skeleton
  13550. */
  13551. dispose(): void;
  13552. /**
  13553. * Serialize the skeleton in a JSON object
  13554. * @returns a JSON object
  13555. */
  13556. serialize(): any;
  13557. /**
  13558. * Creates a new skeleton from serialized data
  13559. * @param parsedSkeleton defines the serialized data
  13560. * @param scene defines the hosting scene
  13561. * @returns a new skeleton
  13562. */
  13563. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13564. /**
  13565. * Compute all node absolute transforms
  13566. * @param forceUpdate defines if computation must be done even if cache is up to date
  13567. */
  13568. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13569. /**
  13570. * Gets the root pose matrix
  13571. * @returns a matrix
  13572. */
  13573. getPoseMatrix(): Nullable<Matrix>;
  13574. /**
  13575. * Sorts bones per internal index
  13576. */
  13577. sortBones(): void;
  13578. private _sortBones;
  13579. }
  13580. }
  13581. declare module "babylonjs/Bones/bone" {
  13582. import { Skeleton } from "babylonjs/Bones/skeleton";
  13583. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13584. import { Nullable } from "babylonjs/types";
  13585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13586. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13587. import { Node } from "babylonjs/node";
  13588. import { Space } from "babylonjs/Maths/math.axis";
  13589. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13590. /**
  13591. * Class used to store bone information
  13592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13593. */
  13594. export class Bone extends Node {
  13595. /**
  13596. * defines the bone name
  13597. */
  13598. name: string;
  13599. private static _tmpVecs;
  13600. private static _tmpQuat;
  13601. private static _tmpMats;
  13602. /**
  13603. * Gets the list of child bones
  13604. */
  13605. children: Bone[];
  13606. /** Gets the animations associated with this bone */
  13607. animations: import("babylonjs/Animations/animation").Animation[];
  13608. /**
  13609. * Gets or sets bone length
  13610. */
  13611. length: number;
  13612. /**
  13613. * @hidden Internal only
  13614. * Set this value to map this bone to a different index in the transform matrices
  13615. * Set this value to -1 to exclude the bone from the transform matrices
  13616. */
  13617. _index: Nullable<number>;
  13618. private _skeleton;
  13619. private _localMatrix;
  13620. private _restPose;
  13621. private _baseMatrix;
  13622. private _absoluteTransform;
  13623. private _invertedAbsoluteTransform;
  13624. private _parent;
  13625. private _scalingDeterminant;
  13626. private _worldTransform;
  13627. private _localScaling;
  13628. private _localRotation;
  13629. private _localPosition;
  13630. private _needToDecompose;
  13631. private _needToCompose;
  13632. /** @hidden */
  13633. _linkedTransformNode: Nullable<TransformNode>;
  13634. /** @hidden */
  13635. _waitingTransformNodeId: Nullable<string>;
  13636. /** @hidden */
  13637. /** @hidden */
  13638. _matrix: Matrix;
  13639. /**
  13640. * Create a new bone
  13641. * @param name defines the bone name
  13642. * @param skeleton defines the parent skeleton
  13643. * @param parentBone defines the parent (can be null if the bone is the root)
  13644. * @param localMatrix defines the local matrix
  13645. * @param restPose defines the rest pose matrix
  13646. * @param baseMatrix defines the base matrix
  13647. * @param index defines index of the bone in the hiearchy
  13648. */
  13649. constructor(
  13650. /**
  13651. * defines the bone name
  13652. */
  13653. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13654. /**
  13655. * Gets the current object class name.
  13656. * @return the class name
  13657. */
  13658. getClassName(): string;
  13659. /**
  13660. * Gets the parent skeleton
  13661. * @returns a skeleton
  13662. */
  13663. getSkeleton(): Skeleton;
  13664. /**
  13665. * Gets parent bone
  13666. * @returns a bone or null if the bone is the root of the bone hierarchy
  13667. */
  13668. getParent(): Nullable<Bone>;
  13669. /**
  13670. * Returns an array containing the root bones
  13671. * @returns an array containing the root bones
  13672. */
  13673. getChildren(): Array<Bone>;
  13674. /**
  13675. * Sets the parent bone
  13676. * @param parent defines the parent (can be null if the bone is the root)
  13677. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13678. */
  13679. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13680. /**
  13681. * Gets the local matrix
  13682. * @returns a matrix
  13683. */
  13684. getLocalMatrix(): Matrix;
  13685. /**
  13686. * Gets the base matrix (initial matrix which remains unchanged)
  13687. * @returns a matrix
  13688. */
  13689. getBaseMatrix(): Matrix;
  13690. /**
  13691. * Gets the rest pose matrix
  13692. * @returns a matrix
  13693. */
  13694. getRestPose(): Matrix;
  13695. /**
  13696. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13697. */
  13698. getWorldMatrix(): Matrix;
  13699. /**
  13700. * Sets the local matrix to rest pose matrix
  13701. */
  13702. returnToRest(): void;
  13703. /**
  13704. * Gets the inverse of the absolute transform matrix.
  13705. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13706. * @returns a matrix
  13707. */
  13708. getInvertedAbsoluteTransform(): Matrix;
  13709. /**
  13710. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13711. * @returns a matrix
  13712. */
  13713. getAbsoluteTransform(): Matrix;
  13714. /**
  13715. * Links with the given transform node.
  13716. * The local matrix of this bone is copied from the transform node every frame.
  13717. * @param transformNode defines the transform node to link to
  13718. */
  13719. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13720. /**
  13721. * Gets the node used to drive the bone's transformation
  13722. * @returns a transform node or null
  13723. */
  13724. getTransformNode(): Nullable<TransformNode>;
  13725. /** Gets or sets current position (in local space) */
  13726. position: Vector3;
  13727. /** Gets or sets current rotation (in local space) */
  13728. rotation: Vector3;
  13729. /** Gets or sets current rotation quaternion (in local space) */
  13730. rotationQuaternion: Quaternion;
  13731. /** Gets or sets current scaling (in local space) */
  13732. scaling: Vector3;
  13733. /**
  13734. * Gets the animation properties override
  13735. */
  13736. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13737. private _decompose;
  13738. private _compose;
  13739. /**
  13740. * Update the base and local matrices
  13741. * @param matrix defines the new base or local matrix
  13742. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13743. * @param updateLocalMatrix defines if the local matrix should be updated
  13744. */
  13745. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13746. /** @hidden */
  13747. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13748. /**
  13749. * Flag the bone as dirty (Forcing it to update everything)
  13750. */
  13751. markAsDirty(): void;
  13752. /** @hidden */
  13753. _markAsDirtyAndCompose(): void;
  13754. private _markAsDirtyAndDecompose;
  13755. /**
  13756. * Translate the bone in local or world space
  13757. * @param vec The amount to translate the bone
  13758. * @param space The space that the translation is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the postion of the bone in local or world space
  13764. * @param position The position to set the bone
  13765. * @param space The space that the position is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. */
  13768. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13769. /**
  13770. * Set the absolute position of the bone (world space)
  13771. * @param position The position to set the bone
  13772. * @param mesh The mesh that this bone is attached to
  13773. */
  13774. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13775. /**
  13776. * Scale the bone on the x, y and z axes (in local space)
  13777. * @param x The amount to scale the bone on the x axis
  13778. * @param y The amount to scale the bone on the y axis
  13779. * @param z The amount to scale the bone on the z axis
  13780. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13781. */
  13782. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13783. /**
  13784. * Set the bone scaling in local space
  13785. * @param scale defines the scaling vector
  13786. */
  13787. setScale(scale: Vector3): void;
  13788. /**
  13789. * Gets the current scaling in local space
  13790. * @returns the current scaling vector
  13791. */
  13792. getScale(): Vector3;
  13793. /**
  13794. * Gets the current scaling in local space and stores it in a target vector
  13795. * @param result defines the target vector
  13796. */
  13797. getScaleToRef(result: Vector3): void;
  13798. /**
  13799. * Set the yaw, pitch, and roll of the bone in local or world space
  13800. * @param yaw The rotation of the bone on the y axis
  13801. * @param pitch The rotation of the bone on the x axis
  13802. * @param roll The rotation of the bone on the z axis
  13803. * @param space The space that the axes of rotation are in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. */
  13806. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13807. /**
  13808. * Add a rotation to the bone on an axis in local or world space
  13809. * @param axis The axis to rotate the bone on
  13810. * @param amount The amount to rotate the bone
  13811. * @param space The space that the axis is in
  13812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13813. */
  13814. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13815. /**
  13816. * Set the rotation of the bone to a particular axis angle in local or world space
  13817. * @param axis The axis to rotate the bone on
  13818. * @param angle The angle that the bone should be rotated to
  13819. * @param space The space that the axis is in
  13820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13821. */
  13822. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13823. /**
  13824. * Set the euler rotation of the bone in local of world space
  13825. * @param rotation The euler rotation that the bone should be set to
  13826. * @param space The space that the rotation is in
  13827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13828. */
  13829. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13830. /**
  13831. * Set the quaternion rotation of the bone in local of world space
  13832. * @param quat The quaternion rotation that the bone should be set to
  13833. * @param space The space that the rotation is in
  13834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13835. */
  13836. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13837. /**
  13838. * Set the rotation matrix of the bone in local of world space
  13839. * @param rotMat The rotation matrix that the bone should be set to
  13840. * @param space The space that the rotation is in
  13841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13842. */
  13843. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13844. private _rotateWithMatrix;
  13845. private _getNegativeRotationToRef;
  13846. /**
  13847. * Get the position of the bone in local or world space
  13848. * @param space The space that the returned position is in
  13849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13850. * @returns The position of the bone
  13851. */
  13852. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13853. /**
  13854. * Copy the position of the bone to a vector3 in local or world space
  13855. * @param space The space that the returned position is in
  13856. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13857. * @param result The vector3 to copy the position to
  13858. */
  13859. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13860. /**
  13861. * Get the absolute position of the bone (world space)
  13862. * @param mesh The mesh that this bone is attached to
  13863. * @returns The absolute position of the bone
  13864. */
  13865. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13866. /**
  13867. * Copy the absolute position of the bone (world space) to the result param
  13868. * @param mesh The mesh that this bone is attached to
  13869. * @param result The vector3 to copy the absolute position to
  13870. */
  13871. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13872. /**
  13873. * Compute the absolute transforms of this bone and its children
  13874. */
  13875. computeAbsoluteTransforms(): void;
  13876. /**
  13877. * Get the world direction from an axis that is in the local space of the bone
  13878. * @param localAxis The local direction that is used to compute the world direction
  13879. * @param mesh The mesh that this bone is attached to
  13880. * @returns The world direction
  13881. */
  13882. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13883. /**
  13884. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13885. * @param localAxis The local direction that is used to compute the world direction
  13886. * @param mesh The mesh that this bone is attached to
  13887. * @param result The vector3 that the world direction will be copied to
  13888. */
  13889. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13890. /**
  13891. * Get the euler rotation of the bone in local or world space
  13892. * @param space The space that the rotation should be in
  13893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13894. * @returns The euler rotation
  13895. */
  13896. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13897. /**
  13898. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13899. * @param space The space that the rotation should be in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. * @param result The vector3 that the rotation should be copied to
  13902. */
  13903. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13904. /**
  13905. * Get the quaternion rotation of the bone in either local or world space
  13906. * @param space The space that the rotation should be in
  13907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13908. * @returns The quaternion rotation
  13909. */
  13910. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13911. /**
  13912. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13913. * @param space The space that the rotation should be in
  13914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13915. * @param result The quaternion that the rotation should be copied to
  13916. */
  13917. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13918. /**
  13919. * Get the rotation matrix of the bone in local or world space
  13920. * @param space The space that the rotation should be in
  13921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13922. * @returns The rotation matrix
  13923. */
  13924. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13925. /**
  13926. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13927. * @param space The space that the rotation should be in
  13928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13929. * @param result The quaternion that the rotation should be copied to
  13930. */
  13931. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13932. /**
  13933. * Get the world position of a point that is in the local space of the bone
  13934. * @param position The local position
  13935. * @param mesh The mesh that this bone is attached to
  13936. * @returns The world position
  13937. */
  13938. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13939. /**
  13940. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13941. * @param position The local position
  13942. * @param mesh The mesh that this bone is attached to
  13943. * @param result The vector3 that the world position should be copied to
  13944. */
  13945. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13946. /**
  13947. * Get the local position of a point that is in world space
  13948. * @param position The world position
  13949. * @param mesh The mesh that this bone is attached to
  13950. * @returns The local position
  13951. */
  13952. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13953. /**
  13954. * Get the local position of a point that is in world space and copy it to the result param
  13955. * @param position The world position
  13956. * @param mesh The mesh that this bone is attached to
  13957. * @param result The vector3 that the local position should be copied to
  13958. */
  13959. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13960. }
  13961. }
  13962. declare module "babylonjs/Meshes/transformNode" {
  13963. import { DeepImmutable } from "babylonjs/types";
  13964. import { Observable } from "babylonjs/Misc/observable";
  13965. import { Nullable } from "babylonjs/types";
  13966. import { Camera } from "babylonjs/Cameras/camera";
  13967. import { Scene } from "babylonjs/scene";
  13968. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13969. import { Node } from "babylonjs/node";
  13970. import { Bone } from "babylonjs/Bones/bone";
  13971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13972. import { Space } from "babylonjs/Maths/math.axis";
  13973. /**
  13974. * 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.
  13975. * @see https://doc.babylonjs.com/how_to/transformnode
  13976. */
  13977. export class TransformNode extends Node {
  13978. /**
  13979. * Object will not rotate to face the camera
  13980. */
  13981. static BILLBOARDMODE_NONE: number;
  13982. /**
  13983. * Object will rotate to face the camera but only on the x axis
  13984. */
  13985. static BILLBOARDMODE_X: number;
  13986. /**
  13987. * Object will rotate to face the camera but only on the y axis
  13988. */
  13989. static BILLBOARDMODE_Y: number;
  13990. /**
  13991. * Object will rotate to face the camera but only on the z axis
  13992. */
  13993. static BILLBOARDMODE_Z: number;
  13994. /**
  13995. * Object will rotate to face the camera
  13996. */
  13997. static BILLBOARDMODE_ALL: number;
  13998. /**
  13999. * Object will rotate to face the camera's position instead of orientation
  14000. */
  14001. static BILLBOARDMODE_USE_POSITION: number;
  14002. private _forward;
  14003. private _forwardInverted;
  14004. private _up;
  14005. private _right;
  14006. private _rightInverted;
  14007. private _position;
  14008. private _rotation;
  14009. private _rotationQuaternion;
  14010. protected _scaling: Vector3;
  14011. protected _isDirty: boolean;
  14012. private _transformToBoneReferal;
  14013. private _isAbsoluteSynced;
  14014. private _billboardMode;
  14015. /**
  14016. * Gets or sets the billboard mode. Default is 0.
  14017. *
  14018. * | Value | Type | Description |
  14019. * | --- | --- | --- |
  14020. * | 0 | BILLBOARDMODE_NONE | |
  14021. * | 1 | BILLBOARDMODE_X | |
  14022. * | 2 | BILLBOARDMODE_Y | |
  14023. * | 4 | BILLBOARDMODE_Z | |
  14024. * | 7 | BILLBOARDMODE_ALL | |
  14025. *
  14026. */
  14027. billboardMode: number;
  14028. private _preserveParentRotationForBillboard;
  14029. /**
  14030. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14031. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14032. */
  14033. preserveParentRotationForBillboard: boolean;
  14034. /**
  14035. * 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
  14036. */
  14037. scalingDeterminant: number;
  14038. private _infiniteDistance;
  14039. /**
  14040. * Gets or sets the distance of the object to max, often used by skybox
  14041. */
  14042. infiniteDistance: boolean;
  14043. /**
  14044. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14045. * By default the system will update normals to compensate
  14046. */
  14047. ignoreNonUniformScaling: boolean;
  14048. /**
  14049. * 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
  14050. */
  14051. reIntegrateRotationIntoRotationQuaternion: boolean;
  14052. /** @hidden */
  14053. _poseMatrix: Nullable<Matrix>;
  14054. /** @hidden */
  14055. _localMatrix: Matrix;
  14056. private _usePivotMatrix;
  14057. private _absolutePosition;
  14058. private _absoluteScaling;
  14059. private _absoluteRotationQuaternion;
  14060. private _pivotMatrix;
  14061. private _pivotMatrixInverse;
  14062. protected _postMultiplyPivotMatrix: boolean;
  14063. protected _isWorldMatrixFrozen: boolean;
  14064. /** @hidden */
  14065. _indexInSceneTransformNodesArray: number;
  14066. /**
  14067. * An event triggered after the world matrix is updated
  14068. */
  14069. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14070. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14071. /**
  14072. * Gets a string identifying the name of the class
  14073. * @returns "TransformNode" string
  14074. */
  14075. getClassName(): string;
  14076. /**
  14077. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14078. */
  14079. position: Vector3;
  14080. /**
  14081. * 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)).
  14082. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14083. */
  14084. rotation: Vector3;
  14085. /**
  14086. * 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)).
  14087. */
  14088. scaling: Vector3;
  14089. /**
  14090. * 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).
  14091. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14092. */
  14093. rotationQuaternion: Nullable<Quaternion>;
  14094. /**
  14095. * The forward direction of that transform in world space.
  14096. */
  14097. readonly forward: Vector3;
  14098. /**
  14099. * The up direction of that transform in world space.
  14100. */
  14101. readonly up: Vector3;
  14102. /**
  14103. * The right direction of that transform in world space.
  14104. */
  14105. readonly right: Vector3;
  14106. /**
  14107. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14108. * @param matrix the matrix to copy the pose from
  14109. * @returns this TransformNode.
  14110. */
  14111. updatePoseMatrix(matrix: Matrix): TransformNode;
  14112. /**
  14113. * Returns the mesh Pose matrix.
  14114. * @returns the pose matrix
  14115. */
  14116. getPoseMatrix(): Matrix;
  14117. /** @hidden */
  14118. _isSynchronized(): boolean;
  14119. /** @hidden */
  14120. _initCache(): void;
  14121. /**
  14122. * Flag the transform node as dirty (Forcing it to update everything)
  14123. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14124. * @returns this transform node
  14125. */
  14126. markAsDirty(property: string): TransformNode;
  14127. /**
  14128. * Returns the current mesh absolute position.
  14129. * Returns a Vector3.
  14130. */
  14131. readonly absolutePosition: Vector3;
  14132. /**
  14133. * Returns the current mesh absolute scaling.
  14134. * Returns a Vector3.
  14135. */
  14136. readonly absoluteScaling: Vector3;
  14137. /**
  14138. * Returns the current mesh absolute rotation.
  14139. * Returns a Quaternion.
  14140. */
  14141. readonly absoluteRotationQuaternion: Quaternion;
  14142. /**
  14143. * Sets a new matrix to apply before all other transformation
  14144. * @param matrix defines the transform matrix
  14145. * @returns the current TransformNode
  14146. */
  14147. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14148. /**
  14149. * Sets a new pivot matrix to the current node
  14150. * @param matrix defines the new pivot matrix to use
  14151. * @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
  14152. * @returns the current TransformNode
  14153. */
  14154. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14155. /**
  14156. * Returns the mesh pivot matrix.
  14157. * Default : Identity.
  14158. * @returns the matrix
  14159. */
  14160. getPivotMatrix(): Matrix;
  14161. /**
  14162. * Instantiate (when possible) or clone that node with its hierarchy
  14163. * @param newParent defines the new parent to use for the instance (or clone)
  14164. * @returns an instance (or a clone) of the current node with its hiearchy
  14165. */
  14166. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14167. /**
  14168. * Prevents the World matrix to be computed any longer
  14169. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14170. * @returns the TransformNode.
  14171. */
  14172. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14173. /**
  14174. * Allows back the World matrix computation.
  14175. * @returns the TransformNode.
  14176. */
  14177. unfreezeWorldMatrix(): this;
  14178. /**
  14179. * True if the World matrix has been frozen.
  14180. */
  14181. readonly isWorldMatrixFrozen: boolean;
  14182. /**
  14183. * Retuns the mesh absolute position in the World.
  14184. * @returns a Vector3.
  14185. */
  14186. getAbsolutePosition(): Vector3;
  14187. /**
  14188. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14189. * @param absolutePosition the absolute position to set
  14190. * @returns the TransformNode.
  14191. */
  14192. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14193. /**
  14194. * Sets the mesh position in its local space.
  14195. * @param vector3 the position to set in localspace
  14196. * @returns the TransformNode.
  14197. */
  14198. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14199. /**
  14200. * Returns the mesh position in the local space from the current World matrix values.
  14201. * @returns a new Vector3.
  14202. */
  14203. getPositionExpressedInLocalSpace(): Vector3;
  14204. /**
  14205. * Translates the mesh along the passed Vector3 in its local space.
  14206. * @param vector3 the distance to translate in localspace
  14207. * @returns the TransformNode.
  14208. */
  14209. locallyTranslate(vector3: Vector3): TransformNode;
  14210. private static _lookAtVectorCache;
  14211. /**
  14212. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14213. * @param targetPoint the position (must be in same space as current mesh) to look at
  14214. * @param yawCor optional yaw (y-axis) correction in radians
  14215. * @param pitchCor optional pitch (x-axis) correction in radians
  14216. * @param rollCor optional roll (z-axis) correction in radians
  14217. * @param space the choosen space of the target
  14218. * @returns the TransformNode.
  14219. */
  14220. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14221. /**
  14222. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14223. * This Vector3 is expressed in the World space.
  14224. * @param localAxis axis to rotate
  14225. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14226. */
  14227. getDirection(localAxis: Vector3): Vector3;
  14228. /**
  14229. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14230. * localAxis is expressed in the mesh local space.
  14231. * result is computed in the Wordl space from the mesh World matrix.
  14232. * @param localAxis axis to rotate
  14233. * @param result the resulting transformnode
  14234. * @returns this TransformNode.
  14235. */
  14236. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14237. /**
  14238. * Sets this transform node rotation to the given local axis.
  14239. * @param localAxis the axis in local space
  14240. * @param yawCor optional yaw (y-axis) correction in radians
  14241. * @param pitchCor optional pitch (x-axis) correction in radians
  14242. * @param rollCor optional roll (z-axis) correction in radians
  14243. * @returns this TransformNode
  14244. */
  14245. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14246. /**
  14247. * Sets a new pivot point to the current node
  14248. * @param point defines the new pivot point to use
  14249. * @param space defines if the point is in world or local space (local by default)
  14250. * @returns the current TransformNode
  14251. */
  14252. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14253. /**
  14254. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14255. * @returns the pivot point
  14256. */
  14257. getPivotPoint(): Vector3;
  14258. /**
  14259. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14260. * @param result the vector3 to store the result
  14261. * @returns this TransformNode.
  14262. */
  14263. getPivotPointToRef(result: Vector3): TransformNode;
  14264. /**
  14265. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14266. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14267. */
  14268. getAbsolutePivotPoint(): Vector3;
  14269. /**
  14270. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14271. * @param result vector3 to store the result
  14272. * @returns this TransformNode.
  14273. */
  14274. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14275. /**
  14276. * Defines the passed node as the parent of the current node.
  14277. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14278. * @see https://doc.babylonjs.com/how_to/parenting
  14279. * @param node the node ot set as the parent
  14280. * @returns this TransformNode.
  14281. */
  14282. setParent(node: Nullable<Node>): TransformNode;
  14283. private _nonUniformScaling;
  14284. /**
  14285. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14286. */
  14287. readonly nonUniformScaling: boolean;
  14288. /** @hidden */
  14289. _updateNonUniformScalingState(value: boolean): boolean;
  14290. /**
  14291. * Attach the current TransformNode to another TransformNode associated with a bone
  14292. * @param bone Bone affecting the TransformNode
  14293. * @param affectedTransformNode TransformNode associated with the bone
  14294. * @returns this object
  14295. */
  14296. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14297. /**
  14298. * Detach the transform node if its associated with a bone
  14299. * @returns this object
  14300. */
  14301. detachFromBone(): TransformNode;
  14302. private static _rotationAxisCache;
  14303. /**
  14304. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14305. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14306. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14307. * The passed axis is also normalized.
  14308. * @param axis the axis to rotate around
  14309. * @param amount the amount to rotate in radians
  14310. * @param space Space to rotate in (Default: local)
  14311. * @returns the TransformNode.
  14312. */
  14313. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14314. /**
  14315. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14316. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14317. * The passed axis is also normalized. .
  14318. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14319. * @param point the point to rotate around
  14320. * @param axis the axis to rotate around
  14321. * @param amount the amount to rotate in radians
  14322. * @returns the TransformNode
  14323. */
  14324. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14325. /**
  14326. * Translates the mesh along the axis vector for the passed distance in the given space.
  14327. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14328. * @param axis the axis to translate in
  14329. * @param distance the distance to translate
  14330. * @param space Space to rotate in (Default: local)
  14331. * @returns the TransformNode.
  14332. */
  14333. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14334. /**
  14335. * Adds a rotation step to the mesh current rotation.
  14336. * x, y, z are Euler angles expressed in radians.
  14337. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14338. * This means this rotation is made in the mesh local space only.
  14339. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14340. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14341. * ```javascript
  14342. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14343. * ```
  14344. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14345. * 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.
  14346. * @param x Rotation to add
  14347. * @param y Rotation to add
  14348. * @param z Rotation to add
  14349. * @returns the TransformNode.
  14350. */
  14351. addRotation(x: number, y: number, z: number): TransformNode;
  14352. /**
  14353. * @hidden
  14354. */
  14355. protected _getEffectiveParent(): Nullable<Node>;
  14356. /**
  14357. * Computes the world matrix of the node
  14358. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14359. * @returns the world matrix
  14360. */
  14361. computeWorldMatrix(force?: boolean): Matrix;
  14362. protected _afterComputeWorldMatrix(): void;
  14363. /**
  14364. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14365. * @param func callback function to add
  14366. *
  14367. * @returns the TransformNode.
  14368. */
  14369. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14370. /**
  14371. * Removes a registered callback function.
  14372. * @param func callback function to remove
  14373. * @returns the TransformNode.
  14374. */
  14375. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14376. /**
  14377. * Gets the position of the current mesh in camera space
  14378. * @param camera defines the camera to use
  14379. * @returns a position
  14380. */
  14381. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14382. /**
  14383. * Returns the distance from the mesh to the active camera
  14384. * @param camera defines the camera to use
  14385. * @returns the distance
  14386. */
  14387. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14388. /**
  14389. * Clone the current transform node
  14390. * @param name Name of the new clone
  14391. * @param newParent New parent for the clone
  14392. * @param doNotCloneChildren Do not clone children hierarchy
  14393. * @returns the new transform node
  14394. */
  14395. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14396. /**
  14397. * Serializes the objects information.
  14398. * @param currentSerializationObject defines the object to serialize in
  14399. * @returns the serialized object
  14400. */
  14401. serialize(currentSerializationObject?: any): any;
  14402. /**
  14403. * Returns a new TransformNode object parsed from the source provided.
  14404. * @param parsedTransformNode is the source.
  14405. * @param scene the scne the object belongs to
  14406. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14407. * @returns a new TransformNode object parsed from the source provided.
  14408. */
  14409. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14410. /**
  14411. * Get all child-transformNodes of this node
  14412. * @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
  14413. * @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
  14414. * @returns an array of TransformNode
  14415. */
  14416. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14417. /**
  14418. * Releases resources associated with this transform node.
  14419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14421. */
  14422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14423. /**
  14424. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14425. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14426. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14427. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14428. * @returns the current mesh
  14429. */
  14430. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14431. private _syncAbsoluteScalingAndRotation;
  14432. }
  14433. }
  14434. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14435. import { Observable } from "babylonjs/Misc/observable";
  14436. import { Nullable } from "babylonjs/types";
  14437. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14438. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14440. import { Ray } from "babylonjs/Culling/ray";
  14441. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14442. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14443. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14444. /**
  14445. * Defines the types of pose enabled controllers that are supported
  14446. */
  14447. export enum PoseEnabledControllerType {
  14448. /**
  14449. * HTC Vive
  14450. */
  14451. VIVE = 0,
  14452. /**
  14453. * Oculus Rift
  14454. */
  14455. OCULUS = 1,
  14456. /**
  14457. * Windows mixed reality
  14458. */
  14459. WINDOWS = 2,
  14460. /**
  14461. * Samsung gear VR
  14462. */
  14463. GEAR_VR = 3,
  14464. /**
  14465. * Google Daydream
  14466. */
  14467. DAYDREAM = 4,
  14468. /**
  14469. * Generic
  14470. */
  14471. GENERIC = 5
  14472. }
  14473. /**
  14474. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14475. */
  14476. export interface MutableGamepadButton {
  14477. /**
  14478. * Value of the button/trigger
  14479. */
  14480. value: number;
  14481. /**
  14482. * If the button/trigger is currently touched
  14483. */
  14484. touched: boolean;
  14485. /**
  14486. * If the button/trigger is currently pressed
  14487. */
  14488. pressed: boolean;
  14489. }
  14490. /**
  14491. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14492. * @hidden
  14493. */
  14494. export interface ExtendedGamepadButton extends GamepadButton {
  14495. /**
  14496. * If the button/trigger is currently pressed
  14497. */
  14498. readonly pressed: boolean;
  14499. /**
  14500. * If the button/trigger is currently touched
  14501. */
  14502. readonly touched: boolean;
  14503. /**
  14504. * Value of the button/trigger
  14505. */
  14506. readonly value: number;
  14507. }
  14508. /** @hidden */
  14509. export interface _GamePadFactory {
  14510. /**
  14511. * Returns wether or not the current gamepad can be created for this type of controller.
  14512. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14513. * @returns true if it can be created, otherwise false
  14514. */
  14515. canCreate(gamepadInfo: any): boolean;
  14516. /**
  14517. * Creates a new instance of the Gamepad.
  14518. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14519. * @returns the new gamepad instance
  14520. */
  14521. create(gamepadInfo: any): Gamepad;
  14522. }
  14523. /**
  14524. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14525. */
  14526. export class PoseEnabledControllerHelper {
  14527. /** @hidden */
  14528. static _ControllerFactories: _GamePadFactory[];
  14529. /** @hidden */
  14530. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14531. /**
  14532. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14533. * @param vrGamepad the gamepad to initialized
  14534. * @returns a vr controller of the type the gamepad identified as
  14535. */
  14536. static InitiateController(vrGamepad: any): Gamepad;
  14537. }
  14538. /**
  14539. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14540. */
  14541. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14542. /**
  14543. * If the controller is used in a webXR session
  14544. */
  14545. isXR: boolean;
  14546. private _deviceRoomPosition;
  14547. private _deviceRoomRotationQuaternion;
  14548. /**
  14549. * The device position in babylon space
  14550. */
  14551. devicePosition: Vector3;
  14552. /**
  14553. * The device rotation in babylon space
  14554. */
  14555. deviceRotationQuaternion: Quaternion;
  14556. /**
  14557. * The scale factor of the device in babylon space
  14558. */
  14559. deviceScaleFactor: number;
  14560. /**
  14561. * (Likely devicePosition should be used instead) The device position in its room space
  14562. */
  14563. position: Vector3;
  14564. /**
  14565. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14566. */
  14567. rotationQuaternion: Quaternion;
  14568. /**
  14569. * The type of controller (Eg. Windows mixed reality)
  14570. */
  14571. controllerType: PoseEnabledControllerType;
  14572. protected _calculatedPosition: Vector3;
  14573. private _calculatedRotation;
  14574. /**
  14575. * The raw pose from the device
  14576. */
  14577. rawPose: DevicePose;
  14578. private _trackPosition;
  14579. private _maxRotationDistFromHeadset;
  14580. private _draggedRoomRotation;
  14581. /**
  14582. * @hidden
  14583. */
  14584. _disableTrackPosition(fixedPosition: Vector3): void;
  14585. /**
  14586. * Internal, the mesh attached to the controller
  14587. * @hidden
  14588. */
  14589. _mesh: Nullable<AbstractMesh>;
  14590. private _poseControlledCamera;
  14591. private _leftHandSystemQuaternion;
  14592. /**
  14593. * Internal, matrix used to convert room space to babylon space
  14594. * @hidden
  14595. */
  14596. _deviceToWorld: Matrix;
  14597. /**
  14598. * Node to be used when casting a ray from the controller
  14599. * @hidden
  14600. */
  14601. _pointingPoseNode: Nullable<TransformNode>;
  14602. /**
  14603. * Name of the child mesh that can be used to cast a ray from the controller
  14604. */
  14605. static readonly POINTING_POSE: string;
  14606. /**
  14607. * Creates a new PoseEnabledController from a gamepad
  14608. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14609. */
  14610. constructor(browserGamepad: any);
  14611. private _workingMatrix;
  14612. /**
  14613. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14614. */
  14615. update(): void;
  14616. /**
  14617. * Updates only the pose device and mesh without doing any button event checking
  14618. */
  14619. protected _updatePoseAndMesh(): void;
  14620. /**
  14621. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14622. * @param poseData raw pose fromthe device
  14623. */
  14624. updateFromDevice(poseData: DevicePose): void;
  14625. /**
  14626. * @hidden
  14627. */
  14628. _meshAttachedObservable: Observable<AbstractMesh>;
  14629. /**
  14630. * Attaches a mesh to the controller
  14631. * @param mesh the mesh to be attached
  14632. */
  14633. attachToMesh(mesh: AbstractMesh): void;
  14634. /**
  14635. * Attaches the controllers mesh to a camera
  14636. * @param camera the camera the mesh should be attached to
  14637. */
  14638. attachToPoseControlledCamera(camera: TargetCamera): void;
  14639. /**
  14640. * Disposes of the controller
  14641. */
  14642. dispose(): void;
  14643. /**
  14644. * The mesh that is attached to the controller
  14645. */
  14646. readonly mesh: Nullable<AbstractMesh>;
  14647. /**
  14648. * Gets the ray of the controller in the direction the controller is pointing
  14649. * @param length the length the resulting ray should be
  14650. * @returns a ray in the direction the controller is pointing
  14651. */
  14652. getForwardRay(length?: number): Ray;
  14653. }
  14654. }
  14655. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14656. import { Observable } from "babylonjs/Misc/observable";
  14657. import { Scene } from "babylonjs/scene";
  14658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14659. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14660. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14661. /**
  14662. * Defines the WebVRController object that represents controllers tracked in 3D space
  14663. */
  14664. export abstract class WebVRController extends PoseEnabledController {
  14665. /**
  14666. * Internal, the default controller model for the controller
  14667. */
  14668. protected _defaultModel: AbstractMesh;
  14669. /**
  14670. * Fired when the trigger state has changed
  14671. */
  14672. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14673. /**
  14674. * Fired when the main button state has changed
  14675. */
  14676. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14677. /**
  14678. * Fired when the secondary button state has changed
  14679. */
  14680. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14681. /**
  14682. * Fired when the pad state has changed
  14683. */
  14684. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14685. /**
  14686. * Fired when controllers stick values have changed
  14687. */
  14688. onPadValuesChangedObservable: Observable<StickValues>;
  14689. /**
  14690. * Array of button availible on the controller
  14691. */
  14692. protected _buttons: Array<MutableGamepadButton>;
  14693. private _onButtonStateChange;
  14694. /**
  14695. * Fired when a controller button's state has changed
  14696. * @param callback the callback containing the button that was modified
  14697. */
  14698. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14699. /**
  14700. * X and Y axis corresponding to the controllers joystick
  14701. */
  14702. pad: StickValues;
  14703. /**
  14704. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14705. */
  14706. hand: string;
  14707. /**
  14708. * The default controller model for the controller
  14709. */
  14710. readonly defaultModel: AbstractMesh;
  14711. /**
  14712. * Creates a new WebVRController from a gamepad
  14713. * @param vrGamepad the gamepad that the WebVRController should be created from
  14714. */
  14715. constructor(vrGamepad: any);
  14716. /**
  14717. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14718. */
  14719. update(): void;
  14720. /**
  14721. * Function to be called when a button is modified
  14722. */
  14723. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14724. /**
  14725. * Loads a mesh and attaches it to the controller
  14726. * @param scene the scene the mesh should be added to
  14727. * @param meshLoaded callback for when the mesh has been loaded
  14728. */
  14729. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14730. private _setButtonValue;
  14731. private _changes;
  14732. private _checkChanges;
  14733. /**
  14734. * Disposes of th webVRCOntroller
  14735. */
  14736. dispose(): void;
  14737. }
  14738. }
  14739. declare module "babylonjs/Lights/hemisphericLight" {
  14740. import { Nullable } from "babylonjs/types";
  14741. import { Scene } from "babylonjs/scene";
  14742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14743. import { Color3 } from "babylonjs/Maths/math.color";
  14744. import { Effect } from "babylonjs/Materials/effect";
  14745. import { Light } from "babylonjs/Lights/light";
  14746. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14747. /**
  14748. * The HemisphericLight simulates the ambient environment light,
  14749. * so the passed direction is the light reflection direction, not the incoming direction.
  14750. */
  14751. export class HemisphericLight extends Light {
  14752. /**
  14753. * The groundColor is the light in the opposite direction to the one specified during creation.
  14754. * 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.
  14755. */
  14756. groundColor: Color3;
  14757. /**
  14758. * The light reflection direction, not the incoming direction.
  14759. */
  14760. direction: Vector3;
  14761. /**
  14762. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14763. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14764. * The HemisphericLight can't cast shadows.
  14765. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14766. * @param name The friendly name of the light
  14767. * @param direction The direction of the light reflection
  14768. * @param scene The scene the light belongs to
  14769. */
  14770. constructor(name: string, direction: Vector3, scene: Scene);
  14771. protected _buildUniformLayout(): void;
  14772. /**
  14773. * Returns the string "HemisphericLight".
  14774. * @return The class name
  14775. */
  14776. getClassName(): string;
  14777. /**
  14778. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14779. * Returns the updated direction.
  14780. * @param target The target the direction should point to
  14781. * @return The computed direction
  14782. */
  14783. setDirectionToTarget(target: Vector3): Vector3;
  14784. /**
  14785. * Returns the shadow generator associated to the light.
  14786. * @returns Always null for hemispheric lights because it does not support shadows.
  14787. */
  14788. getShadowGenerator(): Nullable<IShadowGenerator>;
  14789. /**
  14790. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14791. * @param effect The effect to update
  14792. * @param lightIndex The index of the light in the effect to update
  14793. * @returns The hemispheric light
  14794. */
  14795. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14796. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14797. /**
  14798. * Computes the world matrix of the node
  14799. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14800. * @param useWasUpdatedFlag defines a reserved property
  14801. * @returns the world matrix
  14802. */
  14803. computeWorldMatrix(): Matrix;
  14804. /**
  14805. * Returns the integer 3.
  14806. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14807. */
  14808. getTypeID(): number;
  14809. /**
  14810. * Prepares the list of defines specific to the light type.
  14811. * @param defines the list of defines
  14812. * @param lightIndex defines the index of the light for the effect
  14813. */
  14814. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14815. }
  14816. }
  14817. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14818. /** @hidden */
  14819. export var vrMultiviewToSingleviewPixelShader: {
  14820. name: string;
  14821. shader: string;
  14822. };
  14823. }
  14824. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14826. import { Scene } from "babylonjs/scene";
  14827. /**
  14828. * Renders to multiple views with a single draw call
  14829. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14830. */
  14831. export class MultiviewRenderTarget extends RenderTargetTexture {
  14832. /**
  14833. * Creates a multiview render target
  14834. * @param scene scene used with the render target
  14835. * @param size the size of the render target (used for each view)
  14836. */
  14837. constructor(scene: Scene, size?: number | {
  14838. width: number;
  14839. height: number;
  14840. } | {
  14841. ratio: number;
  14842. });
  14843. /**
  14844. * @hidden
  14845. * @param faceIndex the face index, if its a cube texture
  14846. */
  14847. _bindFrameBuffer(faceIndex?: number): void;
  14848. /**
  14849. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14850. * @returns the view count
  14851. */
  14852. getViewCount(): number;
  14853. }
  14854. }
  14855. declare module "babylonjs/Maths/math.frustum" {
  14856. import { Matrix } from "babylonjs/Maths/math.vector";
  14857. import { DeepImmutable } from "babylonjs/types";
  14858. import { Plane } from "babylonjs/Maths/math.plane";
  14859. /**
  14860. * Reprasents a camera frustum
  14861. */
  14862. export class Frustum {
  14863. /**
  14864. * Gets the planes representing the frustum
  14865. * @param transform matrix to be applied to the returned planes
  14866. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14867. */
  14868. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14869. /**
  14870. * Gets the near frustum plane transformed by the transform matrix
  14871. * @param transform transformation matrix to be applied to the resulting frustum plane
  14872. * @param frustumPlane the resuling frustum plane
  14873. */
  14874. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14875. /**
  14876. * Gets the far frustum plane transformed by the transform matrix
  14877. * @param transform transformation matrix to be applied to the resulting frustum plane
  14878. * @param frustumPlane the resuling frustum plane
  14879. */
  14880. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14881. /**
  14882. * Gets the left frustum plane transformed by the transform matrix
  14883. * @param transform transformation matrix to be applied to the resulting frustum plane
  14884. * @param frustumPlane the resuling frustum plane
  14885. */
  14886. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14887. /**
  14888. * Gets the right frustum plane transformed by the transform matrix
  14889. * @param transform transformation matrix to be applied to the resulting frustum plane
  14890. * @param frustumPlane the resuling frustum plane
  14891. */
  14892. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14893. /**
  14894. * Gets the top frustum plane transformed by the transform matrix
  14895. * @param transform transformation matrix to be applied to the resulting frustum plane
  14896. * @param frustumPlane the resuling frustum plane
  14897. */
  14898. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14899. /**
  14900. * Gets the bottom frustum plane transformed by the transform matrix
  14901. * @param transform transformation matrix to be applied to the resulting frustum plane
  14902. * @param frustumPlane the resuling frustum plane
  14903. */
  14904. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14905. /**
  14906. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14907. * @param transform transformation matrix to be applied to the resulting frustum planes
  14908. * @param frustumPlanes the resuling frustum planes
  14909. */
  14910. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14911. }
  14912. }
  14913. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14914. import { Camera } from "babylonjs/Cameras/camera";
  14915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14916. import { Nullable } from "babylonjs/types";
  14917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14918. import { Matrix } from "babylonjs/Maths/math.vector";
  14919. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14920. module "babylonjs/Engines/engine" {
  14921. interface Engine {
  14922. /**
  14923. * Creates a new multiview render target
  14924. * @param width defines the width of the texture
  14925. * @param height defines the height of the texture
  14926. * @returns the created multiview texture
  14927. */
  14928. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14929. /**
  14930. * Binds a multiview framebuffer to be drawn to
  14931. * @param multiviewTexture texture to bind
  14932. */
  14933. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14934. }
  14935. }
  14936. module "babylonjs/Cameras/camera" {
  14937. interface Camera {
  14938. /**
  14939. * @hidden
  14940. * 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)
  14941. */
  14942. _useMultiviewToSingleView: boolean;
  14943. /**
  14944. * @hidden
  14945. * 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)
  14946. */
  14947. _multiviewTexture: Nullable<RenderTargetTexture>;
  14948. /**
  14949. * @hidden
  14950. * ensures the multiview texture of the camera exists and has the specified width/height
  14951. * @param width height to set on the multiview texture
  14952. * @param height width to set on the multiview texture
  14953. */
  14954. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14955. }
  14956. }
  14957. module "babylonjs/scene" {
  14958. interface Scene {
  14959. /** @hidden */
  14960. _transformMatrixR: Matrix;
  14961. /** @hidden */
  14962. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14963. /** @hidden */
  14964. _createMultiviewUbo(): void;
  14965. /** @hidden */
  14966. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14967. /** @hidden */
  14968. _renderMultiviewToSingleView(camera: Camera): void;
  14969. }
  14970. }
  14971. }
  14972. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14973. import { Camera } from "babylonjs/Cameras/camera";
  14974. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14975. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14976. import "babylonjs/Engines/Extensions/engine.multiview";
  14977. /**
  14978. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14979. * This will not be used for webXR as it supports displaying texture arrays directly
  14980. */
  14981. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14982. /**
  14983. * Initializes a VRMultiviewToSingleview
  14984. * @param name name of the post process
  14985. * @param camera camera to be applied to
  14986. * @param scaleFactor scaling factor to the size of the output texture
  14987. */
  14988. constructor(name: string, camera: Camera, scaleFactor: number);
  14989. }
  14990. }
  14991. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14992. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14993. import { Nullable } from "babylonjs/types";
  14994. import { Size } from "babylonjs/Maths/math.size";
  14995. import { Observable } from "babylonjs/Misc/observable";
  14996. module "babylonjs/Engines/engine" {
  14997. interface Engine {
  14998. /** @hidden */
  14999. _vrDisplay: any;
  15000. /** @hidden */
  15001. _vrSupported: boolean;
  15002. /** @hidden */
  15003. _oldSize: Size;
  15004. /** @hidden */
  15005. _oldHardwareScaleFactor: number;
  15006. /** @hidden */
  15007. _vrExclusivePointerMode: boolean;
  15008. /** @hidden */
  15009. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15010. /** @hidden */
  15011. _onVRDisplayPointerRestricted: () => void;
  15012. /** @hidden */
  15013. _onVRDisplayPointerUnrestricted: () => void;
  15014. /** @hidden */
  15015. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15016. /** @hidden */
  15017. _onVrDisplayDisconnect: Nullable<() => void>;
  15018. /** @hidden */
  15019. _onVrDisplayPresentChange: Nullable<() => void>;
  15020. /**
  15021. * Observable signaled when VR display mode changes
  15022. */
  15023. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15024. /**
  15025. * Observable signaled when VR request present is complete
  15026. */
  15027. onVRRequestPresentComplete: Observable<boolean>;
  15028. /**
  15029. * Observable signaled when VR request present starts
  15030. */
  15031. onVRRequestPresentStart: Observable<Engine>;
  15032. /**
  15033. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15034. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15035. */
  15036. isInVRExclusivePointerMode: boolean;
  15037. /**
  15038. * Gets a boolean indicating if a webVR device was detected
  15039. * @returns true if a webVR device was detected
  15040. */
  15041. isVRDevicePresent(): boolean;
  15042. /**
  15043. * Gets the current webVR device
  15044. * @returns the current webVR device (or null)
  15045. */
  15046. getVRDevice(): any;
  15047. /**
  15048. * Initializes a webVR display and starts listening to display change events
  15049. * The onVRDisplayChangedObservable will be notified upon these changes
  15050. * @returns A promise containing a VRDisplay and if vr is supported
  15051. */
  15052. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15053. /** @hidden */
  15054. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15055. /**
  15056. * Call this function to switch to webVR mode
  15057. * Will do nothing if webVR is not supported or if there is no webVR device
  15058. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15059. */
  15060. enableVR(): void;
  15061. /** @hidden */
  15062. _onVRFullScreenTriggered(): void;
  15063. }
  15064. }
  15065. }
  15066. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15067. import { Nullable } from "babylonjs/types";
  15068. import { Observable } from "babylonjs/Misc/observable";
  15069. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15070. import { Scene } from "babylonjs/scene";
  15071. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15072. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15073. import { Node } from "babylonjs/node";
  15074. import { Ray } from "babylonjs/Culling/ray";
  15075. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15076. import "babylonjs/Engines/Extensions/engine.webVR";
  15077. /**
  15078. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15079. * IMPORTANT!! The data is right-hand data.
  15080. * @export
  15081. * @interface DevicePose
  15082. */
  15083. export interface DevicePose {
  15084. /**
  15085. * The position of the device, values in array are [x,y,z].
  15086. */
  15087. readonly position: Nullable<Float32Array>;
  15088. /**
  15089. * The linearVelocity of the device, values in array are [x,y,z].
  15090. */
  15091. readonly linearVelocity: Nullable<Float32Array>;
  15092. /**
  15093. * The linearAcceleration of the device, values in array are [x,y,z].
  15094. */
  15095. readonly linearAcceleration: Nullable<Float32Array>;
  15096. /**
  15097. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15098. */
  15099. readonly orientation: Nullable<Float32Array>;
  15100. /**
  15101. * The angularVelocity of the device, values in array are [x,y,z].
  15102. */
  15103. readonly angularVelocity: Nullable<Float32Array>;
  15104. /**
  15105. * The angularAcceleration of the device, values in array are [x,y,z].
  15106. */
  15107. readonly angularAcceleration: Nullable<Float32Array>;
  15108. }
  15109. /**
  15110. * Interface representing a pose controlled object in Babylon.
  15111. * A pose controlled object has both regular pose values as well as pose values
  15112. * from an external device such as a VR head mounted display
  15113. */
  15114. export interface PoseControlled {
  15115. /**
  15116. * The position of the object in babylon space.
  15117. */
  15118. position: Vector3;
  15119. /**
  15120. * The rotation quaternion of the object in babylon space.
  15121. */
  15122. rotationQuaternion: Quaternion;
  15123. /**
  15124. * The position of the device in babylon space.
  15125. */
  15126. devicePosition?: Vector3;
  15127. /**
  15128. * The rotation quaternion of the device in babylon space.
  15129. */
  15130. deviceRotationQuaternion: Quaternion;
  15131. /**
  15132. * The raw pose coming from the device.
  15133. */
  15134. rawPose: Nullable<DevicePose>;
  15135. /**
  15136. * The scale of the device to be used when translating from device space to babylon space.
  15137. */
  15138. deviceScaleFactor: number;
  15139. /**
  15140. * Updates the poseControlled values based on the input device pose.
  15141. * @param poseData the pose data to update the object with
  15142. */
  15143. updateFromDevice(poseData: DevicePose): void;
  15144. }
  15145. /**
  15146. * Set of options to customize the webVRCamera
  15147. */
  15148. export interface WebVROptions {
  15149. /**
  15150. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15151. */
  15152. trackPosition?: boolean;
  15153. /**
  15154. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15155. */
  15156. positionScale?: number;
  15157. /**
  15158. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15159. */
  15160. displayName?: string;
  15161. /**
  15162. * Should the native controller meshes be initialized. (default: true)
  15163. */
  15164. controllerMeshes?: boolean;
  15165. /**
  15166. * Creating a default HemiLight only on controllers. (default: true)
  15167. */
  15168. defaultLightingOnControllers?: boolean;
  15169. /**
  15170. * If you don't want to use the default VR button of the helper. (default: false)
  15171. */
  15172. useCustomVRButton?: boolean;
  15173. /**
  15174. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15175. */
  15176. customVRButton?: HTMLButtonElement;
  15177. /**
  15178. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15179. */
  15180. rayLength?: number;
  15181. /**
  15182. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15183. */
  15184. defaultHeight?: number;
  15185. /**
  15186. * If multiview should be used if availible (default: false)
  15187. */
  15188. useMultiview?: boolean;
  15189. }
  15190. /**
  15191. * This represents a WebVR camera.
  15192. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15193. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15194. */
  15195. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15196. private webVROptions;
  15197. /**
  15198. * @hidden
  15199. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15200. */
  15201. _vrDevice: any;
  15202. /**
  15203. * The rawPose of the vrDevice.
  15204. */
  15205. rawPose: Nullable<DevicePose>;
  15206. private _onVREnabled;
  15207. private _specsVersion;
  15208. private _attached;
  15209. private _frameData;
  15210. protected _descendants: Array<Node>;
  15211. private _deviceRoomPosition;
  15212. /** @hidden */
  15213. _deviceRoomRotationQuaternion: Quaternion;
  15214. private _standingMatrix;
  15215. /**
  15216. * Represents device position in babylon space.
  15217. */
  15218. devicePosition: Vector3;
  15219. /**
  15220. * Represents device rotation in babylon space.
  15221. */
  15222. deviceRotationQuaternion: Quaternion;
  15223. /**
  15224. * The scale of the device to be used when translating from device space to babylon space.
  15225. */
  15226. deviceScaleFactor: number;
  15227. private _deviceToWorld;
  15228. private _worldToDevice;
  15229. /**
  15230. * References to the webVR controllers for the vrDevice.
  15231. */
  15232. controllers: Array<WebVRController>;
  15233. /**
  15234. * Emits an event when a controller is attached.
  15235. */
  15236. onControllersAttachedObservable: Observable<WebVRController[]>;
  15237. /**
  15238. * Emits an event when a controller's mesh has been loaded;
  15239. */
  15240. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15241. /**
  15242. * Emits an event when the HMD's pose has been updated.
  15243. */
  15244. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15245. private _poseSet;
  15246. /**
  15247. * If the rig cameras be used as parent instead of this camera.
  15248. */
  15249. rigParenting: boolean;
  15250. private _lightOnControllers;
  15251. private _defaultHeight?;
  15252. /**
  15253. * Instantiates a WebVRFreeCamera.
  15254. * @param name The name of the WebVRFreeCamera
  15255. * @param position The starting anchor position for the camera
  15256. * @param scene The scene the camera belongs to
  15257. * @param webVROptions a set of customizable options for the webVRCamera
  15258. */
  15259. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15260. /**
  15261. * Gets the device distance from the ground in meters.
  15262. * @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.
  15263. */
  15264. deviceDistanceToRoomGround(): number;
  15265. /**
  15266. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15267. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15268. */
  15269. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15270. /**
  15271. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15272. * @returns A promise with a boolean set to if the standing matrix is supported.
  15273. */
  15274. useStandingMatrixAsync(): Promise<boolean>;
  15275. /**
  15276. * Disposes the camera
  15277. */
  15278. dispose(): void;
  15279. /**
  15280. * Gets a vrController by name.
  15281. * @param name The name of the controller to retreive
  15282. * @returns the controller matching the name specified or null if not found
  15283. */
  15284. getControllerByName(name: string): Nullable<WebVRController>;
  15285. private _leftController;
  15286. /**
  15287. * The controller corresponding to the users left hand.
  15288. */
  15289. readonly leftController: Nullable<WebVRController>;
  15290. private _rightController;
  15291. /**
  15292. * The controller corresponding to the users right hand.
  15293. */
  15294. readonly rightController: Nullable<WebVRController>;
  15295. /**
  15296. * Casts a ray forward from the vrCamera's gaze.
  15297. * @param length Length of the ray (default: 100)
  15298. * @returns the ray corresponding to the gaze
  15299. */
  15300. getForwardRay(length?: number): Ray;
  15301. /**
  15302. * @hidden
  15303. * Updates the camera based on device's frame data
  15304. */
  15305. _checkInputs(): void;
  15306. /**
  15307. * Updates the poseControlled values based on the input device pose.
  15308. * @param poseData Pose coming from the device
  15309. */
  15310. updateFromDevice(poseData: DevicePose): void;
  15311. private _htmlElementAttached;
  15312. private _detachIfAttached;
  15313. /**
  15314. * WebVR's attach control will start broadcasting frames to the device.
  15315. * Note that in certain browsers (chrome for example) this function must be called
  15316. * within a user-interaction callback. Example:
  15317. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15318. *
  15319. * @param element html element to attach the vrDevice to
  15320. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15321. */
  15322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15323. /**
  15324. * Detaches the camera from the html element and disables VR
  15325. *
  15326. * @param element html element to detach from
  15327. */
  15328. detachControl(element: HTMLElement): void;
  15329. /**
  15330. * @returns the name of this class
  15331. */
  15332. getClassName(): string;
  15333. /**
  15334. * Calls resetPose on the vrDisplay
  15335. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15336. */
  15337. resetToCurrentRotation(): void;
  15338. /**
  15339. * @hidden
  15340. * Updates the rig cameras (left and right eye)
  15341. */
  15342. _updateRigCameras(): void;
  15343. private _workingVector;
  15344. private _oneVector;
  15345. private _workingMatrix;
  15346. private updateCacheCalled;
  15347. private _correctPositionIfNotTrackPosition;
  15348. /**
  15349. * @hidden
  15350. * Updates the cached values of the camera
  15351. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15352. */
  15353. _updateCache(ignoreParentClass?: boolean): void;
  15354. /**
  15355. * @hidden
  15356. * Get current device position in babylon world
  15357. */
  15358. _computeDevicePosition(): void;
  15359. /**
  15360. * Updates the current device position and rotation in the babylon world
  15361. */
  15362. update(): void;
  15363. /**
  15364. * @hidden
  15365. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15366. * @returns an identity matrix
  15367. */
  15368. _getViewMatrix(): Matrix;
  15369. private _tmpMatrix;
  15370. /**
  15371. * This function is called by the two RIG cameras.
  15372. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15373. * @hidden
  15374. */
  15375. _getWebVRViewMatrix(): Matrix;
  15376. /** @hidden */
  15377. _getWebVRProjectionMatrix(): Matrix;
  15378. private _onGamepadConnectedObserver;
  15379. private _onGamepadDisconnectedObserver;
  15380. private _updateCacheWhenTrackingDisabledObserver;
  15381. /**
  15382. * Initializes the controllers and their meshes
  15383. */
  15384. initControllers(): void;
  15385. }
  15386. }
  15387. declare module "babylonjs/PostProcesses/postProcess" {
  15388. import { Nullable } from "babylonjs/types";
  15389. import { SmartArray } from "babylonjs/Misc/smartArray";
  15390. import { Observable } from "babylonjs/Misc/observable";
  15391. import { Vector2 } from "babylonjs/Maths/math.vector";
  15392. import { Camera } from "babylonjs/Cameras/camera";
  15393. import { Effect } from "babylonjs/Materials/effect";
  15394. import "babylonjs/Shaders/postprocess.vertex";
  15395. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15396. import { Engine } from "babylonjs/Engines/engine";
  15397. import { Color4 } from "babylonjs/Maths/math.color";
  15398. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15399. /**
  15400. * Size options for a post process
  15401. */
  15402. export type PostProcessOptions = {
  15403. width: number;
  15404. height: number;
  15405. };
  15406. /**
  15407. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15408. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15409. */
  15410. export class PostProcess {
  15411. /** Name of the PostProcess. */
  15412. name: string;
  15413. /**
  15414. * Gets or sets the unique id of the post process
  15415. */
  15416. uniqueId: number;
  15417. /**
  15418. * Width of the texture to apply the post process on
  15419. */
  15420. width: number;
  15421. /**
  15422. * Height of the texture to apply the post process on
  15423. */
  15424. height: number;
  15425. /**
  15426. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15427. * @hidden
  15428. */
  15429. _outputTexture: Nullable<InternalTexture>;
  15430. /**
  15431. * Sampling mode used by the shader
  15432. * See https://doc.babylonjs.com/classes/3.1/texture
  15433. */
  15434. renderTargetSamplingMode: number;
  15435. /**
  15436. * Clear color to use when screen clearing
  15437. */
  15438. clearColor: Color4;
  15439. /**
  15440. * If the buffer needs to be cleared before applying the post process. (default: true)
  15441. * Should be set to false if shader will overwrite all previous pixels.
  15442. */
  15443. autoClear: boolean;
  15444. /**
  15445. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15446. */
  15447. alphaMode: number;
  15448. /**
  15449. * Sets the setAlphaBlendConstants of the babylon engine
  15450. */
  15451. alphaConstants: Color4;
  15452. /**
  15453. * Animations to be used for the post processing
  15454. */
  15455. animations: import("babylonjs/Animations/animation").Animation[];
  15456. /**
  15457. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15458. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15459. */
  15460. enablePixelPerfectMode: boolean;
  15461. /**
  15462. * Force the postprocess to be applied without taking in account viewport
  15463. */
  15464. forceFullscreenViewport: boolean;
  15465. /**
  15466. * List of inspectable custom properties (used by the Inspector)
  15467. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15468. */
  15469. inspectableCustomProperties: IInspectable[];
  15470. /**
  15471. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15472. *
  15473. * | Value | Type | Description |
  15474. * | ----- | ----------------------------------- | ----------- |
  15475. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15476. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15477. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15478. *
  15479. */
  15480. scaleMode: number;
  15481. /**
  15482. * Force textures to be a power of two (default: false)
  15483. */
  15484. alwaysForcePOT: boolean;
  15485. private _samples;
  15486. /**
  15487. * Number of sample textures (default: 1)
  15488. */
  15489. samples: number;
  15490. /**
  15491. * Modify the scale of the post process to be the same as the viewport (default: false)
  15492. */
  15493. adaptScaleToCurrentViewport: boolean;
  15494. private _camera;
  15495. private _scene;
  15496. private _engine;
  15497. private _options;
  15498. private _reusable;
  15499. private _textureType;
  15500. /**
  15501. * Smart array of input and output textures for the post process.
  15502. * @hidden
  15503. */
  15504. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15505. /**
  15506. * The index in _textures that corresponds to the output texture.
  15507. * @hidden
  15508. */
  15509. _currentRenderTextureInd: number;
  15510. private _effect;
  15511. private _samplers;
  15512. private _fragmentUrl;
  15513. private _vertexUrl;
  15514. private _parameters;
  15515. private _scaleRatio;
  15516. protected _indexParameters: any;
  15517. private _shareOutputWithPostProcess;
  15518. private _texelSize;
  15519. private _forcedOutputTexture;
  15520. /**
  15521. * Returns the fragment url or shader name used in the post process.
  15522. * @returns the fragment url or name in the shader store.
  15523. */
  15524. getEffectName(): string;
  15525. /**
  15526. * An event triggered when the postprocess is activated.
  15527. */
  15528. onActivateObservable: Observable<Camera>;
  15529. private _onActivateObserver;
  15530. /**
  15531. * A function that is added to the onActivateObservable
  15532. */
  15533. onActivate: Nullable<(camera: Camera) => void>;
  15534. /**
  15535. * An event triggered when the postprocess changes its size.
  15536. */
  15537. onSizeChangedObservable: Observable<PostProcess>;
  15538. private _onSizeChangedObserver;
  15539. /**
  15540. * A function that is added to the onSizeChangedObservable
  15541. */
  15542. onSizeChanged: (postProcess: PostProcess) => void;
  15543. /**
  15544. * An event triggered when the postprocess applies its effect.
  15545. */
  15546. onApplyObservable: Observable<Effect>;
  15547. private _onApplyObserver;
  15548. /**
  15549. * A function that is added to the onApplyObservable
  15550. */
  15551. onApply: (effect: Effect) => void;
  15552. /**
  15553. * An event triggered before rendering the postprocess
  15554. */
  15555. onBeforeRenderObservable: Observable<Effect>;
  15556. private _onBeforeRenderObserver;
  15557. /**
  15558. * A function that is added to the onBeforeRenderObservable
  15559. */
  15560. onBeforeRender: (effect: Effect) => void;
  15561. /**
  15562. * An event triggered after rendering the postprocess
  15563. */
  15564. onAfterRenderObservable: Observable<Effect>;
  15565. private _onAfterRenderObserver;
  15566. /**
  15567. * A function that is added to the onAfterRenderObservable
  15568. */
  15569. onAfterRender: (efect: Effect) => void;
  15570. /**
  15571. * 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
  15572. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15573. */
  15574. inputTexture: InternalTexture;
  15575. /**
  15576. * Gets the camera which post process is applied to.
  15577. * @returns The camera the post process is applied to.
  15578. */
  15579. getCamera(): Camera;
  15580. /**
  15581. * Gets the texel size of the postprocess.
  15582. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15583. */
  15584. readonly texelSize: Vector2;
  15585. /**
  15586. * Creates a new instance PostProcess
  15587. * @param name The name of the PostProcess.
  15588. * @param fragmentUrl The url of the fragment shader to be used.
  15589. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15590. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15591. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15592. * @param camera The camera to apply the render pass to.
  15593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15594. * @param engine The engine which the post process will be applied. (default: current engine)
  15595. * @param reusable If the post process can be reused on the same frame. (default: false)
  15596. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15597. * @param textureType Type of textures used when performing the post process. (default: 0)
  15598. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15599. * @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
  15600. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15601. */
  15602. constructor(
  15603. /** Name of the PostProcess. */
  15604. 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);
  15605. /**
  15606. * Gets a string idenfifying the name of the class
  15607. * @returns "PostProcess" string
  15608. */
  15609. getClassName(): string;
  15610. /**
  15611. * Gets the engine which this post process belongs to.
  15612. * @returns The engine the post process was enabled with.
  15613. */
  15614. getEngine(): Engine;
  15615. /**
  15616. * The effect that is created when initializing the post process.
  15617. * @returns The created effect corresponding the the postprocess.
  15618. */
  15619. getEffect(): Effect;
  15620. /**
  15621. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15622. * @param postProcess The post process to share the output with.
  15623. * @returns This post process.
  15624. */
  15625. shareOutputWith(postProcess: PostProcess): PostProcess;
  15626. /**
  15627. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15628. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15629. */
  15630. useOwnOutput(): void;
  15631. /**
  15632. * Updates the effect with the current post process compile time values and recompiles the shader.
  15633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15636. * @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
  15637. * @param onCompiled Called when the shader has been compiled.
  15638. * @param onError Called if there is an error when compiling a shader.
  15639. */
  15640. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15641. /**
  15642. * The post process is reusable if it can be used multiple times within one frame.
  15643. * @returns If the post process is reusable
  15644. */
  15645. isReusable(): boolean;
  15646. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15647. markTextureDirty(): void;
  15648. /**
  15649. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15650. * 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.
  15651. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15652. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15653. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15654. * @returns The target texture that was bound to be written to.
  15655. */
  15656. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15657. /**
  15658. * If the post process is supported.
  15659. */
  15660. readonly isSupported: boolean;
  15661. /**
  15662. * The aspect ratio of the output texture.
  15663. */
  15664. readonly aspectRatio: number;
  15665. /**
  15666. * Get a value indicating if the post-process is ready to be used
  15667. * @returns true if the post-process is ready (shader is compiled)
  15668. */
  15669. isReady(): boolean;
  15670. /**
  15671. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15672. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15673. */
  15674. apply(): Nullable<Effect>;
  15675. private _disposeTextures;
  15676. /**
  15677. * Disposes the post process.
  15678. * @param camera The camera to dispose the post process on.
  15679. */
  15680. dispose(camera?: Camera): void;
  15681. }
  15682. }
  15683. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15684. /** @hidden */
  15685. export var kernelBlurVaryingDeclaration: {
  15686. name: string;
  15687. shader: string;
  15688. };
  15689. }
  15690. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15691. /** @hidden */
  15692. export var kernelBlurFragment: {
  15693. name: string;
  15694. shader: string;
  15695. };
  15696. }
  15697. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15698. /** @hidden */
  15699. export var kernelBlurFragment2: {
  15700. name: string;
  15701. shader: string;
  15702. };
  15703. }
  15704. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15705. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15706. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15707. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15708. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15709. /** @hidden */
  15710. export var kernelBlurPixelShader: {
  15711. name: string;
  15712. shader: string;
  15713. };
  15714. }
  15715. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15716. /** @hidden */
  15717. export var kernelBlurVertex: {
  15718. name: string;
  15719. shader: string;
  15720. };
  15721. }
  15722. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15723. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15724. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15725. /** @hidden */
  15726. export var kernelBlurVertexShader: {
  15727. name: string;
  15728. shader: string;
  15729. };
  15730. }
  15731. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15732. import { Vector2 } from "babylonjs/Maths/math.vector";
  15733. import { Nullable } from "babylonjs/types";
  15734. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15735. import { Camera } from "babylonjs/Cameras/camera";
  15736. import { Effect } from "babylonjs/Materials/effect";
  15737. import { Engine } from "babylonjs/Engines/engine";
  15738. import "babylonjs/Shaders/kernelBlur.fragment";
  15739. import "babylonjs/Shaders/kernelBlur.vertex";
  15740. /**
  15741. * The Blur Post Process which blurs an image based on a kernel and direction.
  15742. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15743. */
  15744. export class BlurPostProcess extends PostProcess {
  15745. /** The direction in which to blur the image. */
  15746. direction: Vector2;
  15747. private blockCompilation;
  15748. protected _kernel: number;
  15749. protected _idealKernel: number;
  15750. protected _packedFloat: boolean;
  15751. private _staticDefines;
  15752. /**
  15753. * Sets the length in pixels of the blur sample region
  15754. */
  15755. /**
  15756. * Gets the length in pixels of the blur sample region
  15757. */
  15758. kernel: number;
  15759. /**
  15760. * Sets wether or not the blur needs to unpack/repack floats
  15761. */
  15762. /**
  15763. * Gets wether or not the blur is unpacking/repacking floats
  15764. */
  15765. packedFloat: boolean;
  15766. /**
  15767. * Creates a new instance BlurPostProcess
  15768. * @param name The name of the effect.
  15769. * @param direction The direction in which to blur the image.
  15770. * @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.
  15771. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15772. * @param camera The camera to apply the render pass to.
  15773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15774. * @param engine The engine which the post process will be applied. (default: current engine)
  15775. * @param reusable If the post process can be reused on the same frame. (default: false)
  15776. * @param textureType Type of textures used when performing the post process. (default: 0)
  15777. * @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)
  15778. */
  15779. constructor(name: string,
  15780. /** The direction in which to blur the image. */
  15781. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15782. /**
  15783. * Updates the effect with the current post process compile time values and recompiles the shader.
  15784. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15785. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15786. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15787. * @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
  15788. * @param onCompiled Called when the shader has been compiled.
  15789. * @param onError Called if there is an error when compiling a shader.
  15790. */
  15791. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15792. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15793. /**
  15794. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15795. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15796. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15797. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15798. * The gaps between physical kernels are compensated for in the weighting of the samples
  15799. * @param idealKernel Ideal blur kernel.
  15800. * @return Nearest best kernel.
  15801. */
  15802. protected _nearestBestKernel(idealKernel: number): number;
  15803. /**
  15804. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15805. * @param x The point on the Gaussian distribution to sample.
  15806. * @return the value of the Gaussian function at x.
  15807. */
  15808. protected _gaussianWeight(x: number): number;
  15809. /**
  15810. * Generates a string that can be used as a floating point number in GLSL.
  15811. * @param x Value to print.
  15812. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15813. * @return GLSL float string.
  15814. */
  15815. protected _glslFloat(x: number, decimalFigures?: number): string;
  15816. }
  15817. }
  15818. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15819. import { Scene } from "babylonjs/scene";
  15820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15821. import { Plane } from "babylonjs/Maths/math.plane";
  15822. /**
  15823. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15824. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15825. * You can then easily use it as a reflectionTexture on a flat surface.
  15826. * In case the surface is not a plane, please consider relying on reflection probes.
  15827. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15828. */
  15829. export class MirrorTexture extends RenderTargetTexture {
  15830. private scene;
  15831. /**
  15832. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15833. * 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.
  15834. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15835. */
  15836. mirrorPlane: Plane;
  15837. /**
  15838. * Define the blur ratio used to blur the reflection if needed.
  15839. */
  15840. blurRatio: number;
  15841. /**
  15842. * Define the adaptive blur kernel used to blur the reflection if needed.
  15843. * This will autocompute the closest best match for the `blurKernel`
  15844. */
  15845. adaptiveBlurKernel: number;
  15846. /**
  15847. * Define the blur kernel used to blur the reflection if needed.
  15848. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15849. */
  15850. blurKernel: number;
  15851. /**
  15852. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15853. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15854. */
  15855. blurKernelX: number;
  15856. /**
  15857. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15858. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15859. */
  15860. blurKernelY: number;
  15861. private _autoComputeBlurKernel;
  15862. protected _onRatioRescale(): void;
  15863. private _updateGammaSpace;
  15864. private _imageProcessingConfigChangeObserver;
  15865. private _transformMatrix;
  15866. private _mirrorMatrix;
  15867. private _savedViewMatrix;
  15868. private _blurX;
  15869. private _blurY;
  15870. private _adaptiveBlurKernel;
  15871. private _blurKernelX;
  15872. private _blurKernelY;
  15873. private _blurRatio;
  15874. /**
  15875. * Instantiates a Mirror Texture.
  15876. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15877. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15878. * You can then easily use it as a reflectionTexture on a flat surface.
  15879. * In case the surface is not a plane, please consider relying on reflection probes.
  15880. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15881. * @param name
  15882. * @param size
  15883. * @param scene
  15884. * @param generateMipMaps
  15885. * @param type
  15886. * @param samplingMode
  15887. * @param generateDepthBuffer
  15888. */
  15889. constructor(name: string, size: number | {
  15890. width: number;
  15891. height: number;
  15892. } | {
  15893. ratio: number;
  15894. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15895. private _preparePostProcesses;
  15896. /**
  15897. * Clone the mirror texture.
  15898. * @returns the cloned texture
  15899. */
  15900. clone(): MirrorTexture;
  15901. /**
  15902. * Serialize the texture to a JSON representation you could use in Parse later on
  15903. * @returns the serialized JSON representation
  15904. */
  15905. serialize(): any;
  15906. /**
  15907. * Dispose the texture and release its associated resources.
  15908. */
  15909. dispose(): void;
  15910. }
  15911. }
  15912. declare module "babylonjs/Materials/Textures/texture" {
  15913. import { Observable } from "babylonjs/Misc/observable";
  15914. import { Nullable } from "babylonjs/types";
  15915. import { Scene } from "babylonjs/scene";
  15916. import { Matrix } from "babylonjs/Maths/math.vector";
  15917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15918. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15919. import { Engine } from "babylonjs/Engines/engine";
  15920. /**
  15921. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15922. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15923. */
  15924. export class Texture extends BaseTexture {
  15925. /** @hidden */
  15926. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15927. /** @hidden */
  15928. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15929. /** @hidden */
  15930. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15931. /** nearest is mag = nearest and min = nearest and mip = linear */
  15932. static readonly NEAREST_SAMPLINGMODE: number;
  15933. /** nearest is mag = nearest and min = nearest and mip = linear */
  15934. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15935. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15936. static readonly BILINEAR_SAMPLINGMODE: number;
  15937. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15938. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15939. /** Trilinear is mag = linear and min = linear and mip = linear */
  15940. static readonly TRILINEAR_SAMPLINGMODE: number;
  15941. /** Trilinear is mag = linear and min = linear and mip = linear */
  15942. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15943. /** mag = nearest and min = nearest and mip = nearest */
  15944. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15945. /** mag = nearest and min = linear and mip = nearest */
  15946. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15947. /** mag = nearest and min = linear and mip = linear */
  15948. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15949. /** mag = nearest and min = linear and mip = none */
  15950. static readonly NEAREST_LINEAR: number;
  15951. /** mag = nearest and min = nearest and mip = none */
  15952. static readonly NEAREST_NEAREST: number;
  15953. /** mag = linear and min = nearest and mip = nearest */
  15954. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15955. /** mag = linear and min = nearest and mip = linear */
  15956. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15957. /** mag = linear and min = linear and mip = none */
  15958. static readonly LINEAR_LINEAR: number;
  15959. /** mag = linear and min = nearest and mip = none */
  15960. static readonly LINEAR_NEAREST: number;
  15961. /** Explicit coordinates mode */
  15962. static readonly EXPLICIT_MODE: number;
  15963. /** Spherical coordinates mode */
  15964. static readonly SPHERICAL_MODE: number;
  15965. /** Planar coordinates mode */
  15966. static readonly PLANAR_MODE: number;
  15967. /** Cubic coordinates mode */
  15968. static readonly CUBIC_MODE: number;
  15969. /** Projection coordinates mode */
  15970. static readonly PROJECTION_MODE: number;
  15971. /** Inverse Cubic coordinates mode */
  15972. static readonly SKYBOX_MODE: number;
  15973. /** Inverse Cubic coordinates mode */
  15974. static readonly INVCUBIC_MODE: number;
  15975. /** Equirectangular coordinates mode */
  15976. static readonly EQUIRECTANGULAR_MODE: number;
  15977. /** Equirectangular Fixed coordinates mode */
  15978. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15979. /** Equirectangular Fixed Mirrored coordinates mode */
  15980. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15981. /** Texture is not repeating outside of 0..1 UVs */
  15982. static readonly CLAMP_ADDRESSMODE: number;
  15983. /** Texture is repeating outside of 0..1 UVs */
  15984. static readonly WRAP_ADDRESSMODE: number;
  15985. /** Texture is repeating and mirrored */
  15986. static readonly MIRROR_ADDRESSMODE: number;
  15987. /**
  15988. * 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
  15989. */
  15990. static UseSerializedUrlIfAny: boolean;
  15991. /**
  15992. * Define the url of the texture.
  15993. */
  15994. url: Nullable<string>;
  15995. /**
  15996. * Define an offset on the texture to offset the u coordinates of the UVs
  15997. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15998. */
  15999. uOffset: number;
  16000. /**
  16001. * Define an offset on the texture to offset the v coordinates of the UVs
  16002. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16003. */
  16004. vOffset: number;
  16005. /**
  16006. * Define an offset on the texture to scale the u coordinates of the UVs
  16007. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16008. */
  16009. uScale: number;
  16010. /**
  16011. * Define an offset on the texture to scale the v coordinates of the UVs
  16012. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16013. */
  16014. vScale: number;
  16015. /**
  16016. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16017. * @see http://doc.babylonjs.com/how_to/more_materials
  16018. */
  16019. uAng: number;
  16020. /**
  16021. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials
  16023. */
  16024. vAng: number;
  16025. /**
  16026. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16027. * @see http://doc.babylonjs.com/how_to/more_materials
  16028. */
  16029. wAng: number;
  16030. /**
  16031. * Defines the center of rotation (U)
  16032. */
  16033. uRotationCenter: number;
  16034. /**
  16035. * Defines the center of rotation (V)
  16036. */
  16037. vRotationCenter: number;
  16038. /**
  16039. * Defines the center of rotation (W)
  16040. */
  16041. wRotationCenter: number;
  16042. /**
  16043. * Are mip maps generated for this texture or not.
  16044. */
  16045. readonly noMipmap: boolean;
  16046. /**
  16047. * List of inspectable custom properties (used by the Inspector)
  16048. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16049. */
  16050. inspectableCustomProperties: Nullable<IInspectable[]>;
  16051. private _noMipmap;
  16052. /** @hidden */
  16053. _invertY: boolean;
  16054. private _rowGenerationMatrix;
  16055. private _cachedTextureMatrix;
  16056. private _projectionModeMatrix;
  16057. private _t0;
  16058. private _t1;
  16059. private _t2;
  16060. private _cachedUOffset;
  16061. private _cachedVOffset;
  16062. private _cachedUScale;
  16063. private _cachedVScale;
  16064. private _cachedUAng;
  16065. private _cachedVAng;
  16066. private _cachedWAng;
  16067. private _cachedProjectionMatrixId;
  16068. private _cachedCoordinatesMode;
  16069. /** @hidden */
  16070. protected _initialSamplingMode: number;
  16071. /** @hidden */
  16072. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16073. private _deleteBuffer;
  16074. protected _format: Nullable<number>;
  16075. private _delayedOnLoad;
  16076. private _delayedOnError;
  16077. /**
  16078. * Observable triggered once the texture has been loaded.
  16079. */
  16080. onLoadObservable: Observable<Texture>;
  16081. protected _isBlocking: boolean;
  16082. /**
  16083. * Is the texture preventing material to render while loading.
  16084. * If false, a default texture will be used instead of the loading one during the preparation step.
  16085. */
  16086. isBlocking: boolean;
  16087. /**
  16088. * Get the current sampling mode associated with the texture.
  16089. */
  16090. readonly samplingMode: number;
  16091. /**
  16092. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16093. */
  16094. readonly invertY: boolean;
  16095. /**
  16096. * Instantiates a new texture.
  16097. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16098. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16099. * @param url define the url of the picture to load as a texture
  16100. * @param scene define the scene or engine the texture will belong to
  16101. * @param noMipmap define if the texture will require mip maps or not
  16102. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16103. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16104. * @param onLoad define a callback triggered when the texture has been loaded
  16105. * @param onError define a callback triggered when an error occurred during the loading session
  16106. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16107. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16108. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16109. */
  16110. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16111. /**
  16112. * Update the url (and optional buffer) of this texture if url was null during construction.
  16113. * @param url the url of the texture
  16114. * @param buffer the buffer of the texture (defaults to null)
  16115. * @param onLoad callback called when the texture is loaded (defaults to null)
  16116. */
  16117. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16118. /**
  16119. * Finish the loading sequence of a texture flagged as delayed load.
  16120. * @hidden
  16121. */
  16122. delayLoad(): void;
  16123. private _prepareRowForTextureGeneration;
  16124. /**
  16125. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16126. * @returns the transform matrix of the texture.
  16127. */
  16128. getTextureMatrix(): Matrix;
  16129. /**
  16130. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16131. * @returns The reflection texture transform
  16132. */
  16133. getReflectionTextureMatrix(): Matrix;
  16134. /**
  16135. * Clones the texture.
  16136. * @returns the cloned texture
  16137. */
  16138. clone(): Texture;
  16139. /**
  16140. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16141. * @returns The JSON representation of the texture
  16142. */
  16143. serialize(): any;
  16144. /**
  16145. * Get the current class name of the texture useful for serialization or dynamic coding.
  16146. * @returns "Texture"
  16147. */
  16148. getClassName(): string;
  16149. /**
  16150. * Dispose the texture and release its associated resources.
  16151. */
  16152. dispose(): void;
  16153. /**
  16154. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16155. * @param parsedTexture Define the JSON representation of the texture
  16156. * @param scene Define the scene the parsed texture should be instantiated in
  16157. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16158. * @returns The parsed texture if successful
  16159. */
  16160. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16161. /**
  16162. * Creates a texture from its base 64 representation.
  16163. * @param data Define the base64 payload without the data: prefix
  16164. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16165. * @param scene Define the scene the texture should belong to
  16166. * @param noMipmap Forces the texture to not create mip map information if true
  16167. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16168. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16169. * @param onLoad define a callback triggered when the texture has been loaded
  16170. * @param onError define a callback triggered when an error occurred during the loading session
  16171. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16172. * @returns the created texture
  16173. */
  16174. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16175. /**
  16176. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16177. * @param data Define the base64 payload without the data: prefix
  16178. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16179. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16180. * @param scene Define the scene the texture should belong to
  16181. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16182. * @param noMipmap Forces the texture to not create mip map information if true
  16183. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16184. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16185. * @param onLoad define a callback triggered when the texture has been loaded
  16186. * @param onError define a callback triggered when an error occurred during the loading session
  16187. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16188. * @returns the created texture
  16189. */
  16190. 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;
  16191. }
  16192. }
  16193. declare module "babylonjs/PostProcesses/postProcessManager" {
  16194. import { Nullable } from "babylonjs/types";
  16195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16196. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16197. import { Scene } from "babylonjs/scene";
  16198. /**
  16199. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16200. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16201. */
  16202. export class PostProcessManager {
  16203. private _scene;
  16204. private _indexBuffer;
  16205. private _vertexBuffers;
  16206. /**
  16207. * Creates a new instance PostProcess
  16208. * @param scene The scene that the post process is associated with.
  16209. */
  16210. constructor(scene: Scene);
  16211. private _prepareBuffers;
  16212. private _buildIndexBuffer;
  16213. /**
  16214. * Rebuilds the vertex buffers of the manager.
  16215. * @hidden
  16216. */
  16217. _rebuild(): void;
  16218. /**
  16219. * Prepares a frame to be run through a post process.
  16220. * @param sourceTexture The input texture to the post procesess. (default: null)
  16221. * @param postProcesses An array of post processes to be run. (default: null)
  16222. * @returns True if the post processes were able to be run.
  16223. * @hidden
  16224. */
  16225. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16226. /**
  16227. * Manually render a set of post processes to a texture.
  16228. * @param postProcesses An array of post processes to be run.
  16229. * @param targetTexture The target texture to render to.
  16230. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16231. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16232. * @param lodLevel defines which lod of the texture to render to
  16233. */
  16234. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16235. /**
  16236. * Finalize the result of the output of the postprocesses.
  16237. * @param doNotPresent If true the result will not be displayed to the screen.
  16238. * @param targetTexture The target texture to render to.
  16239. * @param faceIndex The index of the face to bind the target texture to.
  16240. * @param postProcesses The array of post processes to render.
  16241. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16242. * @hidden
  16243. */
  16244. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16245. /**
  16246. * Disposes of the post process manager.
  16247. */
  16248. dispose(): void;
  16249. }
  16250. }
  16251. declare module "babylonjs/Misc/gradients" {
  16252. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16253. /** Interface used by value gradients (color, factor, ...) */
  16254. export interface IValueGradient {
  16255. /**
  16256. * Gets or sets the gradient value (between 0 and 1)
  16257. */
  16258. gradient: number;
  16259. }
  16260. /** Class used to store color4 gradient */
  16261. export class ColorGradient implements IValueGradient {
  16262. /**
  16263. * Gets or sets the gradient value (between 0 and 1)
  16264. */
  16265. gradient: number;
  16266. /**
  16267. * Gets or sets first associated color
  16268. */
  16269. color1: Color4;
  16270. /**
  16271. * Gets or sets second associated color
  16272. */
  16273. color2?: Color4;
  16274. /**
  16275. * Will get a color picked randomly between color1 and color2.
  16276. * If color2 is undefined then color1 will be used
  16277. * @param result defines the target Color4 to store the result in
  16278. */
  16279. getColorToRef(result: Color4): void;
  16280. }
  16281. /** Class used to store color 3 gradient */
  16282. export class Color3Gradient implements IValueGradient {
  16283. /**
  16284. * Gets or sets the gradient value (between 0 and 1)
  16285. */
  16286. gradient: number;
  16287. /**
  16288. * Gets or sets the associated color
  16289. */
  16290. color: Color3;
  16291. }
  16292. /** Class used to store factor gradient */
  16293. export class FactorGradient implements IValueGradient {
  16294. /**
  16295. * Gets or sets the gradient value (between 0 and 1)
  16296. */
  16297. gradient: number;
  16298. /**
  16299. * Gets or sets first associated factor
  16300. */
  16301. factor1: number;
  16302. /**
  16303. * Gets or sets second associated factor
  16304. */
  16305. factor2?: number;
  16306. /**
  16307. * Will get a number picked randomly between factor1 and factor2.
  16308. * If factor2 is undefined then factor1 will be used
  16309. * @returns the picked number
  16310. */
  16311. getFactor(): number;
  16312. }
  16313. /**
  16314. * Helper used to simplify some generic gradient tasks
  16315. */
  16316. export class GradientHelper {
  16317. /**
  16318. * Gets the current gradient from an array of IValueGradient
  16319. * @param ratio defines the current ratio to get
  16320. * @param gradients defines the array of IValueGradient
  16321. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16322. */
  16323. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16324. }
  16325. }
  16326. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16327. import { Scene } from "babylonjs/scene";
  16328. import { ISceneComponent } from "babylonjs/sceneComponent";
  16329. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16330. module "babylonjs/abstractScene" {
  16331. interface AbstractScene {
  16332. /**
  16333. * The list of procedural textures added to the scene
  16334. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16335. */
  16336. proceduralTextures: Array<ProceduralTexture>;
  16337. }
  16338. }
  16339. /**
  16340. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16341. * in a given scene.
  16342. */
  16343. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16344. /**
  16345. * The component name helpfull to identify the component in the list of scene components.
  16346. */
  16347. readonly name: string;
  16348. /**
  16349. * The scene the component belongs to.
  16350. */
  16351. scene: Scene;
  16352. /**
  16353. * Creates a new instance of the component for the given scene
  16354. * @param scene Defines the scene to register the component in
  16355. */
  16356. constructor(scene: Scene);
  16357. /**
  16358. * Registers the component in a given scene
  16359. */
  16360. register(): void;
  16361. /**
  16362. * Rebuilds the elements related to this component in case of
  16363. * context lost for instance.
  16364. */
  16365. rebuild(): void;
  16366. /**
  16367. * Disposes the component and the associated ressources.
  16368. */
  16369. dispose(): void;
  16370. private _beforeClear;
  16371. }
  16372. }
  16373. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16375. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16376. module "babylonjs/Engines/engine" {
  16377. interface Engine {
  16378. /**
  16379. * Creates a new render target cube texture
  16380. * @param size defines the size of the texture
  16381. * @param options defines the options used to create the texture
  16382. * @returns a new render target cube texture stored in an InternalTexture
  16383. */
  16384. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16385. }
  16386. }
  16387. }
  16388. declare module "babylonjs/Shaders/procedural.vertex" {
  16389. /** @hidden */
  16390. export var proceduralVertexShader: {
  16391. name: string;
  16392. shader: string;
  16393. };
  16394. }
  16395. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16396. import { Observable } from "babylonjs/Misc/observable";
  16397. import { Nullable } from "babylonjs/types";
  16398. import { Scene } from "babylonjs/scene";
  16399. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16400. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16401. import { Effect } from "babylonjs/Materials/effect";
  16402. import { Texture } from "babylonjs/Materials/Textures/texture";
  16403. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16404. import "babylonjs/Shaders/procedural.vertex";
  16405. /**
  16406. * 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.
  16407. * This is the base class of any Procedural texture and contains most of the shareable code.
  16408. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16409. */
  16410. export class ProceduralTexture extends Texture {
  16411. isCube: boolean;
  16412. /**
  16413. * Define if the texture is enabled or not (disabled texture will not render)
  16414. */
  16415. isEnabled: boolean;
  16416. /**
  16417. * Define if the texture must be cleared before rendering (default is true)
  16418. */
  16419. autoClear: boolean;
  16420. /**
  16421. * Callback called when the texture is generated
  16422. */
  16423. onGenerated: () => void;
  16424. /**
  16425. * Event raised when the texture is generated
  16426. */
  16427. onGeneratedObservable: Observable<ProceduralTexture>;
  16428. /** @hidden */
  16429. _generateMipMaps: boolean;
  16430. /** @hidden **/
  16431. _effect: Effect;
  16432. /** @hidden */
  16433. _textures: {
  16434. [key: string]: Texture;
  16435. };
  16436. private _size;
  16437. private _currentRefreshId;
  16438. private _refreshRate;
  16439. private _vertexBuffers;
  16440. private _indexBuffer;
  16441. private _uniforms;
  16442. private _samplers;
  16443. private _fragment;
  16444. private _floats;
  16445. private _ints;
  16446. private _floatsArrays;
  16447. private _colors3;
  16448. private _colors4;
  16449. private _vectors2;
  16450. private _vectors3;
  16451. private _matrices;
  16452. private _fallbackTexture;
  16453. private _fallbackTextureUsed;
  16454. private _engine;
  16455. private _cachedDefines;
  16456. private _contentUpdateId;
  16457. private _contentData;
  16458. /**
  16459. * Instantiates a new procedural texture.
  16460. * 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.
  16461. * This is the base class of any Procedural texture and contains most of the shareable code.
  16462. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16463. * @param name Define the name of the texture
  16464. * @param size Define the size of the texture to create
  16465. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16466. * @param scene Define the scene the texture belongs to
  16467. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16468. * @param generateMipMaps Define if the texture should creates mip maps or not
  16469. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16470. */
  16471. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16472. /**
  16473. * The effect that is created when initializing the post process.
  16474. * @returns The created effect corresponding the the postprocess.
  16475. */
  16476. getEffect(): Effect;
  16477. /**
  16478. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16479. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16480. */
  16481. getContent(): Nullable<ArrayBufferView>;
  16482. private _createIndexBuffer;
  16483. /** @hidden */
  16484. _rebuild(): void;
  16485. /**
  16486. * Resets the texture in order to recreate its associated resources.
  16487. * This can be called in case of context loss
  16488. */
  16489. reset(): void;
  16490. protected _getDefines(): string;
  16491. /**
  16492. * Is the texture ready to be used ? (rendered at least once)
  16493. * @returns true if ready, otherwise, false.
  16494. */
  16495. isReady(): boolean;
  16496. /**
  16497. * Resets the refresh counter of the texture and start bak from scratch.
  16498. * Could be useful to regenerate the texture if it is setup to render only once.
  16499. */
  16500. resetRefreshCounter(): void;
  16501. /**
  16502. * Set the fragment shader to use in order to render the texture.
  16503. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16504. */
  16505. setFragment(fragment: any): void;
  16506. /**
  16507. * Define the refresh rate of the texture or the rendering frequency.
  16508. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16509. */
  16510. refreshRate: number;
  16511. /** @hidden */
  16512. _shouldRender(): boolean;
  16513. /**
  16514. * Get the size the texture is rendering at.
  16515. * @returns the size (texture is always squared)
  16516. */
  16517. getRenderSize(): number;
  16518. /**
  16519. * Resize the texture to new value.
  16520. * @param size Define the new size the texture should have
  16521. * @param generateMipMaps Define whether the new texture should create mip maps
  16522. */
  16523. resize(size: number, generateMipMaps: boolean): void;
  16524. private _checkUniform;
  16525. /**
  16526. * Set a texture in the shader program used to render.
  16527. * @param name Define the name of the uniform samplers as defined in the shader
  16528. * @param texture Define the texture to bind to this sampler
  16529. * @return the texture itself allowing "fluent" like uniform updates
  16530. */
  16531. setTexture(name: string, texture: Texture): ProceduralTexture;
  16532. /**
  16533. * Set a float in the shader.
  16534. * @param name Define the name of the uniform as defined in the shader
  16535. * @param value Define the value to give to the uniform
  16536. * @return the texture itself allowing "fluent" like uniform updates
  16537. */
  16538. setFloat(name: string, value: number): ProceduralTexture;
  16539. /**
  16540. * Set a int in the shader.
  16541. * @param name Define the name of the uniform as defined in the shader
  16542. * @param value Define the value to give to the uniform
  16543. * @return the texture itself allowing "fluent" like uniform updates
  16544. */
  16545. setInt(name: string, value: number): ProceduralTexture;
  16546. /**
  16547. * Set an array of floats in the shader.
  16548. * @param name Define the name of the uniform as defined in the shader
  16549. * @param value Define the value to give to the uniform
  16550. * @return the texture itself allowing "fluent" like uniform updates
  16551. */
  16552. setFloats(name: string, value: number[]): ProceduralTexture;
  16553. /**
  16554. * Set a vec3 in the shader from a Color3.
  16555. * @param name Define the name of the uniform as defined in the shader
  16556. * @param value Define the value to give to the uniform
  16557. * @return the texture itself allowing "fluent" like uniform updates
  16558. */
  16559. setColor3(name: string, value: Color3): ProceduralTexture;
  16560. /**
  16561. * Set a vec4 in the shader from a Color4.
  16562. * @param name Define the name of the uniform as defined in the shader
  16563. * @param value Define the value to give to the uniform
  16564. * @return the texture itself allowing "fluent" like uniform updates
  16565. */
  16566. setColor4(name: string, value: Color4): ProceduralTexture;
  16567. /**
  16568. * Set a vec2 in the shader from a Vector2.
  16569. * @param name Define the name of the uniform as defined in the shader
  16570. * @param value Define the value to give to the uniform
  16571. * @return the texture itself allowing "fluent" like uniform updates
  16572. */
  16573. setVector2(name: string, value: Vector2): ProceduralTexture;
  16574. /**
  16575. * Set a vec3 in the shader from a Vector3.
  16576. * @param name Define the name of the uniform as defined in the shader
  16577. * @param value Define the value to give to the uniform
  16578. * @return the texture itself allowing "fluent" like uniform updates
  16579. */
  16580. setVector3(name: string, value: Vector3): ProceduralTexture;
  16581. /**
  16582. * Set a mat4 in the shader from a MAtrix.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the texture itself allowing "fluent" like uniform updates
  16586. */
  16587. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16588. /**
  16589. * Render the texture to its associated render target.
  16590. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16591. */
  16592. render(useCameraPostProcess?: boolean): void;
  16593. /**
  16594. * Clone the texture.
  16595. * @returns the cloned texture
  16596. */
  16597. clone(): ProceduralTexture;
  16598. /**
  16599. * Dispose the texture and release its asoociated resources.
  16600. */
  16601. dispose(): void;
  16602. }
  16603. }
  16604. declare module "babylonjs/Particles/baseParticleSystem" {
  16605. import { Nullable } from "babylonjs/types";
  16606. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16608. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16609. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16610. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16611. import { Scene } from "babylonjs/scene";
  16612. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16613. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16614. import { Texture } from "babylonjs/Materials/Textures/texture";
  16615. import { Color4 } from "babylonjs/Maths/math.color";
  16616. import { Animation } from "babylonjs/Animations/animation";
  16617. /**
  16618. * This represents the base class for particle system in Babylon.
  16619. * 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.
  16620. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16621. * @example https://doc.babylonjs.com/babylon101/particles
  16622. */
  16623. export class BaseParticleSystem {
  16624. /**
  16625. * Source color is added to the destination color without alpha affecting the result
  16626. */
  16627. static BLENDMODE_ONEONE: number;
  16628. /**
  16629. * Blend current color and particle color using particle’s alpha
  16630. */
  16631. static BLENDMODE_STANDARD: number;
  16632. /**
  16633. * Add current color and particle color multiplied by particle’s alpha
  16634. */
  16635. static BLENDMODE_ADD: number;
  16636. /**
  16637. * Multiply current color with particle color
  16638. */
  16639. static BLENDMODE_MULTIPLY: number;
  16640. /**
  16641. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16642. */
  16643. static BLENDMODE_MULTIPLYADD: number;
  16644. /**
  16645. * List of animations used by the particle system.
  16646. */
  16647. animations: Animation[];
  16648. /**
  16649. * The id of the Particle system.
  16650. */
  16651. id: string;
  16652. /**
  16653. * The friendly name of the Particle system.
  16654. */
  16655. name: string;
  16656. /**
  16657. * The rendering group used by the Particle system to chose when to render.
  16658. */
  16659. renderingGroupId: number;
  16660. /**
  16661. * The emitter represents the Mesh or position we are attaching the particle system to.
  16662. */
  16663. emitter: Nullable<AbstractMesh | Vector3>;
  16664. /**
  16665. * The maximum number of particles to emit per frame
  16666. */
  16667. emitRate: number;
  16668. /**
  16669. * If you want to launch only a few particles at once, that can be done, as well.
  16670. */
  16671. manualEmitCount: number;
  16672. /**
  16673. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16674. */
  16675. updateSpeed: number;
  16676. /**
  16677. * The amount of time the particle system is running (depends of the overall update speed).
  16678. */
  16679. targetStopDuration: number;
  16680. /**
  16681. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16682. */
  16683. disposeOnStop: boolean;
  16684. /**
  16685. * Minimum power of emitting particles.
  16686. */
  16687. minEmitPower: number;
  16688. /**
  16689. * Maximum power of emitting particles.
  16690. */
  16691. maxEmitPower: number;
  16692. /**
  16693. * Minimum life time of emitting particles.
  16694. */
  16695. minLifeTime: number;
  16696. /**
  16697. * Maximum life time of emitting particles.
  16698. */
  16699. maxLifeTime: number;
  16700. /**
  16701. * Minimum Size of emitting particles.
  16702. */
  16703. minSize: number;
  16704. /**
  16705. * Maximum Size of emitting particles.
  16706. */
  16707. maxSize: number;
  16708. /**
  16709. * Minimum scale of emitting particles on X axis.
  16710. */
  16711. minScaleX: number;
  16712. /**
  16713. * Maximum scale of emitting particles on X axis.
  16714. */
  16715. maxScaleX: number;
  16716. /**
  16717. * Minimum scale of emitting particles on Y axis.
  16718. */
  16719. minScaleY: number;
  16720. /**
  16721. * Maximum scale of emitting particles on Y axis.
  16722. */
  16723. maxScaleY: number;
  16724. /**
  16725. * Gets or sets the minimal initial rotation in radians.
  16726. */
  16727. minInitialRotation: number;
  16728. /**
  16729. * Gets or sets the maximal initial rotation in radians.
  16730. */
  16731. maxInitialRotation: number;
  16732. /**
  16733. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16734. */
  16735. minAngularSpeed: number;
  16736. /**
  16737. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16738. */
  16739. maxAngularSpeed: number;
  16740. /**
  16741. * The texture used to render each particle. (this can be a spritesheet)
  16742. */
  16743. particleTexture: Nullable<Texture>;
  16744. /**
  16745. * The layer mask we are rendering the particles through.
  16746. */
  16747. layerMask: number;
  16748. /**
  16749. * This can help using your own shader to render the particle system.
  16750. * The according effect will be created
  16751. */
  16752. customShader: any;
  16753. /**
  16754. * By default particle system starts as soon as they are created. This prevents the
  16755. * automatic start to happen and let you decide when to start emitting particles.
  16756. */
  16757. preventAutoStart: boolean;
  16758. private _noiseTexture;
  16759. /**
  16760. * Gets or sets a texture used to add random noise to particle positions
  16761. */
  16762. noiseTexture: Nullable<ProceduralTexture>;
  16763. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16764. noiseStrength: Vector3;
  16765. /**
  16766. * Callback triggered when the particle animation is ending.
  16767. */
  16768. onAnimationEnd: Nullable<() => void>;
  16769. /**
  16770. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16771. */
  16772. blendMode: number;
  16773. /**
  16774. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16775. * to override the particles.
  16776. */
  16777. forceDepthWrite: boolean;
  16778. /** 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 */
  16779. preWarmCycles: number;
  16780. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16781. preWarmStepOffset: number;
  16782. /**
  16783. * 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)
  16784. */
  16785. spriteCellChangeSpeed: number;
  16786. /**
  16787. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16788. */
  16789. startSpriteCellID: number;
  16790. /**
  16791. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16792. */
  16793. endSpriteCellID: number;
  16794. /**
  16795. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16796. */
  16797. spriteCellWidth: number;
  16798. /**
  16799. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16800. */
  16801. spriteCellHeight: number;
  16802. /**
  16803. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16804. */
  16805. spriteRandomStartCell: boolean;
  16806. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16807. translationPivot: Vector2;
  16808. /** @hidden */
  16809. protected _isAnimationSheetEnabled: boolean;
  16810. /**
  16811. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16812. */
  16813. beginAnimationOnStart: boolean;
  16814. /**
  16815. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16816. */
  16817. beginAnimationFrom: number;
  16818. /**
  16819. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16820. */
  16821. beginAnimationTo: number;
  16822. /**
  16823. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16824. */
  16825. beginAnimationLoop: boolean;
  16826. /**
  16827. * Gets or sets a world offset applied to all particles
  16828. */
  16829. worldOffset: Vector3;
  16830. /**
  16831. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16832. */
  16833. isAnimationSheetEnabled: boolean;
  16834. /**
  16835. * Get hosting scene
  16836. * @returns the scene
  16837. */
  16838. getScene(): Scene;
  16839. /**
  16840. * You can use gravity if you want to give an orientation to your particles.
  16841. */
  16842. gravity: Vector3;
  16843. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16844. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16845. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16846. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16847. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16848. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16849. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16850. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16851. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16852. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16853. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16854. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16855. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16856. /**
  16857. * Defines the delay in milliseconds before starting the system (0 by default)
  16858. */
  16859. startDelay: number;
  16860. /**
  16861. * Gets the current list of drag gradients.
  16862. * You must use addDragGradient and removeDragGradient to udpate this list
  16863. * @returns the list of drag gradients
  16864. */
  16865. getDragGradients(): Nullable<Array<FactorGradient>>;
  16866. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16867. limitVelocityDamping: number;
  16868. /**
  16869. * Gets the current list of limit velocity gradients.
  16870. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16871. * @returns the list of limit velocity gradients
  16872. */
  16873. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16874. /**
  16875. * Gets the current list of color gradients.
  16876. * You must use addColorGradient and removeColorGradient to udpate this list
  16877. * @returns the list of color gradients
  16878. */
  16879. getColorGradients(): Nullable<Array<ColorGradient>>;
  16880. /**
  16881. * Gets the current list of size gradients.
  16882. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16883. * @returns the list of size gradients
  16884. */
  16885. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16886. /**
  16887. * Gets the current list of color remap gradients.
  16888. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16889. * @returns the list of color remap gradients
  16890. */
  16891. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Gets the current list of alpha remap gradients.
  16894. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16895. * @returns the list of alpha remap gradients
  16896. */
  16897. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16898. /**
  16899. * Gets the current list of life time gradients.
  16900. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16901. * @returns the list of life time gradients
  16902. */
  16903. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16904. /**
  16905. * Gets the current list of angular speed gradients.
  16906. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16907. * @returns the list of angular speed gradients
  16908. */
  16909. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16910. /**
  16911. * Gets the current list of velocity gradients.
  16912. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16913. * @returns the list of velocity gradients
  16914. */
  16915. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16916. /**
  16917. * Gets the current list of start size gradients.
  16918. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16919. * @returns the list of start size gradients
  16920. */
  16921. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16922. /**
  16923. * Gets the current list of emit rate gradients.
  16924. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16925. * @returns the list of emit rate gradients
  16926. */
  16927. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16928. /**
  16929. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16930. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16931. */
  16932. direction1: Vector3;
  16933. /**
  16934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16935. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16936. */
  16937. direction2: Vector3;
  16938. /**
  16939. * 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.
  16940. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16941. */
  16942. minEmitBox: Vector3;
  16943. /**
  16944. * 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.
  16945. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16946. */
  16947. maxEmitBox: Vector3;
  16948. /**
  16949. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16950. */
  16951. color1: Color4;
  16952. /**
  16953. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16954. */
  16955. color2: Color4;
  16956. /**
  16957. * Color the particle will have at the end of its lifetime
  16958. */
  16959. colorDead: Color4;
  16960. /**
  16961. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16962. */
  16963. textureMask: Color4;
  16964. /**
  16965. * The particle emitter type defines the emitter used by the particle system.
  16966. * It can be for example box, sphere, or cone...
  16967. */
  16968. particleEmitterType: IParticleEmitterType;
  16969. /** @hidden */
  16970. _isSubEmitter: boolean;
  16971. /**
  16972. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16973. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16974. */
  16975. billboardMode: number;
  16976. protected _isBillboardBased: boolean;
  16977. /**
  16978. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16979. */
  16980. isBillboardBased: boolean;
  16981. /**
  16982. * The scene the particle system belongs to.
  16983. */
  16984. protected _scene: Scene;
  16985. /**
  16986. * Local cache of defines for image processing.
  16987. */
  16988. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16989. /**
  16990. * Default configuration related to image processing available in the standard Material.
  16991. */
  16992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16993. /**
  16994. * Gets the image processing configuration used either in this material.
  16995. */
  16996. /**
  16997. * Sets the Default image processing configuration used either in the this material.
  16998. *
  16999. * If sets to null, the scene one is in use.
  17000. */
  17001. imageProcessingConfiguration: ImageProcessingConfiguration;
  17002. /**
  17003. * Attaches a new image processing configuration to the Standard Material.
  17004. * @param configuration
  17005. */
  17006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17007. /** @hidden */
  17008. protected _reset(): void;
  17009. /** @hidden */
  17010. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17011. /**
  17012. * Instantiates a particle system.
  17013. * 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.
  17014. * @param name The name of the particle system
  17015. */
  17016. constructor(name: string);
  17017. /**
  17018. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17019. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17020. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17021. * @returns the emitter
  17022. */
  17023. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17024. /**
  17025. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17026. * @param radius The radius of the hemisphere to emit from
  17027. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17028. * @returns the emitter
  17029. */
  17030. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17031. /**
  17032. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17033. * @param radius The radius of the sphere to emit from
  17034. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17035. * @returns the emitter
  17036. */
  17037. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17038. /**
  17039. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17040. * @param radius The radius of the sphere to emit from
  17041. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17042. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17043. * @returns the emitter
  17044. */
  17045. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17046. /**
  17047. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17048. * @param radius The radius of the emission cylinder
  17049. * @param height The height of the emission cylinder
  17050. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17051. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17052. * @returns the emitter
  17053. */
  17054. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17055. /**
  17056. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17057. * @param radius The radius of the cylinder to emit from
  17058. * @param height The height of the emission cylinder
  17059. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17060. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17061. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17062. * @returns the emitter
  17063. */
  17064. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17065. /**
  17066. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17067. * @param radius The radius of the cone to emit from
  17068. * @param angle The base angle of the cone
  17069. * @returns the emitter
  17070. */
  17071. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17072. /**
  17073. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17074. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17075. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17076. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17077. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17078. * @returns the emitter
  17079. */
  17080. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17081. }
  17082. }
  17083. declare module "babylonjs/Particles/subEmitter" {
  17084. import { Scene } from "babylonjs/scene";
  17085. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17086. /**
  17087. * Type of sub emitter
  17088. */
  17089. export enum SubEmitterType {
  17090. /**
  17091. * Attached to the particle over it's lifetime
  17092. */
  17093. ATTACHED = 0,
  17094. /**
  17095. * Created when the particle dies
  17096. */
  17097. END = 1
  17098. }
  17099. /**
  17100. * Sub emitter class used to emit particles from an existing particle
  17101. */
  17102. export class SubEmitter {
  17103. /**
  17104. * the particle system to be used by the sub emitter
  17105. */
  17106. particleSystem: ParticleSystem;
  17107. /**
  17108. * Type of the submitter (Default: END)
  17109. */
  17110. type: SubEmitterType;
  17111. /**
  17112. * 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)
  17113. * Note: This only is supported when using an emitter of type Mesh
  17114. */
  17115. inheritDirection: boolean;
  17116. /**
  17117. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17118. */
  17119. inheritedVelocityAmount: number;
  17120. /**
  17121. * Creates a sub emitter
  17122. * @param particleSystem the particle system to be used by the sub emitter
  17123. */
  17124. constructor(
  17125. /**
  17126. * the particle system to be used by the sub emitter
  17127. */
  17128. particleSystem: ParticleSystem);
  17129. /**
  17130. * Clones the sub emitter
  17131. * @returns the cloned sub emitter
  17132. */
  17133. clone(): SubEmitter;
  17134. /**
  17135. * Serialize current object to a JSON object
  17136. * @returns the serialized object
  17137. */
  17138. serialize(): any;
  17139. /** @hidden */
  17140. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17141. /**
  17142. * Creates a new SubEmitter from a serialized JSON version
  17143. * @param serializationObject defines the JSON object to read from
  17144. * @param scene defines the hosting scene
  17145. * @param rootUrl defines the rootUrl for data loading
  17146. * @returns a new SubEmitter
  17147. */
  17148. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17149. /** Release associated resources */
  17150. dispose(): void;
  17151. }
  17152. }
  17153. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17154. /** @hidden */
  17155. export var clipPlaneFragmentDeclaration: {
  17156. name: string;
  17157. shader: string;
  17158. };
  17159. }
  17160. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17161. /** @hidden */
  17162. export var imageProcessingDeclaration: {
  17163. name: string;
  17164. shader: string;
  17165. };
  17166. }
  17167. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17168. /** @hidden */
  17169. export var imageProcessingFunctions: {
  17170. name: string;
  17171. shader: string;
  17172. };
  17173. }
  17174. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17175. /** @hidden */
  17176. export var clipPlaneFragment: {
  17177. name: string;
  17178. shader: string;
  17179. };
  17180. }
  17181. declare module "babylonjs/Shaders/particles.fragment" {
  17182. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17183. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17184. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17186. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17187. /** @hidden */
  17188. export var particlesPixelShader: {
  17189. name: string;
  17190. shader: string;
  17191. };
  17192. }
  17193. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17194. /** @hidden */
  17195. export var clipPlaneVertexDeclaration: {
  17196. name: string;
  17197. shader: string;
  17198. };
  17199. }
  17200. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17201. /** @hidden */
  17202. export var clipPlaneVertex: {
  17203. name: string;
  17204. shader: string;
  17205. };
  17206. }
  17207. declare module "babylonjs/Shaders/particles.vertex" {
  17208. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17209. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17210. /** @hidden */
  17211. export var particlesVertexShader: {
  17212. name: string;
  17213. shader: string;
  17214. };
  17215. }
  17216. declare module "babylonjs/Particles/particleSystem" {
  17217. import { Nullable } from "babylonjs/types";
  17218. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17219. import { Observable } from "babylonjs/Misc/observable";
  17220. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17221. import { Effect } from "babylonjs/Materials/effect";
  17222. import { Scene, IDisposable } from "babylonjs/scene";
  17223. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17224. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17225. import { Particle } from "babylonjs/Particles/particle";
  17226. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17227. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17228. import "babylonjs/Shaders/particles.fragment";
  17229. import "babylonjs/Shaders/particles.vertex";
  17230. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17231. /**
  17232. * This represents a particle system in Babylon.
  17233. * 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.
  17234. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17235. * @example https://doc.babylonjs.com/babylon101/particles
  17236. */
  17237. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17238. /**
  17239. * Billboard mode will only apply to Y axis
  17240. */
  17241. static readonly BILLBOARDMODE_Y: number;
  17242. /**
  17243. * Billboard mode will apply to all axes
  17244. */
  17245. static readonly BILLBOARDMODE_ALL: number;
  17246. /**
  17247. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17248. */
  17249. static readonly BILLBOARDMODE_STRETCHED: number;
  17250. /**
  17251. * This function can be defined to provide custom update for active particles.
  17252. * This function will be called instead of regular update (age, position, color, etc.).
  17253. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17254. */
  17255. updateFunction: (particles: Particle[]) => void;
  17256. private _emitterWorldMatrix;
  17257. /**
  17258. * This function can be defined to specify initial direction for every new particle.
  17259. * It by default use the emitterType defined function
  17260. */
  17261. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17262. /**
  17263. * This function can be defined to specify initial position for every new particle.
  17264. * It by default use the emitterType defined function
  17265. */
  17266. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17267. /**
  17268. * @hidden
  17269. */
  17270. _inheritedVelocityOffset: Vector3;
  17271. /**
  17272. * An event triggered when the system is disposed
  17273. */
  17274. onDisposeObservable: Observable<ParticleSystem>;
  17275. private _onDisposeObserver;
  17276. /**
  17277. * Sets a callback that will be triggered when the system is disposed
  17278. */
  17279. onDispose: () => void;
  17280. private _particles;
  17281. private _epsilon;
  17282. private _capacity;
  17283. private _stockParticles;
  17284. private _newPartsExcess;
  17285. private _vertexData;
  17286. private _vertexBuffer;
  17287. private _vertexBuffers;
  17288. private _spriteBuffer;
  17289. private _indexBuffer;
  17290. private _effect;
  17291. private _customEffect;
  17292. private _cachedDefines;
  17293. private _scaledColorStep;
  17294. private _colorDiff;
  17295. private _scaledDirection;
  17296. private _scaledGravity;
  17297. private _currentRenderId;
  17298. private _alive;
  17299. private _useInstancing;
  17300. private _started;
  17301. private _stopped;
  17302. private _actualFrame;
  17303. private _scaledUpdateSpeed;
  17304. private _vertexBufferSize;
  17305. /** @hidden */
  17306. _currentEmitRateGradient: Nullable<FactorGradient>;
  17307. /** @hidden */
  17308. _currentEmitRate1: number;
  17309. /** @hidden */
  17310. _currentEmitRate2: number;
  17311. /** @hidden */
  17312. _currentStartSizeGradient: Nullable<FactorGradient>;
  17313. /** @hidden */
  17314. _currentStartSize1: number;
  17315. /** @hidden */
  17316. _currentStartSize2: number;
  17317. private readonly _rawTextureWidth;
  17318. private _rampGradientsTexture;
  17319. private _useRampGradients;
  17320. /** Gets or sets a boolean indicating that ramp gradients must be used
  17321. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17322. */
  17323. useRampGradients: boolean;
  17324. /**
  17325. * 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.
  17326. * 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: [])
  17327. */
  17328. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17329. private _subEmitters;
  17330. /**
  17331. * @hidden
  17332. * If the particle systems emitter should be disposed when the particle system is disposed
  17333. */
  17334. _disposeEmitterOnDispose: boolean;
  17335. /**
  17336. * The current active Sub-systems, this property is used by the root particle system only.
  17337. */
  17338. activeSubSystems: Array<ParticleSystem>;
  17339. private _rootParticleSystem;
  17340. /**
  17341. * Gets the current list of active particles
  17342. */
  17343. readonly particles: Particle[];
  17344. /**
  17345. * Returns the string "ParticleSystem"
  17346. * @returns a string containing the class name
  17347. */
  17348. getClassName(): string;
  17349. /**
  17350. * Instantiates a particle system.
  17351. * 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.
  17352. * @param name The name of the particle system
  17353. * @param capacity The max number of particles alive at the same time
  17354. * @param scene The scene the particle system belongs to
  17355. * @param customEffect a custom effect used to change the way particles are rendered by default
  17356. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17357. * @param epsilon Offset used to render the particles
  17358. */
  17359. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17360. private _addFactorGradient;
  17361. private _removeFactorGradient;
  17362. /**
  17363. * Adds a new life time gradient
  17364. * @param gradient defines the gradient to use (between 0 and 1)
  17365. * @param factor defines the life time factor to affect to the specified gradient
  17366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17367. * @returns the current particle system
  17368. */
  17369. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17370. /**
  17371. * Remove a specific life time gradient
  17372. * @param gradient defines the gradient to remove
  17373. * @returns the current particle system
  17374. */
  17375. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17376. /**
  17377. * Adds a new size gradient
  17378. * @param gradient defines the gradient to use (between 0 and 1)
  17379. * @param factor defines the size factor to affect to the specified gradient
  17380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17381. * @returns the current particle system
  17382. */
  17383. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17384. /**
  17385. * Remove a specific size gradient
  17386. * @param gradient defines the gradient to remove
  17387. * @returns the current particle system
  17388. */
  17389. removeSizeGradient(gradient: number): IParticleSystem;
  17390. /**
  17391. * Adds a new color remap gradient
  17392. * @param gradient defines the gradient to use (between 0 and 1)
  17393. * @param min defines the color remap minimal range
  17394. * @param max defines the color remap maximal range
  17395. * @returns the current particle system
  17396. */
  17397. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17398. /**
  17399. * Remove a specific color remap gradient
  17400. * @param gradient defines the gradient to remove
  17401. * @returns the current particle system
  17402. */
  17403. removeColorRemapGradient(gradient: number): IParticleSystem;
  17404. /**
  17405. * Adds a new alpha remap gradient
  17406. * @param gradient defines the gradient to use (between 0 and 1)
  17407. * @param min defines the alpha remap minimal range
  17408. * @param max defines the alpha remap maximal range
  17409. * @returns the current particle system
  17410. */
  17411. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17412. /**
  17413. * Remove a specific alpha remap gradient
  17414. * @param gradient defines the gradient to remove
  17415. * @returns the current particle system
  17416. */
  17417. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17418. /**
  17419. * Adds a new angular speed gradient
  17420. * @param gradient defines the gradient to use (between 0 and 1)
  17421. * @param factor defines the angular speed to affect to the specified gradient
  17422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17423. * @returns the current particle system
  17424. */
  17425. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17426. /**
  17427. * Remove a specific angular speed gradient
  17428. * @param gradient defines the gradient to remove
  17429. * @returns the current particle system
  17430. */
  17431. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17432. /**
  17433. * Adds a new velocity gradient
  17434. * @param gradient defines the gradient to use (between 0 and 1)
  17435. * @param factor defines the velocity to affect to the specified gradient
  17436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17437. * @returns the current particle system
  17438. */
  17439. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17440. /**
  17441. * Remove a specific velocity gradient
  17442. * @param gradient defines the gradient to remove
  17443. * @returns the current particle system
  17444. */
  17445. removeVelocityGradient(gradient: number): IParticleSystem;
  17446. /**
  17447. * Adds a new limit velocity gradient
  17448. * @param gradient defines the gradient to use (between 0 and 1)
  17449. * @param factor defines the limit velocity value to affect to the specified gradient
  17450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17451. * @returns the current particle system
  17452. */
  17453. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17454. /**
  17455. * Remove a specific limit velocity gradient
  17456. * @param gradient defines the gradient to remove
  17457. * @returns the current particle system
  17458. */
  17459. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17460. /**
  17461. * Adds a new drag gradient
  17462. * @param gradient defines the gradient to use (between 0 and 1)
  17463. * @param factor defines the drag value to affect to the specified gradient
  17464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17465. * @returns the current particle system
  17466. */
  17467. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17468. /**
  17469. * Remove a specific drag gradient
  17470. * @param gradient defines the gradient to remove
  17471. * @returns the current particle system
  17472. */
  17473. removeDragGradient(gradient: number): IParticleSystem;
  17474. /**
  17475. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17476. * @param gradient defines the gradient to use (between 0 and 1)
  17477. * @param factor defines the emit rate value to affect to the specified gradient
  17478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17479. * @returns the current particle system
  17480. */
  17481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17482. /**
  17483. * Remove a specific emit rate gradient
  17484. * @param gradient defines the gradient to remove
  17485. * @returns the current particle system
  17486. */
  17487. removeEmitRateGradient(gradient: number): IParticleSystem;
  17488. /**
  17489. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17490. * @param gradient defines the gradient to use (between 0 and 1)
  17491. * @param factor defines the start size value to affect to the specified gradient
  17492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17493. * @returns the current particle system
  17494. */
  17495. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17496. /**
  17497. * Remove a specific start size gradient
  17498. * @param gradient defines the gradient to remove
  17499. * @returns the current particle system
  17500. */
  17501. removeStartSizeGradient(gradient: number): IParticleSystem;
  17502. private _createRampGradientTexture;
  17503. /**
  17504. * Gets the current list of ramp gradients.
  17505. * You must use addRampGradient and removeRampGradient to udpate this list
  17506. * @returns the list of ramp gradients
  17507. */
  17508. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17509. /**
  17510. * Adds a new ramp gradient used to remap particle colors
  17511. * @param gradient defines the gradient to use (between 0 and 1)
  17512. * @param color defines the color to affect to the specified gradient
  17513. * @returns the current particle system
  17514. */
  17515. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17516. /**
  17517. * Remove a specific ramp gradient
  17518. * @param gradient defines the gradient to remove
  17519. * @returns the current particle system
  17520. */
  17521. removeRampGradient(gradient: number): ParticleSystem;
  17522. /**
  17523. * Adds a new color gradient
  17524. * @param gradient defines the gradient to use (between 0 and 1)
  17525. * @param color1 defines the color to affect to the specified gradient
  17526. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17527. * @returns this particle system
  17528. */
  17529. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17530. /**
  17531. * Remove a specific color gradient
  17532. * @param gradient defines the gradient to remove
  17533. * @returns this particle system
  17534. */
  17535. removeColorGradient(gradient: number): IParticleSystem;
  17536. private _fetchR;
  17537. protected _reset(): void;
  17538. private _resetEffect;
  17539. private _createVertexBuffers;
  17540. private _createIndexBuffer;
  17541. /**
  17542. * Gets the maximum number of particles active at the same time.
  17543. * @returns The max number of active particles.
  17544. */
  17545. getCapacity(): number;
  17546. /**
  17547. * Gets whether there are still active particles in the system.
  17548. * @returns True if it is alive, otherwise false.
  17549. */
  17550. isAlive(): boolean;
  17551. /**
  17552. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17553. * @returns True if it has been started, otherwise false.
  17554. */
  17555. isStarted(): boolean;
  17556. private _prepareSubEmitterInternalArray;
  17557. /**
  17558. * Starts the particle system and begins to emit
  17559. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17560. */
  17561. start(delay?: number): void;
  17562. /**
  17563. * Stops the particle system.
  17564. * @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.
  17565. */
  17566. stop(stopSubEmitters?: boolean): void;
  17567. /**
  17568. * Remove all active particles
  17569. */
  17570. reset(): void;
  17571. /**
  17572. * @hidden (for internal use only)
  17573. */
  17574. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17575. /**
  17576. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17577. * Its lifetime will start back at 0.
  17578. */
  17579. recycleParticle: (particle: Particle) => void;
  17580. private _stopSubEmitters;
  17581. private _createParticle;
  17582. private _removeFromRoot;
  17583. private _emitFromParticle;
  17584. private _update;
  17585. /** @hidden */
  17586. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17587. /** @hidden */
  17588. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17589. /** @hidden */
  17590. private _getEffect;
  17591. /**
  17592. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17593. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17594. */
  17595. animate(preWarmOnly?: boolean): void;
  17596. private _appendParticleVertices;
  17597. /**
  17598. * Rebuilds the particle system.
  17599. */
  17600. rebuild(): void;
  17601. /**
  17602. * Is this system ready to be used/rendered
  17603. * @return true if the system is ready
  17604. */
  17605. isReady(): boolean;
  17606. private _render;
  17607. /**
  17608. * Renders the particle system in its current state.
  17609. * @returns the current number of particles
  17610. */
  17611. render(): number;
  17612. /**
  17613. * Disposes the particle system and free the associated resources
  17614. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17615. */
  17616. dispose(disposeTexture?: boolean): void;
  17617. /**
  17618. * Clones the particle system.
  17619. * @param name The name of the cloned object
  17620. * @param newEmitter The new emitter to use
  17621. * @returns the cloned particle system
  17622. */
  17623. clone(name: string, newEmitter: any): ParticleSystem;
  17624. /**
  17625. * Serializes the particle system to a JSON object.
  17626. * @returns the JSON object
  17627. */
  17628. serialize(): any;
  17629. /** @hidden */
  17630. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17631. /** @hidden */
  17632. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17633. /**
  17634. * Parses a JSON object to create a particle system.
  17635. * @param parsedParticleSystem The JSON object to parse
  17636. * @param scene The scene to create the particle system in
  17637. * @param rootUrl The root url to use to load external dependencies like texture
  17638. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17639. * @returns the Parsed particle system
  17640. */
  17641. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17642. }
  17643. }
  17644. declare module "babylonjs/Particles/particle" {
  17645. import { Nullable } from "babylonjs/types";
  17646. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17647. import { Color4 } from "babylonjs/Maths/math.color";
  17648. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17649. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17650. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17651. /**
  17652. * A particle represents one of the element emitted by a particle system.
  17653. * This is mainly define by its coordinates, direction, velocity and age.
  17654. */
  17655. export class Particle {
  17656. /**
  17657. * The particle system the particle belongs to.
  17658. */
  17659. particleSystem: ParticleSystem;
  17660. private static _Count;
  17661. /**
  17662. * Unique ID of the particle
  17663. */
  17664. id: number;
  17665. /**
  17666. * The world position of the particle in the scene.
  17667. */
  17668. position: Vector3;
  17669. /**
  17670. * The world direction of the particle in the scene.
  17671. */
  17672. direction: Vector3;
  17673. /**
  17674. * The color of the particle.
  17675. */
  17676. color: Color4;
  17677. /**
  17678. * The color change of the particle per step.
  17679. */
  17680. colorStep: Color4;
  17681. /**
  17682. * Defines how long will the life of the particle be.
  17683. */
  17684. lifeTime: number;
  17685. /**
  17686. * The current age of the particle.
  17687. */
  17688. age: number;
  17689. /**
  17690. * The current size of the particle.
  17691. */
  17692. size: number;
  17693. /**
  17694. * The current scale of the particle.
  17695. */
  17696. scale: Vector2;
  17697. /**
  17698. * The current angle of the particle.
  17699. */
  17700. angle: number;
  17701. /**
  17702. * Defines how fast is the angle changing.
  17703. */
  17704. angularSpeed: number;
  17705. /**
  17706. * Defines the cell index used by the particle to be rendered from a sprite.
  17707. */
  17708. cellIndex: number;
  17709. /**
  17710. * The information required to support color remapping
  17711. */
  17712. remapData: Vector4;
  17713. /** @hidden */
  17714. _randomCellOffset?: number;
  17715. /** @hidden */
  17716. _initialDirection: Nullable<Vector3>;
  17717. /** @hidden */
  17718. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17719. /** @hidden */
  17720. _initialStartSpriteCellID: number;
  17721. /** @hidden */
  17722. _initialEndSpriteCellID: number;
  17723. /** @hidden */
  17724. _currentColorGradient: Nullable<ColorGradient>;
  17725. /** @hidden */
  17726. _currentColor1: Color4;
  17727. /** @hidden */
  17728. _currentColor2: Color4;
  17729. /** @hidden */
  17730. _currentSizeGradient: Nullable<FactorGradient>;
  17731. /** @hidden */
  17732. _currentSize1: number;
  17733. /** @hidden */
  17734. _currentSize2: number;
  17735. /** @hidden */
  17736. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17737. /** @hidden */
  17738. _currentAngularSpeed1: number;
  17739. /** @hidden */
  17740. _currentAngularSpeed2: number;
  17741. /** @hidden */
  17742. _currentVelocityGradient: Nullable<FactorGradient>;
  17743. /** @hidden */
  17744. _currentVelocity1: number;
  17745. /** @hidden */
  17746. _currentVelocity2: number;
  17747. /** @hidden */
  17748. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17749. /** @hidden */
  17750. _currentLimitVelocity1: number;
  17751. /** @hidden */
  17752. _currentLimitVelocity2: number;
  17753. /** @hidden */
  17754. _currentDragGradient: Nullable<FactorGradient>;
  17755. /** @hidden */
  17756. _currentDrag1: number;
  17757. /** @hidden */
  17758. _currentDrag2: number;
  17759. /** @hidden */
  17760. _randomNoiseCoordinates1: Vector3;
  17761. /** @hidden */
  17762. _randomNoiseCoordinates2: Vector3;
  17763. /**
  17764. * Creates a new instance Particle
  17765. * @param particleSystem the particle system the particle belongs to
  17766. */
  17767. constructor(
  17768. /**
  17769. * The particle system the particle belongs to.
  17770. */
  17771. particleSystem: ParticleSystem);
  17772. private updateCellInfoFromSystem;
  17773. /**
  17774. * Defines how the sprite cell index is updated for the particle
  17775. */
  17776. updateCellIndex(): void;
  17777. /** @hidden */
  17778. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17779. /** @hidden */
  17780. _inheritParticleInfoToSubEmitters(): void;
  17781. /** @hidden */
  17782. _reset(): void;
  17783. /**
  17784. * Copy the properties of particle to another one.
  17785. * @param other the particle to copy the information to.
  17786. */
  17787. copyTo(other: Particle): void;
  17788. }
  17789. }
  17790. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17791. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17792. import { Effect } from "babylonjs/Materials/effect";
  17793. import { Particle } from "babylonjs/Particles/particle";
  17794. /**
  17795. * Particle emitter represents a volume emitting particles.
  17796. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17797. */
  17798. export interface IParticleEmitterType {
  17799. /**
  17800. * Called by the particle System when the direction is computed for the created particle.
  17801. * @param worldMatrix is the world matrix of the particle system
  17802. * @param directionToUpdate is the direction vector to update with the result
  17803. * @param particle is the particle we are computed the direction for
  17804. */
  17805. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17806. /**
  17807. * Called by the particle System when the position is computed for the created particle.
  17808. * @param worldMatrix is the world matrix of the particle system
  17809. * @param positionToUpdate is the position vector to update with the result
  17810. * @param particle is the particle we are computed the position for
  17811. */
  17812. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17813. /**
  17814. * Clones the current emitter and returns a copy of it
  17815. * @returns the new emitter
  17816. */
  17817. clone(): IParticleEmitterType;
  17818. /**
  17819. * Called by the GPUParticleSystem to setup the update shader
  17820. * @param effect defines the update shader
  17821. */
  17822. applyToShader(effect: Effect): void;
  17823. /**
  17824. * Returns a string to use to update the GPU particles update shader
  17825. * @returns the effect defines string
  17826. */
  17827. getEffectDefines(): string;
  17828. /**
  17829. * Returns a string representing the class name
  17830. * @returns a string containing the class name
  17831. */
  17832. getClassName(): string;
  17833. /**
  17834. * Serializes the particle system to a JSON object.
  17835. * @returns the JSON object
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * Parse properties from a JSON object
  17840. * @param serializationObject defines the JSON object
  17841. */
  17842. parse(serializationObject: any): void;
  17843. }
  17844. }
  17845. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17846. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17847. import { Effect } from "babylonjs/Materials/effect";
  17848. import { Particle } from "babylonjs/Particles/particle";
  17849. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17850. /**
  17851. * Particle emitter emitting particles from the inside of a box.
  17852. * It emits the particles randomly between 2 given directions.
  17853. */
  17854. export class BoxParticleEmitter implements IParticleEmitterType {
  17855. /**
  17856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17857. */
  17858. direction1: Vector3;
  17859. /**
  17860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17861. */
  17862. direction2: Vector3;
  17863. /**
  17864. * 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.
  17865. */
  17866. minEmitBox: Vector3;
  17867. /**
  17868. * 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.
  17869. */
  17870. maxEmitBox: Vector3;
  17871. /**
  17872. * Creates a new instance BoxParticleEmitter
  17873. */
  17874. constructor();
  17875. /**
  17876. * Called by the particle System when the direction is computed for the created particle.
  17877. * @param worldMatrix is the world matrix of the particle system
  17878. * @param directionToUpdate is the direction vector to update with the result
  17879. * @param particle is the particle we are computed the direction for
  17880. */
  17881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17882. /**
  17883. * Called by the particle System when the position is computed for the created particle.
  17884. * @param worldMatrix is the world matrix of the particle system
  17885. * @param positionToUpdate is the position vector to update with the result
  17886. * @param particle is the particle we are computed the position for
  17887. */
  17888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17889. /**
  17890. * Clones the current emitter and returns a copy of it
  17891. * @returns the new emitter
  17892. */
  17893. clone(): BoxParticleEmitter;
  17894. /**
  17895. * Called by the GPUParticleSystem to setup the update shader
  17896. * @param effect defines the update shader
  17897. */
  17898. applyToShader(effect: Effect): void;
  17899. /**
  17900. * Returns a string to use to update the GPU particles update shader
  17901. * @returns a string containng the defines string
  17902. */
  17903. getEffectDefines(): string;
  17904. /**
  17905. * Returns the string "BoxParticleEmitter"
  17906. * @returns a string containing the class name
  17907. */
  17908. getClassName(): string;
  17909. /**
  17910. * Serializes the particle system to a JSON object.
  17911. * @returns the JSON object
  17912. */
  17913. serialize(): any;
  17914. /**
  17915. * Parse properties from a JSON object
  17916. * @param serializationObject defines the JSON object
  17917. */
  17918. parse(serializationObject: any): void;
  17919. }
  17920. }
  17921. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17922. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17923. import { Effect } from "babylonjs/Materials/effect";
  17924. import { Particle } from "babylonjs/Particles/particle";
  17925. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17926. /**
  17927. * Particle emitter emitting particles from the inside of a cone.
  17928. * It emits the particles alongside the cone volume from the base to the particle.
  17929. * The emission direction might be randomized.
  17930. */
  17931. export class ConeParticleEmitter implements IParticleEmitterType {
  17932. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17933. directionRandomizer: number;
  17934. private _radius;
  17935. private _angle;
  17936. private _height;
  17937. /**
  17938. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17939. */
  17940. radiusRange: number;
  17941. /**
  17942. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17943. */
  17944. heightRange: number;
  17945. /**
  17946. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17947. */
  17948. emitFromSpawnPointOnly: boolean;
  17949. /**
  17950. * Gets or sets the radius of the emission cone
  17951. */
  17952. radius: number;
  17953. /**
  17954. * Gets or sets the angle of the emission cone
  17955. */
  17956. angle: number;
  17957. private _buildHeight;
  17958. /**
  17959. * Creates a new instance ConeParticleEmitter
  17960. * @param radius the radius of the emission cone (1 by default)
  17961. * @param angle the cone base angle (PI by default)
  17962. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17963. */
  17964. constructor(radius?: number, angle?: number,
  17965. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17966. directionRandomizer?: number);
  17967. /**
  17968. * Called by the particle System when the direction is computed for the created particle.
  17969. * @param worldMatrix is the world matrix of the particle system
  17970. * @param directionToUpdate is the direction vector to update with the result
  17971. * @param particle is the particle we are computed the direction for
  17972. */
  17973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17974. /**
  17975. * Called by the particle System when the position is computed for the created particle.
  17976. * @param worldMatrix is the world matrix of the particle system
  17977. * @param positionToUpdate is the position vector to update with the result
  17978. * @param particle is the particle we are computed the position for
  17979. */
  17980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17981. /**
  17982. * Clones the current emitter and returns a copy of it
  17983. * @returns the new emitter
  17984. */
  17985. clone(): ConeParticleEmitter;
  17986. /**
  17987. * Called by the GPUParticleSystem to setup the update shader
  17988. * @param effect defines the update shader
  17989. */
  17990. applyToShader(effect: Effect): void;
  17991. /**
  17992. * Returns a string to use to update the GPU particles update shader
  17993. * @returns a string containng the defines string
  17994. */
  17995. getEffectDefines(): string;
  17996. /**
  17997. * Returns the string "ConeParticleEmitter"
  17998. * @returns a string containing the class name
  17999. */
  18000. getClassName(): string;
  18001. /**
  18002. * Serializes the particle system to a JSON object.
  18003. * @returns the JSON object
  18004. */
  18005. serialize(): any;
  18006. /**
  18007. * Parse properties from a JSON object
  18008. * @param serializationObject defines the JSON object
  18009. */
  18010. parse(serializationObject: any): void;
  18011. }
  18012. }
  18013. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18014. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18015. import { Effect } from "babylonjs/Materials/effect";
  18016. import { Particle } from "babylonjs/Particles/particle";
  18017. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18018. /**
  18019. * Particle emitter emitting particles from the inside of a cylinder.
  18020. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18021. */
  18022. export class CylinderParticleEmitter implements IParticleEmitterType {
  18023. /**
  18024. * The radius of the emission cylinder.
  18025. */
  18026. radius: number;
  18027. /**
  18028. * The height of the emission cylinder.
  18029. */
  18030. height: number;
  18031. /**
  18032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18033. */
  18034. radiusRange: number;
  18035. /**
  18036. * How much to randomize the particle direction [0-1].
  18037. */
  18038. directionRandomizer: number;
  18039. /**
  18040. * Creates a new instance CylinderParticleEmitter
  18041. * @param radius the radius of the emission cylinder (1 by default)
  18042. * @param height the height of the emission cylinder (1 by default)
  18043. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18044. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18045. */
  18046. constructor(
  18047. /**
  18048. * The radius of the emission cylinder.
  18049. */
  18050. radius?: number,
  18051. /**
  18052. * The height of the emission cylinder.
  18053. */
  18054. height?: number,
  18055. /**
  18056. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18057. */
  18058. radiusRange?: number,
  18059. /**
  18060. * How much to randomize the particle direction [0-1].
  18061. */
  18062. directionRandomizer?: number);
  18063. /**
  18064. * Called by the particle System when the direction is computed for the created particle.
  18065. * @param worldMatrix is the world matrix of the particle system
  18066. * @param directionToUpdate is the direction vector to update with the result
  18067. * @param particle is the particle we are computed the direction for
  18068. */
  18069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18070. /**
  18071. * Called by the particle System when the position is computed for the created particle.
  18072. * @param worldMatrix is the world matrix of the particle system
  18073. * @param positionToUpdate is the position vector to update with the result
  18074. * @param particle is the particle we are computed the position for
  18075. */
  18076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18077. /**
  18078. * Clones the current emitter and returns a copy of it
  18079. * @returns the new emitter
  18080. */
  18081. clone(): CylinderParticleEmitter;
  18082. /**
  18083. * Called by the GPUParticleSystem to setup the update shader
  18084. * @param effect defines the update shader
  18085. */
  18086. applyToShader(effect: Effect): void;
  18087. /**
  18088. * Returns a string to use to update the GPU particles update shader
  18089. * @returns a string containng the defines string
  18090. */
  18091. getEffectDefines(): string;
  18092. /**
  18093. * Returns the string "CylinderParticleEmitter"
  18094. * @returns a string containing the class name
  18095. */
  18096. getClassName(): string;
  18097. /**
  18098. * Serializes the particle system to a JSON object.
  18099. * @returns the JSON object
  18100. */
  18101. serialize(): any;
  18102. /**
  18103. * Parse properties from a JSON object
  18104. * @param serializationObject defines the JSON object
  18105. */
  18106. parse(serializationObject: any): void;
  18107. }
  18108. /**
  18109. * Particle emitter emitting particles from the inside of a cylinder.
  18110. * It emits the particles randomly between two vectors.
  18111. */
  18112. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18113. /**
  18114. * The min limit of the emission direction.
  18115. */
  18116. direction1: Vector3;
  18117. /**
  18118. * The max limit of the emission direction.
  18119. */
  18120. direction2: Vector3;
  18121. /**
  18122. * Creates a new instance CylinderDirectedParticleEmitter
  18123. * @param radius the radius of the emission cylinder (1 by default)
  18124. * @param height the height of the emission cylinder (1 by default)
  18125. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18126. * @param direction1 the min limit of the emission direction (up vector by default)
  18127. * @param direction2 the max limit of the emission direction (up vector by default)
  18128. */
  18129. constructor(radius?: number, height?: number, radiusRange?: number,
  18130. /**
  18131. * The min limit of the emission direction.
  18132. */
  18133. direction1?: Vector3,
  18134. /**
  18135. * The max limit of the emission direction.
  18136. */
  18137. direction2?: Vector3);
  18138. /**
  18139. * Called by the particle System when the direction is computed for the created particle.
  18140. * @param worldMatrix is the world matrix of the particle system
  18141. * @param directionToUpdate is the direction vector to update with the result
  18142. * @param particle is the particle we are computed the direction for
  18143. */
  18144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18145. /**
  18146. * Clones the current emitter and returns a copy of it
  18147. * @returns the new emitter
  18148. */
  18149. clone(): CylinderDirectedParticleEmitter;
  18150. /**
  18151. * Called by the GPUParticleSystem to setup the update shader
  18152. * @param effect defines the update shader
  18153. */
  18154. applyToShader(effect: Effect): void;
  18155. /**
  18156. * Returns a string to use to update the GPU particles update shader
  18157. * @returns a string containng the defines string
  18158. */
  18159. getEffectDefines(): string;
  18160. /**
  18161. * Returns the string "CylinderDirectedParticleEmitter"
  18162. * @returns a string containing the class name
  18163. */
  18164. getClassName(): string;
  18165. /**
  18166. * Serializes the particle system to a JSON object.
  18167. * @returns the JSON object
  18168. */
  18169. serialize(): any;
  18170. /**
  18171. * Parse properties from a JSON object
  18172. * @param serializationObject defines the JSON object
  18173. */
  18174. parse(serializationObject: any): void;
  18175. }
  18176. }
  18177. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18178. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18179. import { Effect } from "babylonjs/Materials/effect";
  18180. import { Particle } from "babylonjs/Particles/particle";
  18181. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18182. /**
  18183. * Particle emitter emitting particles from the inside of a hemisphere.
  18184. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18185. */
  18186. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18187. /**
  18188. * The radius of the emission hemisphere.
  18189. */
  18190. radius: number;
  18191. /**
  18192. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18193. */
  18194. radiusRange: number;
  18195. /**
  18196. * How much to randomize the particle direction [0-1].
  18197. */
  18198. directionRandomizer: number;
  18199. /**
  18200. * Creates a new instance HemisphericParticleEmitter
  18201. * @param radius the radius of the emission hemisphere (1 by default)
  18202. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18203. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18204. */
  18205. constructor(
  18206. /**
  18207. * The radius of the emission hemisphere.
  18208. */
  18209. radius?: number,
  18210. /**
  18211. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18212. */
  18213. radiusRange?: number,
  18214. /**
  18215. * How much to randomize the particle direction [0-1].
  18216. */
  18217. directionRandomizer?: number);
  18218. /**
  18219. * Called by the particle System when the direction is computed for the created particle.
  18220. * @param worldMatrix is the world matrix of the particle system
  18221. * @param directionToUpdate is the direction vector to update with the result
  18222. * @param particle is the particle we are computed the direction for
  18223. */
  18224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18225. /**
  18226. * Called by the particle System when the position is computed for the created particle.
  18227. * @param worldMatrix is the world matrix of the particle system
  18228. * @param positionToUpdate is the position vector to update with the result
  18229. * @param particle is the particle we are computed the position for
  18230. */
  18231. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18232. /**
  18233. * Clones the current emitter and returns a copy of it
  18234. * @returns the new emitter
  18235. */
  18236. clone(): HemisphericParticleEmitter;
  18237. /**
  18238. * Called by the GPUParticleSystem to setup the update shader
  18239. * @param effect defines the update shader
  18240. */
  18241. applyToShader(effect: Effect): void;
  18242. /**
  18243. * Returns a string to use to update the GPU particles update shader
  18244. * @returns a string containng the defines string
  18245. */
  18246. getEffectDefines(): string;
  18247. /**
  18248. * Returns the string "HemisphericParticleEmitter"
  18249. * @returns a string containing the class name
  18250. */
  18251. getClassName(): string;
  18252. /**
  18253. * Serializes the particle system to a JSON object.
  18254. * @returns the JSON object
  18255. */
  18256. serialize(): any;
  18257. /**
  18258. * Parse properties from a JSON object
  18259. * @param serializationObject defines the JSON object
  18260. */
  18261. parse(serializationObject: any): void;
  18262. }
  18263. }
  18264. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18265. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18266. import { Effect } from "babylonjs/Materials/effect";
  18267. import { Particle } from "babylonjs/Particles/particle";
  18268. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18269. /**
  18270. * Particle emitter emitting particles from a point.
  18271. * It emits the particles randomly between 2 given directions.
  18272. */
  18273. export class PointParticleEmitter implements IParticleEmitterType {
  18274. /**
  18275. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18276. */
  18277. direction1: Vector3;
  18278. /**
  18279. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18280. */
  18281. direction2: Vector3;
  18282. /**
  18283. * Creates a new instance PointParticleEmitter
  18284. */
  18285. constructor();
  18286. /**
  18287. * Called by the particle System when the direction is computed for the created particle.
  18288. * @param worldMatrix is the world matrix of the particle system
  18289. * @param directionToUpdate is the direction vector to update with the result
  18290. * @param particle is the particle we are computed the direction for
  18291. */
  18292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18293. /**
  18294. * Called by the particle System when the position is computed for the created particle.
  18295. * @param worldMatrix is the world matrix of the particle system
  18296. * @param positionToUpdate is the position vector to update with the result
  18297. * @param particle is the particle we are computed the position for
  18298. */
  18299. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18300. /**
  18301. * Clones the current emitter and returns a copy of it
  18302. * @returns the new emitter
  18303. */
  18304. clone(): PointParticleEmitter;
  18305. /**
  18306. * Called by the GPUParticleSystem to setup the update shader
  18307. * @param effect defines the update shader
  18308. */
  18309. applyToShader(effect: Effect): void;
  18310. /**
  18311. * Returns a string to use to update the GPU particles update shader
  18312. * @returns a string containng the defines string
  18313. */
  18314. getEffectDefines(): string;
  18315. /**
  18316. * Returns the string "PointParticleEmitter"
  18317. * @returns a string containing the class name
  18318. */
  18319. getClassName(): string;
  18320. /**
  18321. * Serializes the particle system to a JSON object.
  18322. * @returns the JSON object
  18323. */
  18324. serialize(): any;
  18325. /**
  18326. * Parse properties from a JSON object
  18327. * @param serializationObject defines the JSON object
  18328. */
  18329. parse(serializationObject: any): void;
  18330. }
  18331. }
  18332. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18333. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18334. import { Effect } from "babylonjs/Materials/effect";
  18335. import { Particle } from "babylonjs/Particles/particle";
  18336. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18337. /**
  18338. * Particle emitter emitting particles from the inside of a sphere.
  18339. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18340. */
  18341. export class SphereParticleEmitter implements IParticleEmitterType {
  18342. /**
  18343. * The radius of the emission sphere.
  18344. */
  18345. radius: number;
  18346. /**
  18347. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18348. */
  18349. radiusRange: number;
  18350. /**
  18351. * How much to randomize the particle direction [0-1].
  18352. */
  18353. directionRandomizer: number;
  18354. /**
  18355. * Creates a new instance SphereParticleEmitter
  18356. * @param radius the radius of the emission sphere (1 by default)
  18357. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18358. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18359. */
  18360. constructor(
  18361. /**
  18362. * The radius of the emission sphere.
  18363. */
  18364. radius?: number,
  18365. /**
  18366. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18367. */
  18368. radiusRange?: number,
  18369. /**
  18370. * How much to randomize the particle direction [0-1].
  18371. */
  18372. directionRandomizer?: number);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Called by the particle System when the position is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param positionToUpdate is the position vector to update with the result
  18384. * @param particle is the particle we are computed the position for
  18385. */
  18386. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Clones the current emitter and returns a copy of it
  18389. * @returns the new emitter
  18390. */
  18391. clone(): SphereParticleEmitter;
  18392. /**
  18393. * Called by the GPUParticleSystem to setup the update shader
  18394. * @param effect defines the update shader
  18395. */
  18396. applyToShader(effect: Effect): void;
  18397. /**
  18398. * Returns a string to use to update the GPU particles update shader
  18399. * @returns a string containng the defines string
  18400. */
  18401. getEffectDefines(): string;
  18402. /**
  18403. * Returns the string "SphereParticleEmitter"
  18404. * @returns a string containing the class name
  18405. */
  18406. getClassName(): string;
  18407. /**
  18408. * Serializes the particle system to a JSON object.
  18409. * @returns the JSON object
  18410. */
  18411. serialize(): any;
  18412. /**
  18413. * Parse properties from a JSON object
  18414. * @param serializationObject defines the JSON object
  18415. */
  18416. parse(serializationObject: any): void;
  18417. }
  18418. /**
  18419. * Particle emitter emitting particles from the inside of a sphere.
  18420. * It emits the particles randomly between two vectors.
  18421. */
  18422. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18423. /**
  18424. * The min limit of the emission direction.
  18425. */
  18426. direction1: Vector3;
  18427. /**
  18428. * The max limit of the emission direction.
  18429. */
  18430. direction2: Vector3;
  18431. /**
  18432. * Creates a new instance SphereDirectedParticleEmitter
  18433. * @param radius the radius of the emission sphere (1 by default)
  18434. * @param direction1 the min limit of the emission direction (up vector by default)
  18435. * @param direction2 the max limit of the emission direction (up vector by default)
  18436. */
  18437. constructor(radius?: number,
  18438. /**
  18439. * The min limit of the emission direction.
  18440. */
  18441. direction1?: Vector3,
  18442. /**
  18443. * The max limit of the emission direction.
  18444. */
  18445. direction2?: Vector3);
  18446. /**
  18447. * Called by the particle System when the direction is computed for the created particle.
  18448. * @param worldMatrix is the world matrix of the particle system
  18449. * @param directionToUpdate is the direction vector to update with the result
  18450. * @param particle is the particle we are computed the direction for
  18451. */
  18452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18453. /**
  18454. * Clones the current emitter and returns a copy of it
  18455. * @returns the new emitter
  18456. */
  18457. clone(): SphereDirectedParticleEmitter;
  18458. /**
  18459. * Called by the GPUParticleSystem to setup the update shader
  18460. * @param effect defines the update shader
  18461. */
  18462. applyToShader(effect: Effect): void;
  18463. /**
  18464. * Returns a string to use to update the GPU particles update shader
  18465. * @returns a string containng the defines string
  18466. */
  18467. getEffectDefines(): string;
  18468. /**
  18469. * Returns the string "SphereDirectedParticleEmitter"
  18470. * @returns a string containing the class name
  18471. */
  18472. getClassName(): string;
  18473. /**
  18474. * Serializes the particle system to a JSON object.
  18475. * @returns the JSON object
  18476. */
  18477. serialize(): any;
  18478. /**
  18479. * Parse properties from a JSON object
  18480. * @param serializationObject defines the JSON object
  18481. */
  18482. parse(serializationObject: any): void;
  18483. }
  18484. }
  18485. declare module "babylonjs/Particles/EmitterTypes/index" {
  18486. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18487. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18488. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18489. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18490. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18491. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18492. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18493. }
  18494. declare module "babylonjs/Particles/IParticleSystem" {
  18495. import { Nullable } from "babylonjs/types";
  18496. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18497. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18500. import { Texture } from "babylonjs/Materials/Textures/texture";
  18501. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18502. import { Scene } from "babylonjs/scene";
  18503. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18504. import { Animation } from "babylonjs/Animations/animation";
  18505. /**
  18506. * Interface representing a particle system in Babylon.js.
  18507. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18508. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18509. */
  18510. export interface IParticleSystem {
  18511. /**
  18512. * List of animations used by the particle system.
  18513. */
  18514. animations: Animation[];
  18515. /**
  18516. * The id of the Particle system.
  18517. */
  18518. id: string;
  18519. /**
  18520. * The name of the Particle system.
  18521. */
  18522. name: string;
  18523. /**
  18524. * The emitter represents the Mesh or position we are attaching the particle system to.
  18525. */
  18526. emitter: Nullable<AbstractMesh | Vector3>;
  18527. /**
  18528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18529. */
  18530. isBillboardBased: boolean;
  18531. /**
  18532. * The rendering group used by the Particle system to chose when to render.
  18533. */
  18534. renderingGroupId: number;
  18535. /**
  18536. * The layer mask we are rendering the particles through.
  18537. */
  18538. layerMask: number;
  18539. /**
  18540. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18541. */
  18542. updateSpeed: number;
  18543. /**
  18544. * The amount of time the particle system is running (depends of the overall update speed).
  18545. */
  18546. targetStopDuration: number;
  18547. /**
  18548. * The texture used to render each particle. (this can be a spritesheet)
  18549. */
  18550. particleTexture: Nullable<Texture>;
  18551. /**
  18552. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18553. */
  18554. blendMode: number;
  18555. /**
  18556. * Minimum life time of emitting particles.
  18557. */
  18558. minLifeTime: number;
  18559. /**
  18560. * Maximum life time of emitting particles.
  18561. */
  18562. maxLifeTime: number;
  18563. /**
  18564. * Minimum Size of emitting particles.
  18565. */
  18566. minSize: number;
  18567. /**
  18568. * Maximum Size of emitting particles.
  18569. */
  18570. maxSize: number;
  18571. /**
  18572. * Minimum scale of emitting particles on X axis.
  18573. */
  18574. minScaleX: number;
  18575. /**
  18576. * Maximum scale of emitting particles on X axis.
  18577. */
  18578. maxScaleX: number;
  18579. /**
  18580. * Minimum scale of emitting particles on Y axis.
  18581. */
  18582. minScaleY: number;
  18583. /**
  18584. * Maximum scale of emitting particles on Y axis.
  18585. */
  18586. maxScaleY: number;
  18587. /**
  18588. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18589. */
  18590. color1: Color4;
  18591. /**
  18592. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18593. */
  18594. color2: Color4;
  18595. /**
  18596. * Color the particle will have at the end of its lifetime.
  18597. */
  18598. colorDead: Color4;
  18599. /**
  18600. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18601. */
  18602. emitRate: number;
  18603. /**
  18604. * You can use gravity if you want to give an orientation to your particles.
  18605. */
  18606. gravity: Vector3;
  18607. /**
  18608. * Minimum power of emitting particles.
  18609. */
  18610. minEmitPower: number;
  18611. /**
  18612. * Maximum power of emitting particles.
  18613. */
  18614. maxEmitPower: number;
  18615. /**
  18616. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18617. */
  18618. minAngularSpeed: number;
  18619. /**
  18620. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18621. */
  18622. maxAngularSpeed: number;
  18623. /**
  18624. * Gets or sets the minimal initial rotation in radians.
  18625. */
  18626. minInitialRotation: number;
  18627. /**
  18628. * Gets or sets the maximal initial rotation in radians.
  18629. */
  18630. maxInitialRotation: number;
  18631. /**
  18632. * The particle emitter type defines the emitter used by the particle system.
  18633. * It can be for example box, sphere, or cone...
  18634. */
  18635. particleEmitterType: Nullable<IParticleEmitterType>;
  18636. /**
  18637. * Defines the delay in milliseconds before starting the system (0 by default)
  18638. */
  18639. startDelay: number;
  18640. /**
  18641. * 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
  18642. */
  18643. preWarmCycles: number;
  18644. /**
  18645. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18646. */
  18647. preWarmStepOffset: number;
  18648. /**
  18649. * 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)
  18650. */
  18651. spriteCellChangeSpeed: number;
  18652. /**
  18653. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18654. */
  18655. startSpriteCellID: number;
  18656. /**
  18657. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18658. */
  18659. endSpriteCellID: number;
  18660. /**
  18661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18662. */
  18663. spriteCellWidth: number;
  18664. /**
  18665. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18666. */
  18667. spriteCellHeight: number;
  18668. /**
  18669. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18670. */
  18671. spriteRandomStartCell: boolean;
  18672. /**
  18673. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18674. */
  18675. isAnimationSheetEnabled: boolean;
  18676. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18677. translationPivot: Vector2;
  18678. /**
  18679. * Gets or sets a texture used to add random noise to particle positions
  18680. */
  18681. noiseTexture: Nullable<BaseTexture>;
  18682. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18683. noiseStrength: Vector3;
  18684. /**
  18685. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18686. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18687. */
  18688. billboardMode: number;
  18689. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18690. limitVelocityDamping: number;
  18691. /**
  18692. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18693. */
  18694. beginAnimationOnStart: boolean;
  18695. /**
  18696. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18697. */
  18698. beginAnimationFrom: number;
  18699. /**
  18700. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18701. */
  18702. beginAnimationTo: number;
  18703. /**
  18704. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18705. */
  18706. beginAnimationLoop: boolean;
  18707. /**
  18708. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18709. */
  18710. disposeOnStop: boolean;
  18711. /**
  18712. * Gets the maximum number of particles active at the same time.
  18713. * @returns The max number of active particles.
  18714. */
  18715. getCapacity(): number;
  18716. /**
  18717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18718. * @returns True if it has been started, otherwise false.
  18719. */
  18720. isStarted(): boolean;
  18721. /**
  18722. * Animates the particle system for this frame.
  18723. */
  18724. animate(): void;
  18725. /**
  18726. * Renders the particle system in its current state.
  18727. * @returns the current number of particles
  18728. */
  18729. render(): number;
  18730. /**
  18731. * Dispose the particle system and frees its associated resources.
  18732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18733. */
  18734. dispose(disposeTexture?: boolean): void;
  18735. /**
  18736. * Clones the particle system.
  18737. * @param name The name of the cloned object
  18738. * @param newEmitter The new emitter to use
  18739. * @returns the cloned particle system
  18740. */
  18741. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18742. /**
  18743. * Serializes the particle system to a JSON object.
  18744. * @returns the JSON object
  18745. */
  18746. serialize(): any;
  18747. /**
  18748. * Rebuild the particle system
  18749. */
  18750. rebuild(): void;
  18751. /**
  18752. * Starts the particle system and begins to emit
  18753. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18754. */
  18755. start(delay?: number): void;
  18756. /**
  18757. * Stops the particle system.
  18758. */
  18759. stop(): void;
  18760. /**
  18761. * Remove all active particles
  18762. */
  18763. reset(): void;
  18764. /**
  18765. * Is this system ready to be used/rendered
  18766. * @return true if the system is ready
  18767. */
  18768. isReady(): boolean;
  18769. /**
  18770. * Adds a new color gradient
  18771. * @param gradient defines the gradient to use (between 0 and 1)
  18772. * @param color1 defines the color to affect to the specified gradient
  18773. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18774. * @returns the current particle system
  18775. */
  18776. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18777. /**
  18778. * Remove a specific color gradient
  18779. * @param gradient defines the gradient to remove
  18780. * @returns the current particle system
  18781. */
  18782. removeColorGradient(gradient: number): IParticleSystem;
  18783. /**
  18784. * Adds a new size gradient
  18785. * @param gradient defines the gradient to use (between 0 and 1)
  18786. * @param factor defines the size factor to affect to the specified gradient
  18787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18788. * @returns the current particle system
  18789. */
  18790. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18791. /**
  18792. * Remove a specific size gradient
  18793. * @param gradient defines the gradient to remove
  18794. * @returns the current particle system
  18795. */
  18796. removeSizeGradient(gradient: number): IParticleSystem;
  18797. /**
  18798. * Gets the current list of color gradients.
  18799. * You must use addColorGradient and removeColorGradient to udpate this list
  18800. * @returns the list of color gradients
  18801. */
  18802. getColorGradients(): Nullable<Array<ColorGradient>>;
  18803. /**
  18804. * Gets the current list of size gradients.
  18805. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18806. * @returns the list of size gradients
  18807. */
  18808. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18809. /**
  18810. * Gets the current list of angular speed gradients.
  18811. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18812. * @returns the list of angular speed gradients
  18813. */
  18814. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18815. /**
  18816. * Adds a new angular speed gradient
  18817. * @param gradient defines the gradient to use (between 0 and 1)
  18818. * @param factor defines the angular speed to affect to the specified gradient
  18819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18820. * @returns the current particle system
  18821. */
  18822. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18823. /**
  18824. * Remove a specific angular speed gradient
  18825. * @param gradient defines the gradient to remove
  18826. * @returns the current particle system
  18827. */
  18828. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18829. /**
  18830. * Gets the current list of velocity gradients.
  18831. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18832. * @returns the list of velocity gradients
  18833. */
  18834. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18835. /**
  18836. * Adds a new velocity gradient
  18837. * @param gradient defines the gradient to use (between 0 and 1)
  18838. * @param factor defines the velocity to affect to the specified gradient
  18839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18840. * @returns the current particle system
  18841. */
  18842. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18843. /**
  18844. * Remove a specific velocity gradient
  18845. * @param gradient defines the gradient to remove
  18846. * @returns the current particle system
  18847. */
  18848. removeVelocityGradient(gradient: number): IParticleSystem;
  18849. /**
  18850. * Gets the current list of limit velocity gradients.
  18851. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18852. * @returns the list of limit velocity gradients
  18853. */
  18854. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18855. /**
  18856. * Adds a new limit velocity gradient
  18857. * @param gradient defines the gradient to use (between 0 and 1)
  18858. * @param factor defines the limit velocity to affect to the specified gradient
  18859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18860. * @returns the current particle system
  18861. */
  18862. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18863. /**
  18864. * Remove a specific limit velocity gradient
  18865. * @param gradient defines the gradient to remove
  18866. * @returns the current particle system
  18867. */
  18868. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18869. /**
  18870. * Adds a new drag gradient
  18871. * @param gradient defines the gradient to use (between 0 and 1)
  18872. * @param factor defines the drag to affect to the specified gradient
  18873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18874. * @returns the current particle system
  18875. */
  18876. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18877. /**
  18878. * Remove a specific drag gradient
  18879. * @param gradient defines the gradient to remove
  18880. * @returns the current particle system
  18881. */
  18882. removeDragGradient(gradient: number): IParticleSystem;
  18883. /**
  18884. * Gets the current list of drag gradients.
  18885. * You must use addDragGradient and removeDragGradient to udpate this list
  18886. * @returns the list of drag gradients
  18887. */
  18888. getDragGradients(): Nullable<Array<FactorGradient>>;
  18889. /**
  18890. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18891. * @param gradient defines the gradient to use (between 0 and 1)
  18892. * @param factor defines the emit rate to affect to the specified gradient
  18893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18894. * @returns the current particle system
  18895. */
  18896. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18897. /**
  18898. * Remove a specific emit rate gradient
  18899. * @param gradient defines the gradient to remove
  18900. * @returns the current particle system
  18901. */
  18902. removeEmitRateGradient(gradient: number): IParticleSystem;
  18903. /**
  18904. * Gets the current list of emit rate gradients.
  18905. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18906. * @returns the list of emit rate gradients
  18907. */
  18908. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18909. /**
  18910. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18911. * @param gradient defines the gradient to use (between 0 and 1)
  18912. * @param factor defines the start size to affect to the specified gradient
  18913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18914. * @returns the current particle system
  18915. */
  18916. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18917. /**
  18918. * Remove a specific start size gradient
  18919. * @param gradient defines the gradient to remove
  18920. * @returns the current particle system
  18921. */
  18922. removeStartSizeGradient(gradient: number): IParticleSystem;
  18923. /**
  18924. * Gets the current list of start size gradients.
  18925. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18926. * @returns the list of start size gradients
  18927. */
  18928. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18929. /**
  18930. * Adds a new life time gradient
  18931. * @param gradient defines the gradient to use (between 0 and 1)
  18932. * @param factor defines the life time factor to affect to the specified gradient
  18933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18934. * @returns the current particle system
  18935. */
  18936. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18937. /**
  18938. * Remove a specific life time gradient
  18939. * @param gradient defines the gradient to remove
  18940. * @returns the current particle system
  18941. */
  18942. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18943. /**
  18944. * Gets the current list of life time gradients.
  18945. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18946. * @returns the list of life time gradients
  18947. */
  18948. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18949. /**
  18950. * Gets the current list of color gradients.
  18951. * You must use addColorGradient and removeColorGradient to udpate this list
  18952. * @returns the list of color gradients
  18953. */
  18954. getColorGradients(): Nullable<Array<ColorGradient>>;
  18955. /**
  18956. * Adds a new ramp gradient used to remap particle colors
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param color defines the color to affect to the specified gradient
  18959. * @returns the current particle system
  18960. */
  18961. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18962. /**
  18963. * Gets the current list of ramp gradients.
  18964. * You must use addRampGradient and removeRampGradient to udpate this list
  18965. * @returns the list of ramp gradients
  18966. */
  18967. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18968. /** Gets or sets a boolean indicating that ramp gradients must be used
  18969. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18970. */
  18971. useRampGradients: boolean;
  18972. /**
  18973. * Adds a new color remap gradient
  18974. * @param gradient defines the gradient to use (between 0 and 1)
  18975. * @param min defines the color remap minimal range
  18976. * @param max defines the color remap maximal range
  18977. * @returns the current particle system
  18978. */
  18979. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18980. /**
  18981. * Gets the current list of color remap gradients.
  18982. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18983. * @returns the list of color remap gradients
  18984. */
  18985. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18986. /**
  18987. * Adds a new alpha remap gradient
  18988. * @param gradient defines the gradient to use (between 0 and 1)
  18989. * @param min defines the alpha remap minimal range
  18990. * @param max defines the alpha remap maximal range
  18991. * @returns the current particle system
  18992. */
  18993. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18994. /**
  18995. * Gets the current list of alpha remap gradients.
  18996. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18997. * @returns the list of alpha remap gradients
  18998. */
  18999. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19000. /**
  19001. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19004. * @returns the emitter
  19005. */
  19006. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19007. /**
  19008. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19009. * @param radius The radius of the hemisphere to emit from
  19010. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19011. * @returns the emitter
  19012. */
  19013. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19014. /**
  19015. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19016. * @param radius The radius of the sphere to emit from
  19017. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19018. * @returns the emitter
  19019. */
  19020. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19021. /**
  19022. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19023. * @param radius The radius of the sphere to emit from
  19024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19026. * @returns the emitter
  19027. */
  19028. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19029. /**
  19030. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19031. * @param radius The radius of the emission cylinder
  19032. * @param height The height of the emission cylinder
  19033. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19034. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19035. * @returns the emitter
  19036. */
  19037. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19038. /**
  19039. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19040. * @param radius The radius of the cylinder to emit from
  19041. * @param height The height of the emission cylinder
  19042. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19043. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19044. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19045. * @returns the emitter
  19046. */
  19047. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19048. /**
  19049. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19050. * @param radius The radius of the cone to emit from
  19051. * @param angle The base angle of the cone
  19052. * @returns the emitter
  19053. */
  19054. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19055. /**
  19056. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19057. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19058. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19059. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19060. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19061. * @returns the emitter
  19062. */
  19063. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19064. /**
  19065. * Get hosting scene
  19066. * @returns the scene
  19067. */
  19068. getScene(): Scene;
  19069. }
  19070. }
  19071. declare module "babylonjs/Meshes/instancedMesh" {
  19072. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19073. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19074. import { Camera } from "babylonjs/Cameras/camera";
  19075. import { Node } from "babylonjs/node";
  19076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19077. import { Mesh } from "babylonjs/Meshes/mesh";
  19078. import { Material } from "babylonjs/Materials/material";
  19079. import { Skeleton } from "babylonjs/Bones/skeleton";
  19080. import { Light } from "babylonjs/Lights/light";
  19081. /**
  19082. * Creates an instance based on a source mesh.
  19083. */
  19084. export class InstancedMesh extends AbstractMesh {
  19085. private _sourceMesh;
  19086. private _currentLOD;
  19087. /** @hidden */
  19088. _indexInSourceMeshInstanceArray: number;
  19089. constructor(name: string, source: Mesh);
  19090. /**
  19091. * Returns the string "InstancedMesh".
  19092. */
  19093. getClassName(): string;
  19094. /** Gets the list of lights affecting that mesh */
  19095. readonly lightSources: Light[];
  19096. _resyncLightSources(): void;
  19097. _resyncLighSource(light: Light): void;
  19098. _removeLightSource(light: Light, dispose: boolean): void;
  19099. /**
  19100. * If the source mesh receives shadows
  19101. */
  19102. readonly receiveShadows: boolean;
  19103. /**
  19104. * The material of the source mesh
  19105. */
  19106. readonly material: Nullable<Material>;
  19107. /**
  19108. * Visibility of the source mesh
  19109. */
  19110. readonly visibility: number;
  19111. /**
  19112. * Skeleton of the source mesh
  19113. */
  19114. readonly skeleton: Nullable<Skeleton>;
  19115. /**
  19116. * Rendering ground id of the source mesh
  19117. */
  19118. renderingGroupId: number;
  19119. /**
  19120. * Returns the total number of vertices (integer).
  19121. */
  19122. getTotalVertices(): number;
  19123. /**
  19124. * Returns a positive integer : the total number of indices in this mesh geometry.
  19125. * @returns the numner of indices or zero if the mesh has no geometry.
  19126. */
  19127. getTotalIndices(): number;
  19128. /**
  19129. * The source mesh of the instance
  19130. */
  19131. readonly sourceMesh: Mesh;
  19132. /**
  19133. * Is this node ready to be used/rendered
  19134. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19135. * @return {boolean} is it ready
  19136. */
  19137. isReady(completeCheck?: boolean): boolean;
  19138. /**
  19139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19140. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19141. * @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.
  19142. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19143. */
  19144. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19145. /**
  19146. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19147. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19148. * The `data` are either a numeric array either a Float32Array.
  19149. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19150. * 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).
  19151. * Note that a new underlying VertexBuffer object is created each call.
  19152. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19153. *
  19154. * Possible `kind` values :
  19155. * - VertexBuffer.PositionKind
  19156. * - VertexBuffer.UVKind
  19157. * - VertexBuffer.UV2Kind
  19158. * - VertexBuffer.UV3Kind
  19159. * - VertexBuffer.UV4Kind
  19160. * - VertexBuffer.UV5Kind
  19161. * - VertexBuffer.UV6Kind
  19162. * - VertexBuffer.ColorKind
  19163. * - VertexBuffer.MatricesIndicesKind
  19164. * - VertexBuffer.MatricesIndicesExtraKind
  19165. * - VertexBuffer.MatricesWeightsKind
  19166. * - VertexBuffer.MatricesWeightsExtraKind
  19167. *
  19168. * Returns the Mesh.
  19169. */
  19170. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19171. /**
  19172. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19173. * If the mesh has no geometry, it is simply returned as it is.
  19174. * The `data` are either a numeric array either a Float32Array.
  19175. * No new underlying VertexBuffer object is created.
  19176. * 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.
  19177. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19178. *
  19179. * Possible `kind` values :
  19180. * - VertexBuffer.PositionKind
  19181. * - VertexBuffer.UVKind
  19182. * - VertexBuffer.UV2Kind
  19183. * - VertexBuffer.UV3Kind
  19184. * - VertexBuffer.UV4Kind
  19185. * - VertexBuffer.UV5Kind
  19186. * - VertexBuffer.UV6Kind
  19187. * - VertexBuffer.ColorKind
  19188. * - VertexBuffer.MatricesIndicesKind
  19189. * - VertexBuffer.MatricesIndicesExtraKind
  19190. * - VertexBuffer.MatricesWeightsKind
  19191. * - VertexBuffer.MatricesWeightsExtraKind
  19192. *
  19193. * Returns the Mesh.
  19194. */
  19195. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19196. /**
  19197. * Sets the mesh indices.
  19198. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19199. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19200. * This method creates a new index buffer each call.
  19201. * Returns the Mesh.
  19202. */
  19203. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19204. /**
  19205. * Boolean : True if the mesh owns the requested kind of data.
  19206. */
  19207. isVerticesDataPresent(kind: string): boolean;
  19208. /**
  19209. * Returns an array of indices (IndicesArray).
  19210. */
  19211. getIndices(): Nullable<IndicesArray>;
  19212. readonly _positions: Nullable<Vector3[]>;
  19213. /**
  19214. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19215. * This means the mesh underlying bounding box and sphere are recomputed.
  19216. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19217. * @returns the current mesh
  19218. */
  19219. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19220. /** @hidden */
  19221. _preActivate(): InstancedMesh;
  19222. /** @hidden */
  19223. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19224. /** @hidden */
  19225. _postActivate(): void;
  19226. getWorldMatrix(): Matrix;
  19227. readonly isAnInstance: boolean;
  19228. /**
  19229. * Returns the current associated LOD AbstractMesh.
  19230. */
  19231. getLOD(camera: Camera): AbstractMesh;
  19232. /** @hidden */
  19233. _syncSubMeshes(): InstancedMesh;
  19234. /** @hidden */
  19235. _generatePointsArray(): boolean;
  19236. /**
  19237. * Creates a new InstancedMesh from the current mesh.
  19238. * - name (string) : the cloned mesh name
  19239. * - newParent (optional Node) : the optional Node to parent the clone to.
  19240. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19241. *
  19242. * Returns the clone.
  19243. */
  19244. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19245. /**
  19246. * Disposes the InstancedMesh.
  19247. * Returns nothing.
  19248. */
  19249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19250. }
  19251. }
  19252. declare module "babylonjs/Materials/shaderMaterial" {
  19253. import { Scene } from "babylonjs/scene";
  19254. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19256. import { Mesh } from "babylonjs/Meshes/mesh";
  19257. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19259. import { Texture } from "babylonjs/Materials/Textures/texture";
  19260. import { Material } from "babylonjs/Materials/material";
  19261. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19262. /**
  19263. * Defines the options associated with the creation of a shader material.
  19264. */
  19265. export interface IShaderMaterialOptions {
  19266. /**
  19267. * Does the material work in alpha blend mode
  19268. */
  19269. needAlphaBlending: boolean;
  19270. /**
  19271. * Does the material work in alpha test mode
  19272. */
  19273. needAlphaTesting: boolean;
  19274. /**
  19275. * The list of attribute names used in the shader
  19276. */
  19277. attributes: string[];
  19278. /**
  19279. * The list of unifrom names used in the shader
  19280. */
  19281. uniforms: string[];
  19282. /**
  19283. * The list of UBO names used in the shader
  19284. */
  19285. uniformBuffers: string[];
  19286. /**
  19287. * The list of sampler names used in the shader
  19288. */
  19289. samplers: string[];
  19290. /**
  19291. * The list of defines used in the shader
  19292. */
  19293. defines: string[];
  19294. }
  19295. /**
  19296. * 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.
  19297. *
  19298. * This returned material effects how the mesh will look based on the code in the shaders.
  19299. *
  19300. * @see http://doc.babylonjs.com/how_to/shader_material
  19301. */
  19302. export class ShaderMaterial extends Material {
  19303. private _shaderPath;
  19304. private _options;
  19305. private _textures;
  19306. private _textureArrays;
  19307. private _floats;
  19308. private _ints;
  19309. private _floatsArrays;
  19310. private _colors3;
  19311. private _colors3Arrays;
  19312. private _colors4;
  19313. private _colors4Arrays;
  19314. private _vectors2;
  19315. private _vectors3;
  19316. private _vectors4;
  19317. private _matrices;
  19318. private _matrices3x3;
  19319. private _matrices2x2;
  19320. private _vectors2Arrays;
  19321. private _vectors3Arrays;
  19322. private _vectors4Arrays;
  19323. private _cachedWorldViewMatrix;
  19324. private _cachedWorldViewProjectionMatrix;
  19325. private _renderId;
  19326. /**
  19327. * Instantiate a new shader material.
  19328. * 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.
  19329. * This returned material effects how the mesh will look based on the code in the shaders.
  19330. * @see http://doc.babylonjs.com/how_to/shader_material
  19331. * @param name Define the name of the material in the scene
  19332. * @param scene Define the scene the material belongs to
  19333. * @param shaderPath Defines the route to the shader code in one of three ways:
  19334. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19335. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19336. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19337. * @param options Define the options used to create the shader
  19338. */
  19339. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19340. /**
  19341. * Gets the options used to compile the shader.
  19342. * They can be modified to trigger a new compilation
  19343. */
  19344. readonly options: IShaderMaterialOptions;
  19345. /**
  19346. * Gets the current class name of the material e.g. "ShaderMaterial"
  19347. * Mainly use in serialization.
  19348. * @returns the class name
  19349. */
  19350. getClassName(): string;
  19351. /**
  19352. * Specifies if the material will require alpha blending
  19353. * @returns a boolean specifying if alpha blending is needed
  19354. */
  19355. needAlphaBlending(): boolean;
  19356. /**
  19357. * Specifies if this material should be rendered in alpha test mode
  19358. * @returns a boolean specifying if an alpha test is needed.
  19359. */
  19360. needAlphaTesting(): boolean;
  19361. private _checkUniform;
  19362. /**
  19363. * Set a texture in the shader.
  19364. * @param name Define the name of the uniform samplers as defined in the shader
  19365. * @param texture Define the texture to bind to this sampler
  19366. * @return the material itself allowing "fluent" like uniform updates
  19367. */
  19368. setTexture(name: string, texture: Texture): ShaderMaterial;
  19369. /**
  19370. * Set a texture array in the shader.
  19371. * @param name Define the name of the uniform sampler array as defined in the shader
  19372. * @param textures Define the list of textures to bind to this sampler
  19373. * @return the material itself allowing "fluent" like uniform updates
  19374. */
  19375. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19376. /**
  19377. * Set a float in the shader.
  19378. * @param name Define the name of the uniform as defined in the shader
  19379. * @param value Define the value to give to the uniform
  19380. * @return the material itself allowing "fluent" like uniform updates
  19381. */
  19382. setFloat(name: string, value: number): ShaderMaterial;
  19383. /**
  19384. * Set a int in the shader.
  19385. * @param name Define the name of the uniform as defined in the shader
  19386. * @param value Define the value to give to the uniform
  19387. * @return the material itself allowing "fluent" like uniform updates
  19388. */
  19389. setInt(name: string, value: number): ShaderMaterial;
  19390. /**
  19391. * Set an array of floats in the shader.
  19392. * @param name Define the name of the uniform as defined in the shader
  19393. * @param value Define the value to give to the uniform
  19394. * @return the material itself allowing "fluent" like uniform updates
  19395. */
  19396. setFloats(name: string, value: number[]): ShaderMaterial;
  19397. /**
  19398. * Set a vec3 in the shader from a Color3.
  19399. * @param name Define the name of the uniform as defined in the shader
  19400. * @param value Define the value to give to the uniform
  19401. * @return the material itself allowing "fluent" like uniform updates
  19402. */
  19403. setColor3(name: string, value: Color3): ShaderMaterial;
  19404. /**
  19405. * Set a vec3 array in the shader from a Color3 array.
  19406. * @param name Define the name of the uniform as defined in the shader
  19407. * @param value Define the value to give to the uniform
  19408. * @return the material itself allowing "fluent" like uniform updates
  19409. */
  19410. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19411. /**
  19412. * Set a vec4 in the shader from a Color4.
  19413. * @param name Define the name of the uniform as defined in the shader
  19414. * @param value Define the value to give to the uniform
  19415. * @return the material itself allowing "fluent" like uniform updates
  19416. */
  19417. setColor4(name: string, value: Color4): ShaderMaterial;
  19418. /**
  19419. * Set a vec4 array in the shader from a Color4 array.
  19420. * @param name Define the name of the uniform as defined in the shader
  19421. * @param value Define the value to give to the uniform
  19422. * @return the material itself allowing "fluent" like uniform updates
  19423. */
  19424. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19425. /**
  19426. * Set a vec2 in the shader from a Vector2.
  19427. * @param name Define the name of the uniform as defined in the shader
  19428. * @param value Define the value to give to the uniform
  19429. * @return the material itself allowing "fluent" like uniform updates
  19430. */
  19431. setVector2(name: string, value: Vector2): ShaderMaterial;
  19432. /**
  19433. * Set a vec3 in the shader from a Vector3.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the material itself allowing "fluent" like uniform updates
  19437. */
  19438. setVector3(name: string, value: Vector3): ShaderMaterial;
  19439. /**
  19440. * Set a vec4 in the shader from a Vector4.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the material itself allowing "fluent" like uniform updates
  19444. */
  19445. setVector4(name: string, value: Vector4): ShaderMaterial;
  19446. /**
  19447. * Set a mat4 in the shader from a Matrix.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the material itself allowing "fluent" like uniform updates
  19451. */
  19452. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19453. /**
  19454. * Set a mat3 in the shader from a Float32Array.
  19455. * @param name Define the name of the uniform as defined in the shader
  19456. * @param value Define the value to give to the uniform
  19457. * @return the material itself allowing "fluent" like uniform updates
  19458. */
  19459. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19460. /**
  19461. * Set a mat2 in the shader from a Float32Array.
  19462. * @param name Define the name of the uniform as defined in the shader
  19463. * @param value Define the value to give to the uniform
  19464. * @return the material itself allowing "fluent" like uniform updates
  19465. */
  19466. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19467. /**
  19468. * Set a vec2 array in the shader from a number array.
  19469. * @param name Define the name of the uniform as defined in the shader
  19470. * @param value Define the value to give to the uniform
  19471. * @return the material itself allowing "fluent" like uniform updates
  19472. */
  19473. setArray2(name: string, value: number[]): ShaderMaterial;
  19474. /**
  19475. * Set a vec3 array in the shader from a number array.
  19476. * @param name Define the name of the uniform as defined in the shader
  19477. * @param value Define the value to give to the uniform
  19478. * @return the material itself allowing "fluent" like uniform updates
  19479. */
  19480. setArray3(name: string, value: number[]): ShaderMaterial;
  19481. /**
  19482. * Set a vec4 array in the shader from a number array.
  19483. * @param name Define the name of the uniform as defined in the shader
  19484. * @param value Define the value to give to the uniform
  19485. * @return the material itself allowing "fluent" like uniform updates
  19486. */
  19487. setArray4(name: string, value: number[]): ShaderMaterial;
  19488. private _checkCache;
  19489. /**
  19490. * Specifies that the submesh is ready to be used
  19491. * @param mesh defines the mesh to check
  19492. * @param subMesh defines which submesh to check
  19493. * @param useInstances specifies that instances should be used
  19494. * @returns a boolean indicating that the submesh is ready or not
  19495. */
  19496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19497. /**
  19498. * Checks if the material is ready to render the requested mesh
  19499. * @param mesh Define the mesh to render
  19500. * @param useInstances Define whether or not the material is used with instances
  19501. * @returns true if ready, otherwise false
  19502. */
  19503. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19504. /**
  19505. * Binds the world matrix to the material
  19506. * @param world defines the world transformation matrix
  19507. */
  19508. bindOnlyWorldMatrix(world: Matrix): void;
  19509. /**
  19510. * Binds the material to the mesh
  19511. * @param world defines the world transformation matrix
  19512. * @param mesh defines the mesh to bind the material to
  19513. */
  19514. bind(world: Matrix, mesh?: Mesh): void;
  19515. /**
  19516. * Gets the active textures from the material
  19517. * @returns an array of textures
  19518. */
  19519. getActiveTextures(): BaseTexture[];
  19520. /**
  19521. * Specifies if the material uses a texture
  19522. * @param texture defines the texture to check against the material
  19523. * @returns a boolean specifying if the material uses the texture
  19524. */
  19525. hasTexture(texture: BaseTexture): boolean;
  19526. /**
  19527. * Makes a duplicate of the material, and gives it a new name
  19528. * @param name defines the new name for the duplicated material
  19529. * @returns the cloned material
  19530. */
  19531. clone(name: string): ShaderMaterial;
  19532. /**
  19533. * Disposes the material
  19534. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19535. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19536. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19537. */
  19538. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19539. /**
  19540. * Serializes this material in a JSON representation
  19541. * @returns the serialized material object
  19542. */
  19543. serialize(): any;
  19544. /**
  19545. * Creates a shader material from parsed shader material data
  19546. * @param source defines the JSON represnetation of the material
  19547. * @param scene defines the hosting scene
  19548. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19549. * @returns a new material
  19550. */
  19551. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19552. }
  19553. }
  19554. declare module "babylonjs/Shaders/color.fragment" {
  19555. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19556. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19557. /** @hidden */
  19558. export var colorPixelShader: {
  19559. name: string;
  19560. shader: string;
  19561. };
  19562. }
  19563. declare module "babylonjs/Shaders/color.vertex" {
  19564. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19565. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19566. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19567. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19568. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19569. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19570. /** @hidden */
  19571. export var colorVertexShader: {
  19572. name: string;
  19573. shader: string;
  19574. };
  19575. }
  19576. declare module "babylonjs/Meshes/linesMesh" {
  19577. import { Nullable } from "babylonjs/types";
  19578. import { Scene } from "babylonjs/scene";
  19579. import { Color3 } from "babylonjs/Maths/math.color";
  19580. import { Node } from "babylonjs/node";
  19581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19582. import { Mesh } from "babylonjs/Meshes/mesh";
  19583. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19584. import { Effect } from "babylonjs/Materials/effect";
  19585. import { Material } from "babylonjs/Materials/material";
  19586. import "babylonjs/Shaders/color.fragment";
  19587. import "babylonjs/Shaders/color.vertex";
  19588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19589. /**
  19590. * Line mesh
  19591. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19592. */
  19593. export class LinesMesh extends Mesh {
  19594. /**
  19595. * If vertex color should be applied to the mesh
  19596. */
  19597. readonly useVertexColor?: boolean | undefined;
  19598. /**
  19599. * If vertex alpha should be applied to the mesh
  19600. */
  19601. readonly useVertexAlpha?: boolean | undefined;
  19602. /**
  19603. * Color of the line (Default: White)
  19604. */
  19605. color: Color3;
  19606. /**
  19607. * Alpha of the line (Default: 1)
  19608. */
  19609. alpha: number;
  19610. /**
  19611. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19612. * This margin is expressed in world space coordinates, so its value may vary.
  19613. * Default value is 0.1
  19614. */
  19615. intersectionThreshold: number;
  19616. private _colorShader;
  19617. private color4;
  19618. /**
  19619. * Creates a new LinesMesh
  19620. * @param name defines the name
  19621. * @param scene defines the hosting scene
  19622. * @param parent defines the parent mesh if any
  19623. * @param source defines the optional source LinesMesh used to clone data from
  19624. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19625. * When false, achieved by calling a clone(), also passing False.
  19626. * This will make creation of children, recursive.
  19627. * @param useVertexColor defines if this LinesMesh supports vertex color
  19628. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19629. */
  19630. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19631. /**
  19632. * If vertex color should be applied to the mesh
  19633. */
  19634. useVertexColor?: boolean | undefined,
  19635. /**
  19636. * If vertex alpha should be applied to the mesh
  19637. */
  19638. useVertexAlpha?: boolean | undefined);
  19639. private _addClipPlaneDefine;
  19640. private _removeClipPlaneDefine;
  19641. isReady(): boolean;
  19642. /**
  19643. * Returns the string "LineMesh"
  19644. */
  19645. getClassName(): string;
  19646. /**
  19647. * @hidden
  19648. */
  19649. /**
  19650. * @hidden
  19651. */
  19652. material: Material;
  19653. /**
  19654. * @hidden
  19655. */
  19656. readonly checkCollisions: boolean;
  19657. /** @hidden */
  19658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19659. /** @hidden */
  19660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19661. /**
  19662. * Disposes of the line mesh
  19663. * @param doNotRecurse If children should be disposed
  19664. */
  19665. dispose(doNotRecurse?: boolean): void;
  19666. /**
  19667. * Returns a new LineMesh object cloned from the current one.
  19668. */
  19669. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19670. /**
  19671. * Creates a new InstancedLinesMesh object from the mesh model.
  19672. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19673. * @param name defines the name of the new instance
  19674. * @returns a new InstancedLinesMesh
  19675. */
  19676. createInstance(name: string): InstancedLinesMesh;
  19677. }
  19678. /**
  19679. * Creates an instance based on a source LinesMesh
  19680. */
  19681. export class InstancedLinesMesh extends InstancedMesh {
  19682. /**
  19683. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19684. * This margin is expressed in world space coordinates, so its value may vary.
  19685. * Initilized with the intersectionThreshold value of the source LinesMesh
  19686. */
  19687. intersectionThreshold: number;
  19688. constructor(name: string, source: LinesMesh);
  19689. /**
  19690. * Returns the string "InstancedLinesMesh".
  19691. */
  19692. getClassName(): string;
  19693. }
  19694. }
  19695. declare module "babylonjs/Shaders/line.fragment" {
  19696. /** @hidden */
  19697. export var linePixelShader: {
  19698. name: string;
  19699. shader: string;
  19700. };
  19701. }
  19702. declare module "babylonjs/Shaders/line.vertex" {
  19703. /** @hidden */
  19704. export var lineVertexShader: {
  19705. name: string;
  19706. shader: string;
  19707. };
  19708. }
  19709. declare module "babylonjs/Rendering/edgesRenderer" {
  19710. import { Nullable } from "babylonjs/types";
  19711. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19713. import { Vector3 } from "babylonjs/Maths/math.vector";
  19714. import { IDisposable } from "babylonjs/scene";
  19715. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19716. import "babylonjs/Shaders/line.fragment";
  19717. import "babylonjs/Shaders/line.vertex";
  19718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19719. module "babylonjs/Meshes/abstractMesh" {
  19720. interface AbstractMesh {
  19721. /**
  19722. * Gets the edgesRenderer associated with the mesh
  19723. */
  19724. edgesRenderer: Nullable<EdgesRenderer>;
  19725. }
  19726. }
  19727. module "babylonjs/Meshes/linesMesh" {
  19728. interface LinesMesh {
  19729. /**
  19730. * Enables the edge rendering mode on the mesh.
  19731. * This mode makes the mesh edges visible
  19732. * @param epsilon defines the maximal distance between two angles to detect a face
  19733. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19734. * @returns the currentAbstractMesh
  19735. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19736. */
  19737. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19738. }
  19739. }
  19740. module "babylonjs/Meshes/linesMesh" {
  19741. interface InstancedLinesMesh {
  19742. /**
  19743. * Enables the edge rendering mode on the mesh.
  19744. * This mode makes the mesh edges visible
  19745. * @param epsilon defines the maximal distance between two angles to detect a face
  19746. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19747. * @returns the current InstancedLinesMesh
  19748. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19749. */
  19750. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19751. }
  19752. }
  19753. /**
  19754. * Defines the minimum contract an Edges renderer should follow.
  19755. */
  19756. export interface IEdgesRenderer extends IDisposable {
  19757. /**
  19758. * Gets or sets a boolean indicating if the edgesRenderer is active
  19759. */
  19760. isEnabled: boolean;
  19761. /**
  19762. * Renders the edges of the attached mesh,
  19763. */
  19764. render(): void;
  19765. /**
  19766. * Checks wether or not the edges renderer is ready to render.
  19767. * @return true if ready, otherwise false.
  19768. */
  19769. isReady(): boolean;
  19770. }
  19771. /**
  19772. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19773. */
  19774. export class EdgesRenderer implements IEdgesRenderer {
  19775. /**
  19776. * Define the size of the edges with an orthographic camera
  19777. */
  19778. edgesWidthScalerForOrthographic: number;
  19779. /**
  19780. * Define the size of the edges with a perspective camera
  19781. */
  19782. edgesWidthScalerForPerspective: number;
  19783. protected _source: AbstractMesh;
  19784. protected _linesPositions: number[];
  19785. protected _linesNormals: number[];
  19786. protected _linesIndices: number[];
  19787. protected _epsilon: number;
  19788. protected _indicesCount: number;
  19789. protected _lineShader: ShaderMaterial;
  19790. protected _ib: DataBuffer;
  19791. protected _buffers: {
  19792. [key: string]: Nullable<VertexBuffer>;
  19793. };
  19794. protected _checkVerticesInsteadOfIndices: boolean;
  19795. private _meshRebuildObserver;
  19796. private _meshDisposeObserver;
  19797. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19798. isEnabled: boolean;
  19799. /**
  19800. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19801. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19802. * @param source Mesh used to create edges
  19803. * @param epsilon sum of angles in adjacency to check for edge
  19804. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19805. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19806. */
  19807. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19808. protected _prepareRessources(): void;
  19809. /** @hidden */
  19810. _rebuild(): void;
  19811. /**
  19812. * Releases the required resources for the edges renderer
  19813. */
  19814. dispose(): void;
  19815. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19816. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19817. /**
  19818. * Checks if the pair of p0 and p1 is en edge
  19819. * @param faceIndex
  19820. * @param edge
  19821. * @param faceNormals
  19822. * @param p0
  19823. * @param p1
  19824. * @private
  19825. */
  19826. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19827. /**
  19828. * push line into the position, normal and index buffer
  19829. * @protected
  19830. */
  19831. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19832. /**
  19833. * Generates lines edges from adjacencjes
  19834. * @private
  19835. */
  19836. _generateEdgesLines(): void;
  19837. /**
  19838. * Checks wether or not the edges renderer is ready to render.
  19839. * @return true if ready, otherwise false.
  19840. */
  19841. isReady(): boolean;
  19842. /**
  19843. * Renders the edges of the attached mesh,
  19844. */
  19845. render(): void;
  19846. }
  19847. /**
  19848. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19849. */
  19850. export class LineEdgesRenderer extends EdgesRenderer {
  19851. /**
  19852. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19853. * @param source LineMesh used to generate edges
  19854. * @param epsilon not important (specified angle for edge detection)
  19855. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19856. */
  19857. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19858. /**
  19859. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19860. */
  19861. _generateEdgesLines(): void;
  19862. }
  19863. }
  19864. declare module "babylonjs/Rendering/renderingGroup" {
  19865. import { SmartArray } from "babylonjs/Misc/smartArray";
  19866. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19868. import { Nullable } from "babylonjs/types";
  19869. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19870. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19871. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19872. import { Material } from "babylonjs/Materials/material";
  19873. import { Scene } from "babylonjs/scene";
  19874. /**
  19875. * This represents the object necessary to create a rendering group.
  19876. * This is exclusively used and created by the rendering manager.
  19877. * To modify the behavior, you use the available helpers in your scene or meshes.
  19878. * @hidden
  19879. */
  19880. export class RenderingGroup {
  19881. index: number;
  19882. private static _zeroVector;
  19883. private _scene;
  19884. private _opaqueSubMeshes;
  19885. private _transparentSubMeshes;
  19886. private _alphaTestSubMeshes;
  19887. private _depthOnlySubMeshes;
  19888. private _particleSystems;
  19889. private _spriteManagers;
  19890. private _opaqueSortCompareFn;
  19891. private _alphaTestSortCompareFn;
  19892. private _transparentSortCompareFn;
  19893. private _renderOpaque;
  19894. private _renderAlphaTest;
  19895. private _renderTransparent;
  19896. /** @hidden */
  19897. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19898. onBeforeTransparentRendering: () => void;
  19899. /**
  19900. * Set the opaque sort comparison function.
  19901. * If null the sub meshes will be render in the order they were created
  19902. */
  19903. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19904. /**
  19905. * Set the alpha test sort comparison function.
  19906. * If null the sub meshes will be render in the order they were created
  19907. */
  19908. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19909. /**
  19910. * Set the transparent sort comparison function.
  19911. * If null the sub meshes will be render in the order they were created
  19912. */
  19913. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19914. /**
  19915. * Creates a new rendering group.
  19916. * @param index The rendering group index
  19917. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19918. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19919. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19920. */
  19921. 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>);
  19922. /**
  19923. * Render all the sub meshes contained in the group.
  19924. * @param customRenderFunction Used to override the default render behaviour of the group.
  19925. * @returns true if rendered some submeshes.
  19926. */
  19927. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19928. /**
  19929. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19930. * @param subMeshes The submeshes to render
  19931. */
  19932. private renderOpaqueSorted;
  19933. /**
  19934. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19935. * @param subMeshes The submeshes to render
  19936. */
  19937. private renderAlphaTestSorted;
  19938. /**
  19939. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19940. * @param subMeshes The submeshes to render
  19941. */
  19942. private renderTransparentSorted;
  19943. /**
  19944. * Renders the submeshes in a specified order.
  19945. * @param subMeshes The submeshes to sort before render
  19946. * @param sortCompareFn The comparison function use to sort
  19947. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19948. * @param transparent Specifies to activate blending if true
  19949. */
  19950. private static renderSorted;
  19951. /**
  19952. * Renders the submeshes in the order they were dispatched (no sort applied).
  19953. * @param subMeshes The submeshes to render
  19954. */
  19955. private static renderUnsorted;
  19956. /**
  19957. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19958. * are rendered back to front if in the same alpha index.
  19959. *
  19960. * @param a The first submesh
  19961. * @param b The second submesh
  19962. * @returns The result of the comparison
  19963. */
  19964. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19965. /**
  19966. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19967. * are rendered back to front.
  19968. *
  19969. * @param a The first submesh
  19970. * @param b The second submesh
  19971. * @returns The result of the comparison
  19972. */
  19973. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19974. /**
  19975. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19976. * are rendered front to back (prevent overdraw).
  19977. *
  19978. * @param a The first submesh
  19979. * @param b The second submesh
  19980. * @returns The result of the comparison
  19981. */
  19982. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19983. /**
  19984. * Resets the different lists of submeshes to prepare a new frame.
  19985. */
  19986. prepare(): void;
  19987. dispose(): void;
  19988. /**
  19989. * Inserts the submesh in its correct queue depending on its material.
  19990. * @param subMesh The submesh to dispatch
  19991. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19992. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19993. */
  19994. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19995. dispatchSprites(spriteManager: ISpriteManager): void;
  19996. dispatchParticles(particleSystem: IParticleSystem): void;
  19997. private _renderParticles;
  19998. private _renderSprites;
  19999. }
  20000. }
  20001. declare module "babylonjs/Rendering/renderingManager" {
  20002. import { Nullable } from "babylonjs/types";
  20003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20005. import { SmartArray } from "babylonjs/Misc/smartArray";
  20006. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20007. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20008. import { Material } from "babylonjs/Materials/material";
  20009. import { Scene } from "babylonjs/scene";
  20010. import { Camera } from "babylonjs/Cameras/camera";
  20011. /**
  20012. * Interface describing the different options available in the rendering manager
  20013. * regarding Auto Clear between groups.
  20014. */
  20015. export interface IRenderingManagerAutoClearSetup {
  20016. /**
  20017. * Defines whether or not autoclear is enable.
  20018. */
  20019. autoClear: boolean;
  20020. /**
  20021. * Defines whether or not to autoclear the depth buffer.
  20022. */
  20023. depth: boolean;
  20024. /**
  20025. * Defines whether or not to autoclear the stencil buffer.
  20026. */
  20027. stencil: boolean;
  20028. }
  20029. /**
  20030. * This class is used by the onRenderingGroupObservable
  20031. */
  20032. export class RenderingGroupInfo {
  20033. /**
  20034. * The Scene that being rendered
  20035. */
  20036. scene: Scene;
  20037. /**
  20038. * The camera currently used for the rendering pass
  20039. */
  20040. camera: Nullable<Camera>;
  20041. /**
  20042. * The ID of the renderingGroup being processed
  20043. */
  20044. renderingGroupId: number;
  20045. }
  20046. /**
  20047. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20048. * It is enable to manage the different groups as well as the different necessary sort functions.
  20049. * This should not be used directly aside of the few static configurations
  20050. */
  20051. export class RenderingManager {
  20052. /**
  20053. * The max id used for rendering groups (not included)
  20054. */
  20055. static MAX_RENDERINGGROUPS: number;
  20056. /**
  20057. * The min id used for rendering groups (included)
  20058. */
  20059. static MIN_RENDERINGGROUPS: number;
  20060. /**
  20061. * Used to globally prevent autoclearing scenes.
  20062. */
  20063. static AUTOCLEAR: boolean;
  20064. /**
  20065. * @hidden
  20066. */
  20067. _useSceneAutoClearSetup: boolean;
  20068. private _scene;
  20069. private _renderingGroups;
  20070. private _depthStencilBufferAlreadyCleaned;
  20071. private _autoClearDepthStencil;
  20072. private _customOpaqueSortCompareFn;
  20073. private _customAlphaTestSortCompareFn;
  20074. private _customTransparentSortCompareFn;
  20075. private _renderingGroupInfo;
  20076. /**
  20077. * Instantiates a new rendering group for a particular scene
  20078. * @param scene Defines the scene the groups belongs to
  20079. */
  20080. constructor(scene: Scene);
  20081. private _clearDepthStencilBuffer;
  20082. /**
  20083. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20084. * @hidden
  20085. */
  20086. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20087. /**
  20088. * Resets the different information of the group to prepare a new frame
  20089. * @hidden
  20090. */
  20091. reset(): void;
  20092. /**
  20093. * Dispose and release the group and its associated resources.
  20094. * @hidden
  20095. */
  20096. dispose(): void;
  20097. /**
  20098. * Clear the info related to rendering groups preventing retention points during dispose.
  20099. */
  20100. freeRenderingGroups(): void;
  20101. private _prepareRenderingGroup;
  20102. /**
  20103. * Add a sprite manager to the rendering manager in order to render it this frame.
  20104. * @param spriteManager Define the sprite manager to render
  20105. */
  20106. dispatchSprites(spriteManager: ISpriteManager): void;
  20107. /**
  20108. * Add a particle system to the rendering manager in order to render it this frame.
  20109. * @param particleSystem Define the particle system to render
  20110. */
  20111. dispatchParticles(particleSystem: IParticleSystem): void;
  20112. /**
  20113. * Add a submesh to the manager in order to render it this frame
  20114. * @param subMesh The submesh to dispatch
  20115. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20116. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20117. */
  20118. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20119. /**
  20120. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20121. * This allowed control for front to back rendering or reversly depending of the special needs.
  20122. *
  20123. * @param renderingGroupId The rendering group id corresponding to its index
  20124. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20125. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20126. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20127. */
  20128. 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;
  20129. /**
  20130. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20131. *
  20132. * @param renderingGroupId The rendering group id corresponding to its index
  20133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20134. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20135. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20136. */
  20137. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20138. /**
  20139. * Gets the current auto clear configuration for one rendering group of the rendering
  20140. * manager.
  20141. * @param index the rendering group index to get the information for
  20142. * @returns The auto clear setup for the requested rendering group
  20143. */
  20144. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20145. }
  20146. }
  20147. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20148. import { Observable } from "babylonjs/Misc/observable";
  20149. import { SmartArray } from "babylonjs/Misc/smartArray";
  20150. import { Nullable } from "babylonjs/types";
  20151. import { Camera } from "babylonjs/Cameras/camera";
  20152. import { Scene } from "babylonjs/scene";
  20153. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20154. import { Color4 } from "babylonjs/Maths/math.color";
  20155. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20159. import { Texture } from "babylonjs/Materials/Textures/texture";
  20160. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20161. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20162. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20163. import { Engine } from "babylonjs/Engines/engine";
  20164. /**
  20165. * This Helps creating a texture that will be created from a camera in your scene.
  20166. * It is basically a dynamic texture that could be used to create special effects for instance.
  20167. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20168. */
  20169. export class RenderTargetTexture extends Texture {
  20170. isCube: boolean;
  20171. /**
  20172. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20173. */
  20174. static readonly REFRESHRATE_RENDER_ONCE: number;
  20175. /**
  20176. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20177. */
  20178. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20179. /**
  20180. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20181. * the central point of your effect and can save a lot of performances.
  20182. */
  20183. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20184. /**
  20185. * Use this predicate to dynamically define the list of mesh you want to render.
  20186. * If set, the renderList property will be overwritten.
  20187. */
  20188. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20189. private _renderList;
  20190. /**
  20191. * Use this list to define the list of mesh you want to render.
  20192. */
  20193. renderList: Nullable<Array<AbstractMesh>>;
  20194. private _hookArray;
  20195. /**
  20196. * Define if particles should be rendered in your texture.
  20197. */
  20198. renderParticles: boolean;
  20199. /**
  20200. * Define if sprites should be rendered in your texture.
  20201. */
  20202. renderSprites: boolean;
  20203. /**
  20204. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20205. */
  20206. coordinatesMode: number;
  20207. /**
  20208. * Define the camera used to render the texture.
  20209. */
  20210. activeCamera: Nullable<Camera>;
  20211. /**
  20212. * Override the render function of the texture with your own one.
  20213. */
  20214. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20215. /**
  20216. * Define if camera post processes should be use while rendering the texture.
  20217. */
  20218. useCameraPostProcesses: boolean;
  20219. /**
  20220. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20221. */
  20222. ignoreCameraViewport: boolean;
  20223. private _postProcessManager;
  20224. private _postProcesses;
  20225. private _resizeObserver;
  20226. /**
  20227. * An event triggered when the texture is unbind.
  20228. */
  20229. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20230. /**
  20231. * An event triggered when the texture is unbind.
  20232. */
  20233. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20234. private _onAfterUnbindObserver;
  20235. /**
  20236. * Set a after unbind callback in the texture.
  20237. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20238. */
  20239. onAfterUnbind: () => void;
  20240. /**
  20241. * An event triggered before rendering the texture
  20242. */
  20243. onBeforeRenderObservable: Observable<number>;
  20244. private _onBeforeRenderObserver;
  20245. /**
  20246. * Set a before render callback in the texture.
  20247. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20248. */
  20249. onBeforeRender: (faceIndex: number) => void;
  20250. /**
  20251. * An event triggered after rendering the texture
  20252. */
  20253. onAfterRenderObservable: Observable<number>;
  20254. private _onAfterRenderObserver;
  20255. /**
  20256. * Set a after render callback in the texture.
  20257. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20258. */
  20259. onAfterRender: (faceIndex: number) => void;
  20260. /**
  20261. * An event triggered after the texture clear
  20262. */
  20263. onClearObservable: Observable<Engine>;
  20264. private _onClearObserver;
  20265. /**
  20266. * Set a clear callback in the texture.
  20267. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20268. */
  20269. onClear: (Engine: Engine) => void;
  20270. /**
  20271. * An event triggered when the texture is resized.
  20272. */
  20273. onResizeObservable: Observable<RenderTargetTexture>;
  20274. /**
  20275. * Define the clear color of the Render Target if it should be different from the scene.
  20276. */
  20277. clearColor: Color4;
  20278. protected _size: number | {
  20279. width: number;
  20280. height: number;
  20281. };
  20282. protected _initialSizeParameter: number | {
  20283. width: number;
  20284. height: number;
  20285. } | {
  20286. ratio: number;
  20287. };
  20288. protected _sizeRatio: Nullable<number>;
  20289. /** @hidden */
  20290. _generateMipMaps: boolean;
  20291. protected _renderingManager: RenderingManager;
  20292. /** @hidden */
  20293. _waitingRenderList: string[];
  20294. protected _doNotChangeAspectRatio: boolean;
  20295. protected _currentRefreshId: number;
  20296. protected _refreshRate: number;
  20297. protected _textureMatrix: Matrix;
  20298. protected _samples: number;
  20299. protected _renderTargetOptions: RenderTargetCreationOptions;
  20300. /**
  20301. * Gets render target creation options that were used.
  20302. */
  20303. readonly renderTargetOptions: RenderTargetCreationOptions;
  20304. protected _engine: Engine;
  20305. protected _onRatioRescale(): void;
  20306. /**
  20307. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20308. * It must define where the camera used to render the texture is set
  20309. */
  20310. boundingBoxPosition: Vector3;
  20311. private _boundingBoxSize;
  20312. /**
  20313. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20314. * When defined, the cubemap will switch to local mode
  20315. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20316. * @example https://www.babylonjs-playground.com/#RNASML
  20317. */
  20318. boundingBoxSize: Vector3;
  20319. /**
  20320. * In case the RTT has been created with a depth texture, get the associated
  20321. * depth texture.
  20322. * Otherwise, return null.
  20323. */
  20324. depthStencilTexture: Nullable<InternalTexture>;
  20325. /**
  20326. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20327. * or used a shadow, depth texture...
  20328. * @param name The friendly name of the texture
  20329. * @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)
  20330. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20331. * @param generateMipMaps True if mip maps need to be generated after render.
  20332. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20333. * @param type The type of the buffer in the RTT (int, half float, float...)
  20334. * @param isCube True if a cube texture needs to be created
  20335. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20336. * @param generateDepthBuffer True to generate a depth buffer
  20337. * @param generateStencilBuffer True to generate a stencil buffer
  20338. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20339. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20340. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20341. */
  20342. constructor(name: string, size: number | {
  20343. width: number;
  20344. height: number;
  20345. } | {
  20346. ratio: number;
  20347. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20348. /**
  20349. * Creates a depth stencil texture.
  20350. * This is only available in WebGL 2 or with the depth texture extension available.
  20351. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20352. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20353. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20354. */
  20355. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20356. private _processSizeParameter;
  20357. /**
  20358. * Define the number of samples to use in case of MSAA.
  20359. * It defaults to one meaning no MSAA has been enabled.
  20360. */
  20361. samples: number;
  20362. /**
  20363. * Resets the refresh counter of the texture and start bak from scratch.
  20364. * Could be useful to regenerate the texture if it is setup to render only once.
  20365. */
  20366. resetRefreshCounter(): void;
  20367. /**
  20368. * Define the refresh rate of the texture or the rendering frequency.
  20369. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20370. */
  20371. refreshRate: number;
  20372. /**
  20373. * Adds a post process to the render target rendering passes.
  20374. * @param postProcess define the post process to add
  20375. */
  20376. addPostProcess(postProcess: PostProcess): void;
  20377. /**
  20378. * Clear all the post processes attached to the render target
  20379. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20380. */
  20381. clearPostProcesses(dispose?: boolean): void;
  20382. /**
  20383. * Remove one of the post process from the list of attached post processes to the texture
  20384. * @param postProcess define the post process to remove from the list
  20385. */
  20386. removePostProcess(postProcess: PostProcess): void;
  20387. /** @hidden */
  20388. _shouldRender(): boolean;
  20389. /**
  20390. * Gets the actual render size of the texture.
  20391. * @returns the width of the render size
  20392. */
  20393. getRenderSize(): number;
  20394. /**
  20395. * Gets the actual render width of the texture.
  20396. * @returns the width of the render size
  20397. */
  20398. getRenderWidth(): number;
  20399. /**
  20400. * Gets the actual render height of the texture.
  20401. * @returns the height of the render size
  20402. */
  20403. getRenderHeight(): number;
  20404. /**
  20405. * Get if the texture can be rescaled or not.
  20406. */
  20407. readonly canRescale: boolean;
  20408. /**
  20409. * Resize the texture using a ratio.
  20410. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20411. */
  20412. scale(ratio: number): void;
  20413. /**
  20414. * Get the texture reflection matrix used to rotate/transform the reflection.
  20415. * @returns the reflection matrix
  20416. */
  20417. getReflectionTextureMatrix(): Matrix;
  20418. /**
  20419. * Resize the texture to a new desired size.
  20420. * Be carrefull as it will recreate all the data in the new texture.
  20421. * @param size Define the new size. It can be:
  20422. * - a number for squared texture,
  20423. * - an object containing { width: number, height: number }
  20424. * - or an object containing a ratio { ratio: number }
  20425. */
  20426. resize(size: number | {
  20427. width: number;
  20428. height: number;
  20429. } | {
  20430. ratio: number;
  20431. }): void;
  20432. /**
  20433. * Renders all the objects from the render list into the texture.
  20434. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20435. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20436. */
  20437. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20438. private _bestReflectionRenderTargetDimension;
  20439. /**
  20440. * @hidden
  20441. * @param faceIndex face index to bind to if this is a cubetexture
  20442. */
  20443. _bindFrameBuffer(faceIndex?: number): void;
  20444. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20445. private renderToTarget;
  20446. /**
  20447. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20448. * This allowed control for front to back rendering or reversly depending of the special needs.
  20449. *
  20450. * @param renderingGroupId The rendering group id corresponding to its index
  20451. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20452. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20453. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20454. */
  20455. 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;
  20456. /**
  20457. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20458. *
  20459. * @param renderingGroupId The rendering group id corresponding to its index
  20460. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20461. */
  20462. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20463. /**
  20464. * Clones the texture.
  20465. * @returns the cloned texture
  20466. */
  20467. clone(): RenderTargetTexture;
  20468. /**
  20469. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20470. * @returns The JSON representation of the texture
  20471. */
  20472. serialize(): any;
  20473. /**
  20474. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20475. */
  20476. disposeFramebufferObjects(): void;
  20477. /**
  20478. * Dispose the texture and release its associated resources.
  20479. */
  20480. dispose(): void;
  20481. /** @hidden */
  20482. _rebuild(): void;
  20483. /**
  20484. * Clear the info related to rendering groups preventing retention point in material dispose.
  20485. */
  20486. freeRenderingGroups(): void;
  20487. /**
  20488. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20489. * @returns the view count
  20490. */
  20491. getViewCount(): number;
  20492. }
  20493. }
  20494. declare module "babylonjs/Materials/material" {
  20495. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20496. import { SmartArray } from "babylonjs/Misc/smartArray";
  20497. import { Observable } from "babylonjs/Misc/observable";
  20498. import { Nullable } from "babylonjs/types";
  20499. import { Scene } from "babylonjs/scene";
  20500. import { Matrix } from "babylonjs/Maths/math.vector";
  20501. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20503. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20504. import { Effect } from "babylonjs/Materials/effect";
  20505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20506. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20507. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20508. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20509. import { Mesh } from "babylonjs/Meshes/mesh";
  20510. import { Animation } from "babylonjs/Animations/animation";
  20511. /**
  20512. * Base class for the main features of a material in Babylon.js
  20513. */
  20514. export class Material implements IAnimatable {
  20515. /**
  20516. * Returns the triangle fill mode
  20517. */
  20518. static readonly TriangleFillMode: number;
  20519. /**
  20520. * Returns the wireframe mode
  20521. */
  20522. static readonly WireFrameFillMode: number;
  20523. /**
  20524. * Returns the point fill mode
  20525. */
  20526. static readonly PointFillMode: number;
  20527. /**
  20528. * Returns the point list draw mode
  20529. */
  20530. static readonly PointListDrawMode: number;
  20531. /**
  20532. * Returns the line list draw mode
  20533. */
  20534. static readonly LineListDrawMode: number;
  20535. /**
  20536. * Returns the line loop draw mode
  20537. */
  20538. static readonly LineLoopDrawMode: number;
  20539. /**
  20540. * Returns the line strip draw mode
  20541. */
  20542. static readonly LineStripDrawMode: number;
  20543. /**
  20544. * Returns the triangle strip draw mode
  20545. */
  20546. static readonly TriangleStripDrawMode: number;
  20547. /**
  20548. * Returns the triangle fan draw mode
  20549. */
  20550. static readonly TriangleFanDrawMode: number;
  20551. /**
  20552. * Stores the clock-wise side orientation
  20553. */
  20554. static readonly ClockWiseSideOrientation: number;
  20555. /**
  20556. * Stores the counter clock-wise side orientation
  20557. */
  20558. static readonly CounterClockWiseSideOrientation: number;
  20559. /**
  20560. * The dirty texture flag value
  20561. */
  20562. static readonly TextureDirtyFlag: number;
  20563. /**
  20564. * The dirty light flag value
  20565. */
  20566. static readonly LightDirtyFlag: number;
  20567. /**
  20568. * The dirty fresnel flag value
  20569. */
  20570. static readonly FresnelDirtyFlag: number;
  20571. /**
  20572. * The dirty attribute flag value
  20573. */
  20574. static readonly AttributesDirtyFlag: number;
  20575. /**
  20576. * The dirty misc flag value
  20577. */
  20578. static readonly MiscDirtyFlag: number;
  20579. /**
  20580. * The all dirty flag value
  20581. */
  20582. static readonly AllDirtyFlag: number;
  20583. /**
  20584. * The ID of the material
  20585. */
  20586. id: string;
  20587. /**
  20588. * Gets or sets the unique id of the material
  20589. */
  20590. uniqueId: number;
  20591. /**
  20592. * The name of the material
  20593. */
  20594. name: string;
  20595. /**
  20596. * Gets or sets user defined metadata
  20597. */
  20598. metadata: any;
  20599. /**
  20600. * For internal use only. Please do not use.
  20601. */
  20602. reservedDataStore: any;
  20603. /**
  20604. * Specifies if the ready state should be checked on each call
  20605. */
  20606. checkReadyOnEveryCall: boolean;
  20607. /**
  20608. * Specifies if the ready state should be checked once
  20609. */
  20610. checkReadyOnlyOnce: boolean;
  20611. /**
  20612. * The state of the material
  20613. */
  20614. state: string;
  20615. /**
  20616. * The alpha value of the material
  20617. */
  20618. protected _alpha: number;
  20619. /**
  20620. * List of inspectable custom properties (used by the Inspector)
  20621. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20622. */
  20623. inspectableCustomProperties: IInspectable[];
  20624. /**
  20625. * Sets the alpha value of the material
  20626. */
  20627. /**
  20628. * Gets the alpha value of the material
  20629. */
  20630. alpha: number;
  20631. /**
  20632. * Specifies if back face culling is enabled
  20633. */
  20634. protected _backFaceCulling: boolean;
  20635. /**
  20636. * Sets the back-face culling state
  20637. */
  20638. /**
  20639. * Gets the back-face culling state
  20640. */
  20641. backFaceCulling: boolean;
  20642. /**
  20643. * Stores the value for side orientation
  20644. */
  20645. sideOrientation: number;
  20646. /**
  20647. * Callback triggered when the material is compiled
  20648. */
  20649. onCompiled: Nullable<(effect: Effect) => void>;
  20650. /**
  20651. * Callback triggered when an error occurs
  20652. */
  20653. onError: Nullable<(effect: Effect, errors: string) => void>;
  20654. /**
  20655. * Callback triggered to get the render target textures
  20656. */
  20657. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20658. /**
  20659. * Gets a boolean indicating that current material needs to register RTT
  20660. */
  20661. readonly hasRenderTargetTextures: boolean;
  20662. /**
  20663. * Specifies if the material should be serialized
  20664. */
  20665. doNotSerialize: boolean;
  20666. /**
  20667. * @hidden
  20668. */
  20669. _storeEffectOnSubMeshes: boolean;
  20670. /**
  20671. * Stores the animations for the material
  20672. */
  20673. animations: Nullable<Array<Animation>>;
  20674. /**
  20675. * An event triggered when the material is disposed
  20676. */
  20677. onDisposeObservable: Observable<Material>;
  20678. /**
  20679. * An observer which watches for dispose events
  20680. */
  20681. private _onDisposeObserver;
  20682. private _onUnBindObservable;
  20683. /**
  20684. * Called during a dispose event
  20685. */
  20686. onDispose: () => void;
  20687. private _onBindObservable;
  20688. /**
  20689. * An event triggered when the material is bound
  20690. */
  20691. readonly onBindObservable: Observable<AbstractMesh>;
  20692. /**
  20693. * An observer which watches for bind events
  20694. */
  20695. private _onBindObserver;
  20696. /**
  20697. * Called during a bind event
  20698. */
  20699. onBind: (Mesh: AbstractMesh) => void;
  20700. /**
  20701. * An event triggered when the material is unbound
  20702. */
  20703. readonly onUnBindObservable: Observable<Material>;
  20704. /**
  20705. * Stores the value of the alpha mode
  20706. */
  20707. private _alphaMode;
  20708. /**
  20709. * Sets the value of the alpha mode.
  20710. *
  20711. * | Value | Type | Description |
  20712. * | --- | --- | --- |
  20713. * | 0 | ALPHA_DISABLE | |
  20714. * | 1 | ALPHA_ADD | |
  20715. * | 2 | ALPHA_COMBINE | |
  20716. * | 3 | ALPHA_SUBTRACT | |
  20717. * | 4 | ALPHA_MULTIPLY | |
  20718. * | 5 | ALPHA_MAXIMIZED | |
  20719. * | 6 | ALPHA_ONEONE | |
  20720. * | 7 | ALPHA_PREMULTIPLIED | |
  20721. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20722. * | 9 | ALPHA_INTERPOLATE | |
  20723. * | 10 | ALPHA_SCREENMODE | |
  20724. *
  20725. */
  20726. /**
  20727. * Gets the value of the alpha mode
  20728. */
  20729. alphaMode: number;
  20730. /**
  20731. * Stores the state of the need depth pre-pass value
  20732. */
  20733. private _needDepthPrePass;
  20734. /**
  20735. * Sets the need depth pre-pass value
  20736. */
  20737. /**
  20738. * Gets the depth pre-pass value
  20739. */
  20740. needDepthPrePass: boolean;
  20741. /**
  20742. * Specifies if depth writing should be disabled
  20743. */
  20744. disableDepthWrite: boolean;
  20745. /**
  20746. * Specifies if depth writing should be forced
  20747. */
  20748. forceDepthWrite: boolean;
  20749. /**
  20750. * Specifies if there should be a separate pass for culling
  20751. */
  20752. separateCullingPass: boolean;
  20753. /**
  20754. * Stores the state specifing if fog should be enabled
  20755. */
  20756. private _fogEnabled;
  20757. /**
  20758. * Sets the state for enabling fog
  20759. */
  20760. /**
  20761. * Gets the value of the fog enabled state
  20762. */
  20763. fogEnabled: boolean;
  20764. /**
  20765. * Stores the size of points
  20766. */
  20767. pointSize: number;
  20768. /**
  20769. * Stores the z offset value
  20770. */
  20771. zOffset: number;
  20772. /**
  20773. * Gets a value specifying if wireframe mode is enabled
  20774. */
  20775. /**
  20776. * Sets the state of wireframe mode
  20777. */
  20778. wireframe: boolean;
  20779. /**
  20780. * Gets the value specifying if point clouds are enabled
  20781. */
  20782. /**
  20783. * Sets the state of point cloud mode
  20784. */
  20785. pointsCloud: boolean;
  20786. /**
  20787. * Gets the material fill mode
  20788. */
  20789. /**
  20790. * Sets the material fill mode
  20791. */
  20792. fillMode: number;
  20793. /**
  20794. * @hidden
  20795. * Stores the effects for the material
  20796. */
  20797. _effect: Nullable<Effect>;
  20798. /**
  20799. * @hidden
  20800. * Specifies if the material was previously ready
  20801. */
  20802. _wasPreviouslyReady: boolean;
  20803. /**
  20804. * Specifies if uniform buffers should be used
  20805. */
  20806. private _useUBO;
  20807. /**
  20808. * Stores a reference to the scene
  20809. */
  20810. private _scene;
  20811. /**
  20812. * Stores the fill mode state
  20813. */
  20814. private _fillMode;
  20815. /**
  20816. * Specifies if the depth write state should be cached
  20817. */
  20818. private _cachedDepthWriteState;
  20819. /**
  20820. * Stores the uniform buffer
  20821. */
  20822. protected _uniformBuffer: UniformBuffer;
  20823. /** @hidden */
  20824. _indexInSceneMaterialArray: number;
  20825. /** @hidden */
  20826. meshMap: Nullable<{
  20827. [id: string]: AbstractMesh | undefined;
  20828. }>;
  20829. /**
  20830. * Creates a material instance
  20831. * @param name defines the name of the material
  20832. * @param scene defines the scene to reference
  20833. * @param doNotAdd specifies if the material should be added to the scene
  20834. */
  20835. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20836. /**
  20837. * Returns a string representation of the current material
  20838. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20839. * @returns a string with material information
  20840. */
  20841. toString(fullDetails?: boolean): string;
  20842. /**
  20843. * Gets the class name of the material
  20844. * @returns a string with the class name of the material
  20845. */
  20846. getClassName(): string;
  20847. /**
  20848. * Specifies if updates for the material been locked
  20849. */
  20850. readonly isFrozen: boolean;
  20851. /**
  20852. * Locks updates for the material
  20853. */
  20854. freeze(): void;
  20855. /**
  20856. * Unlocks updates for the material
  20857. */
  20858. unfreeze(): void;
  20859. /**
  20860. * Specifies if the material is ready to be used
  20861. * @param mesh defines the mesh to check
  20862. * @param useInstances specifies if instances should be used
  20863. * @returns a boolean indicating if the material is ready to be used
  20864. */
  20865. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20866. /**
  20867. * Specifies that the submesh is ready to be used
  20868. * @param mesh defines the mesh to check
  20869. * @param subMesh defines which submesh to check
  20870. * @param useInstances specifies that instances should be used
  20871. * @returns a boolean indicating that the submesh is ready or not
  20872. */
  20873. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20874. /**
  20875. * Returns the material effect
  20876. * @returns the effect associated with the material
  20877. */
  20878. getEffect(): Nullable<Effect>;
  20879. /**
  20880. * Returns the current scene
  20881. * @returns a Scene
  20882. */
  20883. getScene(): Scene;
  20884. /**
  20885. * Specifies if the material will require alpha blending
  20886. * @returns a boolean specifying if alpha blending is needed
  20887. */
  20888. needAlphaBlending(): boolean;
  20889. /**
  20890. * Specifies if the mesh will require alpha blending
  20891. * @param mesh defines the mesh to check
  20892. * @returns a boolean specifying if alpha blending is needed for the mesh
  20893. */
  20894. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20895. /**
  20896. * Specifies if this material should be rendered in alpha test mode
  20897. * @returns a boolean specifying if an alpha test is needed.
  20898. */
  20899. needAlphaTesting(): boolean;
  20900. /**
  20901. * Gets the texture used for the alpha test
  20902. * @returns the texture to use for alpha testing
  20903. */
  20904. getAlphaTestTexture(): Nullable<BaseTexture>;
  20905. /**
  20906. * Marks the material to indicate that it needs to be re-calculated
  20907. */
  20908. markDirty(): void;
  20909. /** @hidden */
  20910. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20911. /**
  20912. * Binds the material to the mesh
  20913. * @param world defines the world transformation matrix
  20914. * @param mesh defines the mesh to bind the material to
  20915. */
  20916. bind(world: Matrix, mesh?: Mesh): void;
  20917. /**
  20918. * Binds the submesh to the material
  20919. * @param world defines the world transformation matrix
  20920. * @param mesh defines the mesh containing the submesh
  20921. * @param subMesh defines the submesh to bind the material to
  20922. */
  20923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20924. /**
  20925. * Binds the world matrix to the material
  20926. * @param world defines the world transformation matrix
  20927. */
  20928. bindOnlyWorldMatrix(world: Matrix): void;
  20929. /**
  20930. * Binds the scene's uniform buffer to the effect.
  20931. * @param effect defines the effect to bind to the scene uniform buffer
  20932. * @param sceneUbo defines the uniform buffer storing scene data
  20933. */
  20934. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20935. /**
  20936. * Binds the view matrix to the effect
  20937. * @param effect defines the effect to bind the view matrix to
  20938. */
  20939. bindView(effect: Effect): void;
  20940. /**
  20941. * Binds the view projection matrix to the effect
  20942. * @param effect defines the effect to bind the view projection matrix to
  20943. */
  20944. bindViewProjection(effect: Effect): void;
  20945. /**
  20946. * Specifies if material alpha testing should be turned on for the mesh
  20947. * @param mesh defines the mesh to check
  20948. */
  20949. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20950. /**
  20951. * Processes to execute after binding the material to a mesh
  20952. * @param mesh defines the rendered mesh
  20953. */
  20954. protected _afterBind(mesh?: Mesh): void;
  20955. /**
  20956. * Unbinds the material from the mesh
  20957. */
  20958. unbind(): void;
  20959. /**
  20960. * Gets the active textures from the material
  20961. * @returns an array of textures
  20962. */
  20963. getActiveTextures(): BaseTexture[];
  20964. /**
  20965. * Specifies if the material uses a texture
  20966. * @param texture defines the texture to check against the material
  20967. * @returns a boolean specifying if the material uses the texture
  20968. */
  20969. hasTexture(texture: BaseTexture): boolean;
  20970. /**
  20971. * Makes a duplicate of the material, and gives it a new name
  20972. * @param name defines the new name for the duplicated material
  20973. * @returns the cloned material
  20974. */
  20975. clone(name: string): Nullable<Material>;
  20976. /**
  20977. * Gets the meshes bound to the material
  20978. * @returns an array of meshes bound to the material
  20979. */
  20980. getBindedMeshes(): AbstractMesh[];
  20981. /**
  20982. * Force shader compilation
  20983. * @param mesh defines the mesh associated with this material
  20984. * @param onCompiled defines a function to execute once the material is compiled
  20985. * @param options defines the options to configure the compilation
  20986. */
  20987. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20988. clipPlane: boolean;
  20989. }>): void;
  20990. /**
  20991. * Force shader compilation
  20992. * @param mesh defines the mesh that will use this material
  20993. * @param options defines additional options for compiling the shaders
  20994. * @returns a promise that resolves when the compilation completes
  20995. */
  20996. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20997. clipPlane: boolean;
  20998. }>): Promise<void>;
  20999. private static readonly _AllDirtyCallBack;
  21000. private static readonly _ImageProcessingDirtyCallBack;
  21001. private static readonly _TextureDirtyCallBack;
  21002. private static readonly _FresnelDirtyCallBack;
  21003. private static readonly _MiscDirtyCallBack;
  21004. private static readonly _LightsDirtyCallBack;
  21005. private static readonly _AttributeDirtyCallBack;
  21006. private static _FresnelAndMiscDirtyCallBack;
  21007. private static _TextureAndMiscDirtyCallBack;
  21008. private static readonly _DirtyCallbackArray;
  21009. private static readonly _RunDirtyCallBacks;
  21010. /**
  21011. * Marks a define in the material to indicate that it needs to be re-computed
  21012. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21013. */
  21014. markAsDirty(flag: number): void;
  21015. /**
  21016. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21017. * @param func defines a function which checks material defines against the submeshes
  21018. */
  21019. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21020. /**
  21021. * Indicates that we need to re-calculated for all submeshes
  21022. */
  21023. protected _markAllSubMeshesAsAllDirty(): void;
  21024. /**
  21025. * Indicates that image processing needs to be re-calculated for all submeshes
  21026. */
  21027. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21028. /**
  21029. * Indicates that textures need to be re-calculated for all submeshes
  21030. */
  21031. protected _markAllSubMeshesAsTexturesDirty(): void;
  21032. /**
  21033. * Indicates that fresnel needs to be re-calculated for all submeshes
  21034. */
  21035. protected _markAllSubMeshesAsFresnelDirty(): void;
  21036. /**
  21037. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21038. */
  21039. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21040. /**
  21041. * Indicates that lights need to be re-calculated for all submeshes
  21042. */
  21043. protected _markAllSubMeshesAsLightsDirty(): void;
  21044. /**
  21045. * Indicates that attributes need to be re-calculated for all submeshes
  21046. */
  21047. protected _markAllSubMeshesAsAttributesDirty(): void;
  21048. /**
  21049. * Indicates that misc needs to be re-calculated for all submeshes
  21050. */
  21051. protected _markAllSubMeshesAsMiscDirty(): void;
  21052. /**
  21053. * Indicates that textures and misc need to be re-calculated for all submeshes
  21054. */
  21055. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21056. /**
  21057. * Disposes the material
  21058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21061. */
  21062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21063. /** @hidden */
  21064. private releaseVertexArrayObject;
  21065. /**
  21066. * Serializes this material
  21067. * @returns the serialized material object
  21068. */
  21069. serialize(): any;
  21070. /**
  21071. * Creates a material from parsed material data
  21072. * @param parsedMaterial defines parsed material data
  21073. * @param scene defines the hosting scene
  21074. * @param rootUrl defines the root URL to use to load textures
  21075. * @returns a new material
  21076. */
  21077. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21078. }
  21079. }
  21080. declare module "babylonjs/Materials/multiMaterial" {
  21081. import { Nullable } from "babylonjs/types";
  21082. import { Scene } from "babylonjs/scene";
  21083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21084. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21086. import { Material } from "babylonjs/Materials/material";
  21087. /**
  21088. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21089. * separate meshes. This can be use to improve performances.
  21090. * @see http://doc.babylonjs.com/how_to/multi_materials
  21091. */
  21092. export class MultiMaterial extends Material {
  21093. private _subMaterials;
  21094. /**
  21095. * Gets or Sets the list of Materials used within the multi material.
  21096. * They need to be ordered according to the submeshes order in the associated mesh
  21097. */
  21098. subMaterials: Nullable<Material>[];
  21099. /**
  21100. * Function used to align with Node.getChildren()
  21101. * @returns the list of Materials used within the multi material
  21102. */
  21103. getChildren(): Nullable<Material>[];
  21104. /**
  21105. * Instantiates a new Multi Material
  21106. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21107. * separate meshes. This can be use to improve performances.
  21108. * @see http://doc.babylonjs.com/how_to/multi_materials
  21109. * @param name Define the name in the scene
  21110. * @param scene Define the scene the material belongs to
  21111. */
  21112. constructor(name: string, scene: Scene);
  21113. private _hookArray;
  21114. /**
  21115. * Get one of the submaterial by its index in the submaterials array
  21116. * @param index The index to look the sub material at
  21117. * @returns The Material if the index has been defined
  21118. */
  21119. getSubMaterial(index: number): Nullable<Material>;
  21120. /**
  21121. * Get the list of active textures for the whole sub materials list.
  21122. * @returns All the textures that will be used during the rendering
  21123. */
  21124. getActiveTextures(): BaseTexture[];
  21125. /**
  21126. * Gets the current class name of the material e.g. "MultiMaterial"
  21127. * Mainly use in serialization.
  21128. * @returns the class name
  21129. */
  21130. getClassName(): string;
  21131. /**
  21132. * Checks if the material is ready to render the requested sub mesh
  21133. * @param mesh Define the mesh the submesh belongs to
  21134. * @param subMesh Define the sub mesh to look readyness for
  21135. * @param useInstances Define whether or not the material is used with instances
  21136. * @returns true if ready, otherwise false
  21137. */
  21138. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21139. /**
  21140. * Clones the current material and its related sub materials
  21141. * @param name Define the name of the newly cloned material
  21142. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21143. * @returns the cloned material
  21144. */
  21145. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21146. /**
  21147. * Serializes the materials into a JSON representation.
  21148. * @returns the JSON representation
  21149. */
  21150. serialize(): any;
  21151. /**
  21152. * Dispose the material and release its associated resources
  21153. * @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)
  21154. * @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)
  21155. * @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)
  21156. */
  21157. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21158. /**
  21159. * Creates a MultiMaterial from parsed MultiMaterial data.
  21160. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21161. * @param scene defines the hosting scene
  21162. * @returns a new MultiMaterial
  21163. */
  21164. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21165. }
  21166. }
  21167. declare module "babylonjs/Meshes/subMesh" {
  21168. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21169. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21170. import { Engine } from "babylonjs/Engines/engine";
  21171. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21172. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21173. import { Effect } from "babylonjs/Materials/effect";
  21174. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21175. import { Plane } from "babylonjs/Maths/math.plane";
  21176. import { Collider } from "babylonjs/Collisions/collider";
  21177. import { Material } from "babylonjs/Materials/material";
  21178. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21180. import { Mesh } from "babylonjs/Meshes/mesh";
  21181. import { Ray } from "babylonjs/Culling/ray";
  21182. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21183. /**
  21184. * Base class for submeshes
  21185. */
  21186. export class BaseSubMesh {
  21187. /** @hidden */
  21188. _materialDefines: Nullable<MaterialDefines>;
  21189. /** @hidden */
  21190. _materialEffect: Nullable<Effect>;
  21191. /**
  21192. * Gets associated effect
  21193. */
  21194. readonly effect: Nullable<Effect>;
  21195. /**
  21196. * Sets associated effect (effect used to render this submesh)
  21197. * @param effect defines the effect to associate with
  21198. * @param defines defines the set of defines used to compile this effect
  21199. */
  21200. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21201. }
  21202. /**
  21203. * Defines a subdivision inside a mesh
  21204. */
  21205. export class SubMesh extends BaseSubMesh implements ICullable {
  21206. /** the material index to use */
  21207. materialIndex: number;
  21208. /** vertex index start */
  21209. verticesStart: number;
  21210. /** vertices count */
  21211. verticesCount: number;
  21212. /** index start */
  21213. indexStart: number;
  21214. /** indices count */
  21215. indexCount: number;
  21216. /** @hidden */
  21217. _linesIndexCount: number;
  21218. private _mesh;
  21219. private _renderingMesh;
  21220. private _boundingInfo;
  21221. private _linesIndexBuffer;
  21222. /** @hidden */
  21223. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21224. /** @hidden */
  21225. _trianglePlanes: Plane[];
  21226. /** @hidden */
  21227. _lastColliderTransformMatrix: Nullable<Matrix>;
  21228. /** @hidden */
  21229. _renderId: number;
  21230. /** @hidden */
  21231. _alphaIndex: number;
  21232. /** @hidden */
  21233. _distanceToCamera: number;
  21234. /** @hidden */
  21235. _id: number;
  21236. private _currentMaterial;
  21237. /**
  21238. * Add a new submesh to a mesh
  21239. * @param materialIndex defines the material index to use
  21240. * @param verticesStart defines vertex index start
  21241. * @param verticesCount defines vertices count
  21242. * @param indexStart defines index start
  21243. * @param indexCount defines indices count
  21244. * @param mesh defines the parent mesh
  21245. * @param renderingMesh defines an optional rendering mesh
  21246. * @param createBoundingBox defines if bounding box should be created for this submesh
  21247. * @returns the new submesh
  21248. */
  21249. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21250. /**
  21251. * Creates a new submesh
  21252. * @param materialIndex defines the material index to use
  21253. * @param verticesStart defines vertex index start
  21254. * @param verticesCount defines vertices count
  21255. * @param indexStart defines index start
  21256. * @param indexCount defines indices count
  21257. * @param mesh defines the parent mesh
  21258. * @param renderingMesh defines an optional rendering mesh
  21259. * @param createBoundingBox defines if bounding box should be created for this submesh
  21260. */
  21261. constructor(
  21262. /** the material index to use */
  21263. materialIndex: number,
  21264. /** vertex index start */
  21265. verticesStart: number,
  21266. /** vertices count */
  21267. verticesCount: number,
  21268. /** index start */
  21269. indexStart: number,
  21270. /** indices count */
  21271. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21272. /**
  21273. * Returns true if this submesh covers the entire parent mesh
  21274. * @ignorenaming
  21275. */
  21276. readonly IsGlobal: boolean;
  21277. /**
  21278. * Returns the submesh BoudingInfo object
  21279. * @returns current bounding info (or mesh's one if the submesh is global)
  21280. */
  21281. getBoundingInfo(): BoundingInfo;
  21282. /**
  21283. * Sets the submesh BoundingInfo
  21284. * @param boundingInfo defines the new bounding info to use
  21285. * @returns the SubMesh
  21286. */
  21287. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21288. /**
  21289. * Returns the mesh of the current submesh
  21290. * @return the parent mesh
  21291. */
  21292. getMesh(): AbstractMesh;
  21293. /**
  21294. * Returns the rendering mesh of the submesh
  21295. * @returns the rendering mesh (could be different from parent mesh)
  21296. */
  21297. getRenderingMesh(): Mesh;
  21298. /**
  21299. * Returns the submesh material
  21300. * @returns null or the current material
  21301. */
  21302. getMaterial(): Nullable<Material>;
  21303. /**
  21304. * Sets a new updated BoundingInfo object to the submesh
  21305. * @param data defines an optional position array to use to determine the bounding info
  21306. * @returns the SubMesh
  21307. */
  21308. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21309. /** @hidden */
  21310. _checkCollision(collider: Collider): boolean;
  21311. /**
  21312. * Updates the submesh BoundingInfo
  21313. * @param world defines the world matrix to use to update the bounding info
  21314. * @returns the submesh
  21315. */
  21316. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21317. /**
  21318. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21319. * @param frustumPlanes defines the frustum planes
  21320. * @returns true if the submesh is intersecting with the frustum
  21321. */
  21322. isInFrustum(frustumPlanes: Plane[]): boolean;
  21323. /**
  21324. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21325. * @param frustumPlanes defines the frustum planes
  21326. * @returns true if the submesh is inside the frustum
  21327. */
  21328. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21329. /**
  21330. * Renders the submesh
  21331. * @param enableAlphaMode defines if alpha needs to be used
  21332. * @returns the submesh
  21333. */
  21334. render(enableAlphaMode: boolean): SubMesh;
  21335. /**
  21336. * @hidden
  21337. */
  21338. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21339. /**
  21340. * Checks if the submesh intersects with a ray
  21341. * @param ray defines the ray to test
  21342. * @returns true is the passed ray intersects the submesh bounding box
  21343. */
  21344. canIntersects(ray: Ray): boolean;
  21345. /**
  21346. * Intersects current submesh with a ray
  21347. * @param ray defines the ray to test
  21348. * @param positions defines mesh's positions array
  21349. * @param indices defines mesh's indices array
  21350. * @param fastCheck defines if only bounding info should be used
  21351. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21352. * @returns intersection info or null if no intersection
  21353. */
  21354. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21355. /** @hidden */
  21356. private _intersectLines;
  21357. /** @hidden */
  21358. private _intersectUnIndexedLines;
  21359. /** @hidden */
  21360. private _intersectTriangles;
  21361. /** @hidden */
  21362. private _intersectUnIndexedTriangles;
  21363. /** @hidden */
  21364. _rebuild(): void;
  21365. /**
  21366. * Creates a new submesh from the passed mesh
  21367. * @param newMesh defines the new hosting mesh
  21368. * @param newRenderingMesh defines an optional rendering mesh
  21369. * @returns the new submesh
  21370. */
  21371. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21372. /**
  21373. * Release associated resources
  21374. */
  21375. dispose(): void;
  21376. /**
  21377. * Gets the class name
  21378. * @returns the string "SubMesh".
  21379. */
  21380. getClassName(): string;
  21381. /**
  21382. * Creates a new submesh from indices data
  21383. * @param materialIndex the index of the main mesh material
  21384. * @param startIndex the index where to start the copy in the mesh indices array
  21385. * @param indexCount the number of indices to copy then from the startIndex
  21386. * @param mesh the main mesh to create the submesh from
  21387. * @param renderingMesh the optional rendering mesh
  21388. * @returns a new submesh
  21389. */
  21390. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21391. }
  21392. }
  21393. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21394. /**
  21395. * Class used to represent data loading progression
  21396. */
  21397. export class SceneLoaderFlags {
  21398. private static _ForceFullSceneLoadingForIncremental;
  21399. private static _ShowLoadingScreen;
  21400. private static _CleanBoneMatrixWeights;
  21401. private static _loggingLevel;
  21402. /**
  21403. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21404. */
  21405. static ForceFullSceneLoadingForIncremental: boolean;
  21406. /**
  21407. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21408. */
  21409. static ShowLoadingScreen: boolean;
  21410. /**
  21411. * Defines the current logging level (while loading the scene)
  21412. * @ignorenaming
  21413. */
  21414. static loggingLevel: number;
  21415. /**
  21416. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21417. */
  21418. static CleanBoneMatrixWeights: boolean;
  21419. }
  21420. }
  21421. declare module "babylonjs/Meshes/geometry" {
  21422. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21423. import { Scene } from "babylonjs/scene";
  21424. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21425. import { Engine } from "babylonjs/Engines/engine";
  21426. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21427. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21428. import { Effect } from "babylonjs/Materials/effect";
  21429. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21430. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21431. import { Mesh } from "babylonjs/Meshes/mesh";
  21432. /**
  21433. * Class used to store geometry data (vertex buffers + index buffer)
  21434. */
  21435. export class Geometry implements IGetSetVerticesData {
  21436. /**
  21437. * Gets or sets the ID of the geometry
  21438. */
  21439. id: string;
  21440. /**
  21441. * Gets or sets the unique ID of the geometry
  21442. */
  21443. uniqueId: number;
  21444. /**
  21445. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21446. */
  21447. delayLoadState: number;
  21448. /**
  21449. * Gets the file containing the data to load when running in delay load state
  21450. */
  21451. delayLoadingFile: Nullable<string>;
  21452. /**
  21453. * Callback called when the geometry is updated
  21454. */
  21455. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21456. private _scene;
  21457. private _engine;
  21458. private _meshes;
  21459. private _totalVertices;
  21460. /** @hidden */
  21461. _indices: IndicesArray;
  21462. /** @hidden */
  21463. _vertexBuffers: {
  21464. [key: string]: VertexBuffer;
  21465. };
  21466. private _isDisposed;
  21467. private _extend;
  21468. private _boundingBias;
  21469. /** @hidden */
  21470. _delayInfo: Array<string>;
  21471. private _indexBuffer;
  21472. private _indexBufferIsUpdatable;
  21473. /** @hidden */
  21474. _boundingInfo: Nullable<BoundingInfo>;
  21475. /** @hidden */
  21476. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21477. /** @hidden */
  21478. _softwareSkinningFrameId: number;
  21479. private _vertexArrayObjects;
  21480. private _updatable;
  21481. /** @hidden */
  21482. _positions: Nullable<Vector3[]>;
  21483. /**
  21484. * 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
  21485. */
  21486. /**
  21487. * 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
  21488. */
  21489. boundingBias: Vector2;
  21490. /**
  21491. * Static function used to attach a new empty geometry to a mesh
  21492. * @param mesh defines the mesh to attach the geometry to
  21493. * @returns the new Geometry
  21494. */
  21495. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21496. /**
  21497. * Creates a new geometry
  21498. * @param id defines the unique ID
  21499. * @param scene defines the hosting scene
  21500. * @param vertexData defines the VertexData used to get geometry data
  21501. * @param updatable defines if geometry must be updatable (false by default)
  21502. * @param mesh defines the mesh that will be associated with the geometry
  21503. */
  21504. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21505. /**
  21506. * Gets the current extend of the geometry
  21507. */
  21508. readonly extend: {
  21509. minimum: Vector3;
  21510. maximum: Vector3;
  21511. };
  21512. /**
  21513. * Gets the hosting scene
  21514. * @returns the hosting Scene
  21515. */
  21516. getScene(): Scene;
  21517. /**
  21518. * Gets the hosting engine
  21519. * @returns the hosting Engine
  21520. */
  21521. getEngine(): Engine;
  21522. /**
  21523. * Defines if the geometry is ready to use
  21524. * @returns true if the geometry is ready to be used
  21525. */
  21526. isReady(): boolean;
  21527. /**
  21528. * Gets a value indicating that the geometry should not be serialized
  21529. */
  21530. readonly doNotSerialize: boolean;
  21531. /** @hidden */
  21532. _rebuild(): void;
  21533. /**
  21534. * Affects all geometry data in one call
  21535. * @param vertexData defines the geometry data
  21536. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21537. */
  21538. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21539. /**
  21540. * Set specific vertex data
  21541. * @param kind defines the data kind (Position, normal, etc...)
  21542. * @param data defines the vertex data to use
  21543. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21544. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21545. */
  21546. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21547. /**
  21548. * Removes a specific vertex data
  21549. * @param kind defines the data kind (Position, normal, etc...)
  21550. */
  21551. removeVerticesData(kind: string): void;
  21552. /**
  21553. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21554. * @param buffer defines the vertex buffer to use
  21555. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21556. */
  21557. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21558. /**
  21559. * Update a specific vertex buffer
  21560. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21561. * It will do nothing if the buffer is not updatable
  21562. * @param kind defines the data kind (Position, normal, etc...)
  21563. * @param data defines the data to use
  21564. * @param offset defines the offset in the target buffer where to store the data
  21565. * @param useBytes set to true if the offset is in bytes
  21566. */
  21567. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21568. /**
  21569. * Update a specific vertex buffer
  21570. * This function will create a new buffer if the current one is not updatable
  21571. * @param kind defines the data kind (Position, normal, etc...)
  21572. * @param data defines the data to use
  21573. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21574. */
  21575. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21576. private _updateBoundingInfo;
  21577. /** @hidden */
  21578. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21579. /**
  21580. * Gets total number of vertices
  21581. * @returns the total number of vertices
  21582. */
  21583. getTotalVertices(): number;
  21584. /**
  21585. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21586. * @param kind defines the data kind (Position, normal, etc...)
  21587. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21588. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21589. * @returns a float array containing vertex data
  21590. */
  21591. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21592. /**
  21593. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21594. * @param kind defines the data kind (Position, normal, etc...)
  21595. * @returns true if the vertex buffer with the specified kind is updatable
  21596. */
  21597. isVertexBufferUpdatable(kind: string): boolean;
  21598. /**
  21599. * Gets a specific vertex buffer
  21600. * @param kind defines the data kind (Position, normal, etc...)
  21601. * @returns a VertexBuffer
  21602. */
  21603. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21604. /**
  21605. * Returns all vertex buffers
  21606. * @return an object holding all vertex buffers indexed by kind
  21607. */
  21608. getVertexBuffers(): Nullable<{
  21609. [key: string]: VertexBuffer;
  21610. }>;
  21611. /**
  21612. * Gets a boolean indicating if specific vertex buffer is present
  21613. * @param kind defines the data kind (Position, normal, etc...)
  21614. * @returns true if data is present
  21615. */
  21616. isVerticesDataPresent(kind: string): boolean;
  21617. /**
  21618. * Gets a list of all attached data kinds (Position, normal, etc...)
  21619. * @returns a list of string containing all kinds
  21620. */
  21621. getVerticesDataKinds(): string[];
  21622. /**
  21623. * Update index buffer
  21624. * @param indices defines the indices to store in the index buffer
  21625. * @param offset defines the offset in the target buffer where to store the data
  21626. * @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)
  21627. */
  21628. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21629. /**
  21630. * Creates a new index buffer
  21631. * @param indices defines the indices to store in the index buffer
  21632. * @param totalVertices defines the total number of vertices (could be null)
  21633. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21634. */
  21635. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21636. /**
  21637. * Return the total number of indices
  21638. * @returns the total number of indices
  21639. */
  21640. getTotalIndices(): number;
  21641. /**
  21642. * Gets the index buffer array
  21643. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21644. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21645. * @returns the index buffer array
  21646. */
  21647. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21648. /**
  21649. * Gets the index buffer
  21650. * @return the index buffer
  21651. */
  21652. getIndexBuffer(): Nullable<DataBuffer>;
  21653. /** @hidden */
  21654. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21655. /**
  21656. * Release the associated resources for a specific mesh
  21657. * @param mesh defines the source mesh
  21658. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21659. */
  21660. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21661. /**
  21662. * Apply current geometry to a given mesh
  21663. * @param mesh defines the mesh to apply geometry to
  21664. */
  21665. applyToMesh(mesh: Mesh): void;
  21666. private _updateExtend;
  21667. private _applyToMesh;
  21668. private notifyUpdate;
  21669. /**
  21670. * Load the geometry if it was flagged as delay loaded
  21671. * @param scene defines the hosting scene
  21672. * @param onLoaded defines a callback called when the geometry is loaded
  21673. */
  21674. load(scene: Scene, onLoaded?: () => void): void;
  21675. private _queueLoad;
  21676. /**
  21677. * Invert the geometry to move from a right handed system to a left handed one.
  21678. */
  21679. toLeftHanded(): void;
  21680. /** @hidden */
  21681. _resetPointsArrayCache(): void;
  21682. /** @hidden */
  21683. _generatePointsArray(): boolean;
  21684. /**
  21685. * Gets a value indicating if the geometry is disposed
  21686. * @returns true if the geometry was disposed
  21687. */
  21688. isDisposed(): boolean;
  21689. private _disposeVertexArrayObjects;
  21690. /**
  21691. * Free all associated resources
  21692. */
  21693. dispose(): void;
  21694. /**
  21695. * Clone the current geometry into a new geometry
  21696. * @param id defines the unique ID of the new geometry
  21697. * @returns a new geometry object
  21698. */
  21699. copy(id: string): Geometry;
  21700. /**
  21701. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21702. * @return a JSON representation of the current geometry data (without the vertices data)
  21703. */
  21704. serialize(): any;
  21705. private toNumberArray;
  21706. /**
  21707. * Serialize all vertices data into a JSON oject
  21708. * @returns a JSON representation of the current geometry data
  21709. */
  21710. serializeVerticeData(): any;
  21711. /**
  21712. * Extracts a clone of a mesh geometry
  21713. * @param mesh defines the source mesh
  21714. * @param id defines the unique ID of the new geometry object
  21715. * @returns the new geometry object
  21716. */
  21717. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21718. /**
  21719. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21720. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21721. * Be aware Math.random() could cause collisions, but:
  21722. * "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"
  21723. * @returns a string containing a new GUID
  21724. */
  21725. static RandomId(): string;
  21726. /** @hidden */
  21727. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21728. private static _CleanMatricesWeights;
  21729. /**
  21730. * Create a new geometry from persisted data (Using .babylon file format)
  21731. * @param parsedVertexData defines the persisted data
  21732. * @param scene defines the hosting scene
  21733. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21734. * @returns the new geometry object
  21735. */
  21736. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21737. }
  21738. }
  21739. declare module "babylonjs/Meshes/mesh.vertexData" {
  21740. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21741. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21742. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21743. import { Geometry } from "babylonjs/Meshes/geometry";
  21744. import { Mesh } from "babylonjs/Meshes/mesh";
  21745. /**
  21746. * Define an interface for all classes that will get and set the data on vertices
  21747. */
  21748. export interface IGetSetVerticesData {
  21749. /**
  21750. * Gets a boolean indicating if specific vertex data is present
  21751. * @param kind defines the vertex data kind to use
  21752. * @returns true is data kind is present
  21753. */
  21754. isVerticesDataPresent(kind: string): boolean;
  21755. /**
  21756. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21757. * @param kind defines the data kind (Position, normal, etc...)
  21758. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21760. * @returns a float array containing vertex data
  21761. */
  21762. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21763. /**
  21764. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21765. * @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.
  21766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21767. * @returns the indices array or an empty array if the mesh has no geometry
  21768. */
  21769. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21770. /**
  21771. * Set specific vertex data
  21772. * @param kind defines the data kind (Position, normal, etc...)
  21773. * @param data defines the vertex data to use
  21774. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21775. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21776. */
  21777. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21778. /**
  21779. * Update a specific associated vertex buffer
  21780. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21781. * - VertexBuffer.PositionKind
  21782. * - VertexBuffer.UVKind
  21783. * - VertexBuffer.UV2Kind
  21784. * - VertexBuffer.UV3Kind
  21785. * - VertexBuffer.UV4Kind
  21786. * - VertexBuffer.UV5Kind
  21787. * - VertexBuffer.UV6Kind
  21788. * - VertexBuffer.ColorKind
  21789. * - VertexBuffer.MatricesIndicesKind
  21790. * - VertexBuffer.MatricesIndicesExtraKind
  21791. * - VertexBuffer.MatricesWeightsKind
  21792. * - VertexBuffer.MatricesWeightsExtraKind
  21793. * @param data defines the data source
  21794. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21795. * @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)
  21796. */
  21797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21798. /**
  21799. * Creates a new index buffer
  21800. * @param indices defines the indices to store in the index buffer
  21801. * @param totalVertices defines the total number of vertices (could be null)
  21802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21803. */
  21804. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21805. }
  21806. /**
  21807. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21808. */
  21809. export class VertexData {
  21810. /**
  21811. * Mesh side orientation : usually the external or front surface
  21812. */
  21813. static readonly FRONTSIDE: number;
  21814. /**
  21815. * Mesh side orientation : usually the internal or back surface
  21816. */
  21817. static readonly BACKSIDE: number;
  21818. /**
  21819. * Mesh side orientation : both internal and external or front and back surfaces
  21820. */
  21821. static readonly DOUBLESIDE: number;
  21822. /**
  21823. * Mesh side orientation : by default, `FRONTSIDE`
  21824. */
  21825. static readonly DEFAULTSIDE: number;
  21826. /**
  21827. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21828. */
  21829. positions: Nullable<FloatArray>;
  21830. /**
  21831. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21832. */
  21833. normals: Nullable<FloatArray>;
  21834. /**
  21835. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21836. */
  21837. tangents: Nullable<FloatArray>;
  21838. /**
  21839. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21840. */
  21841. uvs: Nullable<FloatArray>;
  21842. /**
  21843. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21844. */
  21845. uvs2: Nullable<FloatArray>;
  21846. /**
  21847. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21848. */
  21849. uvs3: Nullable<FloatArray>;
  21850. /**
  21851. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21852. */
  21853. uvs4: Nullable<FloatArray>;
  21854. /**
  21855. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21856. */
  21857. uvs5: Nullable<FloatArray>;
  21858. /**
  21859. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21860. */
  21861. uvs6: Nullable<FloatArray>;
  21862. /**
  21863. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21864. */
  21865. colors: Nullable<FloatArray>;
  21866. /**
  21867. * 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).
  21868. */
  21869. matricesIndices: Nullable<FloatArray>;
  21870. /**
  21871. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21872. */
  21873. matricesWeights: Nullable<FloatArray>;
  21874. /**
  21875. * An array extending the number of possible indices
  21876. */
  21877. matricesIndicesExtra: Nullable<FloatArray>;
  21878. /**
  21879. * An array extending the number of possible weights when the number of indices is extended
  21880. */
  21881. matricesWeightsExtra: Nullable<FloatArray>;
  21882. /**
  21883. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21884. */
  21885. indices: Nullable<IndicesArray>;
  21886. /**
  21887. * Uses the passed data array to set the set the values for the specified kind of data
  21888. * @param data a linear array of floating numbers
  21889. * @param kind the type of data that is being set, eg positions, colors etc
  21890. */
  21891. set(data: FloatArray, kind: string): void;
  21892. /**
  21893. * Associates the vertexData to the passed Mesh.
  21894. * Sets it as updatable or not (default `false`)
  21895. * @param mesh the mesh the vertexData is applied to
  21896. * @param updatable when used and having the value true allows new data to update the vertexData
  21897. * @returns the VertexData
  21898. */
  21899. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21900. /**
  21901. * Associates the vertexData to the passed Geometry.
  21902. * Sets it as updatable or not (default `false`)
  21903. * @param geometry the geometry the vertexData is applied to
  21904. * @param updatable when used and having the value true allows new data to update the vertexData
  21905. * @returns VertexData
  21906. */
  21907. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21908. /**
  21909. * Updates the associated mesh
  21910. * @param mesh the mesh to be updated
  21911. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21912. * @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
  21913. * @returns VertexData
  21914. */
  21915. updateMesh(mesh: Mesh): VertexData;
  21916. /**
  21917. * Updates the associated geometry
  21918. * @param geometry the geometry to be updated
  21919. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21920. * @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
  21921. * @returns VertexData.
  21922. */
  21923. updateGeometry(geometry: Geometry): VertexData;
  21924. private _applyTo;
  21925. private _update;
  21926. /**
  21927. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21928. * @param matrix the transforming matrix
  21929. * @returns the VertexData
  21930. */
  21931. transform(matrix: Matrix): VertexData;
  21932. /**
  21933. * Merges the passed VertexData into the current one
  21934. * @param other the VertexData to be merged into the current one
  21935. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21936. * @returns the modified VertexData
  21937. */
  21938. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21939. private _mergeElement;
  21940. private _validate;
  21941. /**
  21942. * Serializes the VertexData
  21943. * @returns a serialized object
  21944. */
  21945. serialize(): any;
  21946. /**
  21947. * Extracts the vertexData from a mesh
  21948. * @param mesh the mesh from which to extract the VertexData
  21949. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21950. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21951. * @returns the object VertexData associated to the passed mesh
  21952. */
  21953. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21954. /**
  21955. * Extracts the vertexData from the geometry
  21956. * @param geometry the geometry from which to extract the VertexData
  21957. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21958. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21959. * @returns the object VertexData associated to the passed mesh
  21960. */
  21961. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21962. private static _ExtractFrom;
  21963. /**
  21964. * Creates the VertexData for a Ribbon
  21965. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21966. * * pathArray array of paths, each of which an array of successive Vector3
  21967. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21968. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21969. * * 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
  21970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21971. * * 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)
  21972. * * 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)
  21973. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21974. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21975. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21976. * @returns the VertexData of the ribbon
  21977. */
  21978. static CreateRibbon(options: {
  21979. pathArray: Vector3[][];
  21980. closeArray?: boolean;
  21981. closePath?: boolean;
  21982. offset?: number;
  21983. sideOrientation?: number;
  21984. frontUVs?: Vector4;
  21985. backUVs?: Vector4;
  21986. invertUV?: boolean;
  21987. uvs?: Vector2[];
  21988. colors?: Color4[];
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for a box
  21992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21993. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21994. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21995. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21996. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21997. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21998. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22000. * * 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)
  22001. * * 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)
  22002. * @returns the VertexData of the box
  22003. */
  22004. static CreateBox(options: {
  22005. size?: number;
  22006. width?: number;
  22007. height?: number;
  22008. depth?: number;
  22009. faceUV?: Vector4[];
  22010. faceColors?: Color4[];
  22011. sideOrientation?: number;
  22012. frontUVs?: Vector4;
  22013. backUVs?: Vector4;
  22014. }): VertexData;
  22015. /**
  22016. * Creates the VertexData for a tiled box
  22017. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22018. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22019. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22020. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22022. * @returns the VertexData of the box
  22023. */
  22024. static CreateTiledBox(options: {
  22025. pattern?: number;
  22026. width?: number;
  22027. height?: number;
  22028. depth?: number;
  22029. tileSize?: number;
  22030. tileWidth?: number;
  22031. tileHeight?: number;
  22032. alignHorizontal?: number;
  22033. alignVertical?: number;
  22034. faceUV?: Vector4[];
  22035. faceColors?: Color4[];
  22036. sideOrientation?: number;
  22037. }): VertexData;
  22038. /**
  22039. * Creates the VertexData for a tiled plane
  22040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22041. * * pattern a limited pattern arrangement depending on the number
  22042. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22043. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22044. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22046. * * 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)
  22047. * * 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)
  22048. * @returns the VertexData of the tiled plane
  22049. */
  22050. static CreateTiledPlane(options: {
  22051. pattern?: number;
  22052. tileSize?: number;
  22053. tileWidth?: number;
  22054. tileHeight?: number;
  22055. size?: number;
  22056. width?: number;
  22057. height?: number;
  22058. alignHorizontal?: number;
  22059. alignVertical?: number;
  22060. sideOrientation?: number;
  22061. frontUVs?: Vector4;
  22062. backUVs?: Vector4;
  22063. }): VertexData;
  22064. /**
  22065. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22066. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22067. * * segments sets the number of horizontal strips optional, default 32
  22068. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22069. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22070. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22071. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22072. * * 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
  22073. * * 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
  22074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22075. * * 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)
  22076. * * 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)
  22077. * @returns the VertexData of the ellipsoid
  22078. */
  22079. static CreateSphere(options: {
  22080. segments?: number;
  22081. diameter?: number;
  22082. diameterX?: number;
  22083. diameterY?: number;
  22084. diameterZ?: number;
  22085. arc?: number;
  22086. slice?: number;
  22087. sideOrientation?: number;
  22088. frontUVs?: Vector4;
  22089. backUVs?: Vector4;
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for a cylinder, cone or prism
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * height sets the height (y direction) of the cylinder, optional, default 2
  22095. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22096. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22097. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22098. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22099. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22100. * * 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
  22101. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22102. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22103. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22104. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22106. * * 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)
  22107. * * 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)
  22108. * @returns the VertexData of the cylinder, cone or prism
  22109. */
  22110. static CreateCylinder(options: {
  22111. height?: number;
  22112. diameterTop?: number;
  22113. diameterBottom?: number;
  22114. diameter?: number;
  22115. tessellation?: number;
  22116. subdivisions?: number;
  22117. arc?: number;
  22118. faceColors?: Color4[];
  22119. faceUV?: Vector4[];
  22120. hasRings?: boolean;
  22121. enclose?: boolean;
  22122. sideOrientation?: number;
  22123. frontUVs?: Vector4;
  22124. backUVs?: Vector4;
  22125. }): VertexData;
  22126. /**
  22127. * Creates the VertexData for a torus
  22128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22129. * * diameter the diameter of the torus, optional default 1
  22130. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22133. * * 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)
  22134. * * 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)
  22135. * @returns the VertexData of the torus
  22136. */
  22137. static CreateTorus(options: {
  22138. diameter?: number;
  22139. thickness?: number;
  22140. tessellation?: number;
  22141. sideOrientation?: number;
  22142. frontUVs?: Vector4;
  22143. backUVs?: Vector4;
  22144. }): VertexData;
  22145. /**
  22146. * Creates the VertexData of the LineSystem
  22147. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22148. * - lines an array of lines, each line being an array of successive Vector3
  22149. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22150. * @returns the VertexData of the LineSystem
  22151. */
  22152. static CreateLineSystem(options: {
  22153. lines: Vector3[][];
  22154. colors?: Nullable<Color4[][]>;
  22155. }): VertexData;
  22156. /**
  22157. * Create the VertexData for a DashedLines
  22158. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22159. * - points an array successive Vector3
  22160. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22161. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22162. * - dashNb the intended total number of dashes, optional, default 200
  22163. * @returns the VertexData for the DashedLines
  22164. */
  22165. static CreateDashedLines(options: {
  22166. points: Vector3[];
  22167. dashSize?: number;
  22168. gapSize?: number;
  22169. dashNb?: number;
  22170. }): VertexData;
  22171. /**
  22172. * Creates the VertexData for a Ground
  22173. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22174. * - width the width (x direction) of the ground, optional, default 1
  22175. * - height the height (z direction) of the ground, optional, default 1
  22176. * - subdivisions the number of subdivisions per side, optional, default 1
  22177. * @returns the VertexData of the Ground
  22178. */
  22179. static CreateGround(options: {
  22180. width?: number;
  22181. height?: number;
  22182. subdivisions?: number;
  22183. subdivisionsX?: number;
  22184. subdivisionsY?: number;
  22185. }): VertexData;
  22186. /**
  22187. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22188. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22189. * * xmin the ground minimum X coordinate, optional, default -1
  22190. * * zmin the ground minimum Z coordinate, optional, default -1
  22191. * * xmax the ground maximum X coordinate, optional, default 1
  22192. * * zmax the ground maximum Z coordinate, optional, default 1
  22193. * * 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}
  22194. * * 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}
  22195. * @returns the VertexData of the TiledGround
  22196. */
  22197. static CreateTiledGround(options: {
  22198. xmin: number;
  22199. zmin: number;
  22200. xmax: number;
  22201. zmax: number;
  22202. subdivisions?: {
  22203. w: number;
  22204. h: number;
  22205. };
  22206. precision?: {
  22207. w: number;
  22208. h: number;
  22209. };
  22210. }): VertexData;
  22211. /**
  22212. * Creates the VertexData of the Ground designed from a heightmap
  22213. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22214. * * width the width (x direction) of the ground
  22215. * * height the height (z direction) of the ground
  22216. * * subdivisions the number of subdivisions per side
  22217. * * minHeight the minimum altitude on the ground, optional, default 0
  22218. * * maxHeight the maximum altitude on the ground, optional default 1
  22219. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22220. * * buffer the array holding the image color data
  22221. * * bufferWidth the width of image
  22222. * * bufferHeight the height of image
  22223. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22224. * @returns the VertexData of the Ground designed from a heightmap
  22225. */
  22226. static CreateGroundFromHeightMap(options: {
  22227. width: number;
  22228. height: number;
  22229. subdivisions: number;
  22230. minHeight: number;
  22231. maxHeight: number;
  22232. colorFilter: Color3;
  22233. buffer: Uint8Array;
  22234. bufferWidth: number;
  22235. bufferHeight: number;
  22236. alphaFilter: number;
  22237. }): VertexData;
  22238. /**
  22239. * Creates the VertexData for a Plane
  22240. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22241. * * size sets the width and height of the plane to the value of size, optional default 1
  22242. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22243. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22245. * * 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)
  22246. * * 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)
  22247. * @returns the VertexData of the box
  22248. */
  22249. static CreatePlane(options: {
  22250. size?: number;
  22251. width?: number;
  22252. height?: number;
  22253. sideOrientation?: number;
  22254. frontUVs?: Vector4;
  22255. backUVs?: Vector4;
  22256. }): VertexData;
  22257. /**
  22258. * Creates the VertexData of the Disc or regular Polygon
  22259. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22260. * * radius the radius of the disc, optional default 0.5
  22261. * * tessellation the number of polygon sides, optional, default 64
  22262. * * 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
  22263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22264. * * 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)
  22265. * * 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)
  22266. * @returns the VertexData of the box
  22267. */
  22268. static CreateDisc(options: {
  22269. radius?: number;
  22270. tessellation?: number;
  22271. arc?: number;
  22272. sideOrientation?: number;
  22273. frontUVs?: Vector4;
  22274. backUVs?: Vector4;
  22275. }): VertexData;
  22276. /**
  22277. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22278. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22279. * @param polygon a mesh built from polygonTriangulation.build()
  22280. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22281. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22282. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22283. * @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)
  22284. * @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)
  22285. * @returns the VertexData of the Polygon
  22286. */
  22287. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22288. /**
  22289. * Creates the VertexData of the IcoSphere
  22290. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22291. * * radius the radius of the IcoSphere, optional default 1
  22292. * * radiusX allows stretching in the x direction, optional, default radius
  22293. * * radiusY allows stretching in the y direction, optional, default radius
  22294. * * radiusZ allows stretching in the z direction, optional, default radius
  22295. * * flat when true creates a flat shaded mesh, optional, default true
  22296. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22298. * * 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)
  22299. * * 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)
  22300. * @returns the VertexData of the IcoSphere
  22301. */
  22302. static CreateIcoSphere(options: {
  22303. radius?: number;
  22304. radiusX?: number;
  22305. radiusY?: number;
  22306. radiusZ?: number;
  22307. flat?: boolean;
  22308. subdivisions?: number;
  22309. sideOrientation?: number;
  22310. frontUVs?: Vector4;
  22311. backUVs?: Vector4;
  22312. }): VertexData;
  22313. /**
  22314. * Creates the VertexData for a Polyhedron
  22315. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22316. * * type provided types are:
  22317. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22318. * * 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)
  22319. * * size the size of the IcoSphere, optional default 1
  22320. * * sizeX allows stretching in the x direction, optional, default size
  22321. * * sizeY allows stretching in the y direction, optional, default size
  22322. * * sizeZ allows stretching in the z direction, optional, default size
  22323. * * 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
  22324. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22325. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22326. * * flat when true creates a flat shaded mesh, optional, default true
  22327. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22329. * * 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)
  22330. * * 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)
  22331. * @returns the VertexData of the Polyhedron
  22332. */
  22333. static CreatePolyhedron(options: {
  22334. type?: number;
  22335. size?: number;
  22336. sizeX?: number;
  22337. sizeY?: number;
  22338. sizeZ?: number;
  22339. custom?: any;
  22340. faceUV?: Vector4[];
  22341. faceColors?: Color4[];
  22342. flat?: boolean;
  22343. sideOrientation?: number;
  22344. frontUVs?: Vector4;
  22345. backUVs?: Vector4;
  22346. }): VertexData;
  22347. /**
  22348. * Creates the VertexData for a TorusKnot
  22349. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22350. * * radius the radius of the torus knot, optional, default 2
  22351. * * tube the thickness of the tube, optional, default 0.5
  22352. * * radialSegments the number of sides on each tube segments, optional, default 32
  22353. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22354. * * p the number of windings around the z axis, optional, default 2
  22355. * * q the number of windings around the x axis, optional, default 3
  22356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22357. * * 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)
  22358. * * 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)
  22359. * @returns the VertexData of the Torus Knot
  22360. */
  22361. static CreateTorusKnot(options: {
  22362. radius?: number;
  22363. tube?: number;
  22364. radialSegments?: number;
  22365. tubularSegments?: number;
  22366. p?: number;
  22367. q?: number;
  22368. sideOrientation?: number;
  22369. frontUVs?: Vector4;
  22370. backUVs?: Vector4;
  22371. }): VertexData;
  22372. /**
  22373. * Compute normals for given positions and indices
  22374. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22375. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22376. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22377. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22378. * * facetNormals : optional array of facet normals (vector3)
  22379. * * facetPositions : optional array of facet positions (vector3)
  22380. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22381. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22382. * * bInfo : optional bounding info, required for facetPartitioning computation
  22383. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22384. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22385. * * useRightHandedSystem: optional boolean to for right handed system computation
  22386. * * depthSort : optional boolean to enable the facet depth sort computation
  22387. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22388. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22389. */
  22390. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22391. facetNormals?: any;
  22392. facetPositions?: any;
  22393. facetPartitioning?: any;
  22394. ratio?: number;
  22395. bInfo?: any;
  22396. bbSize?: Vector3;
  22397. subDiv?: any;
  22398. useRightHandedSystem?: boolean;
  22399. depthSort?: boolean;
  22400. distanceTo?: Vector3;
  22401. depthSortedFacets?: any;
  22402. }): void;
  22403. /** @hidden */
  22404. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22405. /**
  22406. * Applies VertexData created from the imported parameters to the geometry
  22407. * @param parsedVertexData the parsed data from an imported file
  22408. * @param geometry the geometry to apply the VertexData to
  22409. */
  22410. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22411. }
  22412. }
  22413. declare module "babylonjs/Morph/morphTarget" {
  22414. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22415. import { Observable } from "babylonjs/Misc/observable";
  22416. import { Nullable, FloatArray } from "babylonjs/types";
  22417. import { Scene } from "babylonjs/scene";
  22418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22419. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22420. /**
  22421. * Defines a target to use with MorphTargetManager
  22422. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22423. */
  22424. export class MorphTarget implements IAnimatable {
  22425. /** defines the name of the target */
  22426. name: string;
  22427. /**
  22428. * Gets or sets the list of animations
  22429. */
  22430. animations: import("babylonjs/Animations/animation").Animation[];
  22431. private _scene;
  22432. private _positions;
  22433. private _normals;
  22434. private _tangents;
  22435. private _uvs;
  22436. private _influence;
  22437. /**
  22438. * Observable raised when the influence changes
  22439. */
  22440. onInfluenceChanged: Observable<boolean>;
  22441. /** @hidden */
  22442. _onDataLayoutChanged: Observable<void>;
  22443. /**
  22444. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22445. */
  22446. influence: number;
  22447. /**
  22448. * Gets or sets the id of the morph Target
  22449. */
  22450. id: string;
  22451. private _animationPropertiesOverride;
  22452. /**
  22453. * Gets or sets the animation properties override
  22454. */
  22455. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22456. /**
  22457. * Creates a new MorphTarget
  22458. * @param name defines the name of the target
  22459. * @param influence defines the influence to use
  22460. * @param scene defines the scene the morphtarget belongs to
  22461. */
  22462. constructor(
  22463. /** defines the name of the target */
  22464. name: string, influence?: number, scene?: Nullable<Scene>);
  22465. /**
  22466. * Gets a boolean defining if the target contains position data
  22467. */
  22468. readonly hasPositions: boolean;
  22469. /**
  22470. * Gets a boolean defining if the target contains normal data
  22471. */
  22472. readonly hasNormals: boolean;
  22473. /**
  22474. * Gets a boolean defining if the target contains tangent data
  22475. */
  22476. readonly hasTangents: boolean;
  22477. /**
  22478. * Gets a boolean defining if the target contains texture coordinates data
  22479. */
  22480. readonly hasUVs: boolean;
  22481. /**
  22482. * Affects position data to this target
  22483. * @param data defines the position data to use
  22484. */
  22485. setPositions(data: Nullable<FloatArray>): void;
  22486. /**
  22487. * Gets the position data stored in this target
  22488. * @returns a FloatArray containing the position data (or null if not present)
  22489. */
  22490. getPositions(): Nullable<FloatArray>;
  22491. /**
  22492. * Affects normal data to this target
  22493. * @param data defines the normal data to use
  22494. */
  22495. setNormals(data: Nullable<FloatArray>): void;
  22496. /**
  22497. * Gets the normal data stored in this target
  22498. * @returns a FloatArray containing the normal data (or null if not present)
  22499. */
  22500. getNormals(): Nullable<FloatArray>;
  22501. /**
  22502. * Affects tangent data to this target
  22503. * @param data defines the tangent data to use
  22504. */
  22505. setTangents(data: Nullable<FloatArray>): void;
  22506. /**
  22507. * Gets the tangent data stored in this target
  22508. * @returns a FloatArray containing the tangent data (or null if not present)
  22509. */
  22510. getTangents(): Nullable<FloatArray>;
  22511. /**
  22512. * Affects texture coordinates data to this target
  22513. * @param data defines the texture coordinates data to use
  22514. */
  22515. setUVs(data: Nullable<FloatArray>): void;
  22516. /**
  22517. * Gets the texture coordinates data stored in this target
  22518. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22519. */
  22520. getUVs(): Nullable<FloatArray>;
  22521. /**
  22522. * Serializes the current target into a Serialization object
  22523. * @returns the serialized object
  22524. */
  22525. serialize(): any;
  22526. /**
  22527. * Returns the string "MorphTarget"
  22528. * @returns "MorphTarget"
  22529. */
  22530. getClassName(): string;
  22531. /**
  22532. * Creates a new target from serialized data
  22533. * @param serializationObject defines the serialized data to use
  22534. * @returns a new MorphTarget
  22535. */
  22536. static Parse(serializationObject: any): MorphTarget;
  22537. /**
  22538. * Creates a MorphTarget from mesh data
  22539. * @param mesh defines the source mesh
  22540. * @param name defines the name to use for the new target
  22541. * @param influence defines the influence to attach to the target
  22542. * @returns a new MorphTarget
  22543. */
  22544. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22545. }
  22546. }
  22547. declare module "babylonjs/Morph/morphTargetManager" {
  22548. import { Nullable } from "babylonjs/types";
  22549. import { Scene } from "babylonjs/scene";
  22550. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22551. /**
  22552. * This class is used to deform meshes using morphing between different targets
  22553. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22554. */
  22555. export class MorphTargetManager {
  22556. private _targets;
  22557. private _targetInfluenceChangedObservers;
  22558. private _targetDataLayoutChangedObservers;
  22559. private _activeTargets;
  22560. private _scene;
  22561. private _influences;
  22562. private _supportsNormals;
  22563. private _supportsTangents;
  22564. private _supportsUVs;
  22565. private _vertexCount;
  22566. private _uniqueId;
  22567. private _tempInfluences;
  22568. /**
  22569. * Gets or sets a boolean indicating if normals must be morphed
  22570. */
  22571. enableNormalMorphing: boolean;
  22572. /**
  22573. * Gets or sets a boolean indicating if tangents must be morphed
  22574. */
  22575. enableTangentMorphing: boolean;
  22576. /**
  22577. * Gets or sets a boolean indicating if UV must be morphed
  22578. */
  22579. enableUVMorphing: boolean;
  22580. /**
  22581. * Creates a new MorphTargetManager
  22582. * @param scene defines the current scene
  22583. */
  22584. constructor(scene?: Nullable<Scene>);
  22585. /**
  22586. * Gets the unique ID of this manager
  22587. */
  22588. readonly uniqueId: number;
  22589. /**
  22590. * Gets the number of vertices handled by this manager
  22591. */
  22592. readonly vertexCount: number;
  22593. /**
  22594. * Gets a boolean indicating if this manager supports morphing of normals
  22595. */
  22596. readonly supportsNormals: boolean;
  22597. /**
  22598. * Gets a boolean indicating if this manager supports morphing of tangents
  22599. */
  22600. readonly supportsTangents: boolean;
  22601. /**
  22602. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22603. */
  22604. readonly supportsUVs: boolean;
  22605. /**
  22606. * Gets the number of targets stored in this manager
  22607. */
  22608. readonly numTargets: number;
  22609. /**
  22610. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22611. */
  22612. readonly numInfluencers: number;
  22613. /**
  22614. * Gets the list of influences (one per target)
  22615. */
  22616. readonly influences: Float32Array;
  22617. /**
  22618. * Gets the active target at specified index. An active target is a target with an influence > 0
  22619. * @param index defines the index to check
  22620. * @returns the requested target
  22621. */
  22622. getActiveTarget(index: number): MorphTarget;
  22623. /**
  22624. * Gets the target at specified index
  22625. * @param index defines the index to check
  22626. * @returns the requested target
  22627. */
  22628. getTarget(index: number): MorphTarget;
  22629. /**
  22630. * Add a new target to this manager
  22631. * @param target defines the target to add
  22632. */
  22633. addTarget(target: MorphTarget): void;
  22634. /**
  22635. * Removes a target from the manager
  22636. * @param target defines the target to remove
  22637. */
  22638. removeTarget(target: MorphTarget): void;
  22639. /**
  22640. * Serializes the current manager into a Serialization object
  22641. * @returns the serialized object
  22642. */
  22643. serialize(): any;
  22644. private _syncActiveTargets;
  22645. /**
  22646. * Syncrhonize the targets with all the meshes using this morph target manager
  22647. */
  22648. synchronize(): void;
  22649. /**
  22650. * Creates a new MorphTargetManager from serialized data
  22651. * @param serializationObject defines the serialized data
  22652. * @param scene defines the hosting scene
  22653. * @returns the new MorphTargetManager
  22654. */
  22655. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22656. }
  22657. }
  22658. declare module "babylonjs/Meshes/meshLODLevel" {
  22659. import { Mesh } from "babylonjs/Meshes/mesh";
  22660. import { Nullable } from "babylonjs/types";
  22661. /**
  22662. * Class used to represent a specific level of detail of a mesh
  22663. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22664. */
  22665. export class MeshLODLevel {
  22666. /** Defines the distance where this level should star being displayed */
  22667. distance: number;
  22668. /** Defines the mesh to use to render this level */
  22669. mesh: Nullable<Mesh>;
  22670. /**
  22671. * Creates a new LOD level
  22672. * @param distance defines the distance where this level should star being displayed
  22673. * @param mesh defines the mesh to use to render this level
  22674. */
  22675. constructor(
  22676. /** Defines the distance where this level should star being displayed */
  22677. distance: number,
  22678. /** Defines the mesh to use to render this level */
  22679. mesh: Nullable<Mesh>);
  22680. }
  22681. }
  22682. declare module "babylonjs/Meshes/groundMesh" {
  22683. import { Scene } from "babylonjs/scene";
  22684. import { Vector3 } from "babylonjs/Maths/math.vector";
  22685. import { Mesh } from "babylonjs/Meshes/mesh";
  22686. /**
  22687. * Mesh representing the gorund
  22688. */
  22689. export class GroundMesh extends Mesh {
  22690. /** If octree should be generated */
  22691. generateOctree: boolean;
  22692. private _heightQuads;
  22693. /** @hidden */
  22694. _subdivisionsX: number;
  22695. /** @hidden */
  22696. _subdivisionsY: number;
  22697. /** @hidden */
  22698. _width: number;
  22699. /** @hidden */
  22700. _height: number;
  22701. /** @hidden */
  22702. _minX: number;
  22703. /** @hidden */
  22704. _maxX: number;
  22705. /** @hidden */
  22706. _minZ: number;
  22707. /** @hidden */
  22708. _maxZ: number;
  22709. constructor(name: string, scene: Scene);
  22710. /**
  22711. * "GroundMesh"
  22712. * @returns "GroundMesh"
  22713. */
  22714. getClassName(): string;
  22715. /**
  22716. * The minimum of x and y subdivisions
  22717. */
  22718. readonly subdivisions: number;
  22719. /**
  22720. * X subdivisions
  22721. */
  22722. readonly subdivisionsX: number;
  22723. /**
  22724. * Y subdivisions
  22725. */
  22726. readonly subdivisionsY: number;
  22727. /**
  22728. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22729. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22730. * @param chunksCount the number of subdivisions for x and y
  22731. * @param octreeBlocksSize (Default: 32)
  22732. */
  22733. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22734. /**
  22735. * Returns a height (y) value in the Worl system :
  22736. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22737. * @param x x coordinate
  22738. * @param z z coordinate
  22739. * @returns the ground y position if (x, z) are outside the ground surface.
  22740. */
  22741. getHeightAtCoordinates(x: number, z: number): number;
  22742. /**
  22743. * Returns a normalized vector (Vector3) orthogonal to the ground
  22744. * at the ground coordinates (x, z) expressed in the World system.
  22745. * @param x x coordinate
  22746. * @param z z coordinate
  22747. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22748. */
  22749. getNormalAtCoordinates(x: number, z: number): Vector3;
  22750. /**
  22751. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22752. * at the ground coordinates (x, z) expressed in the World system.
  22753. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22754. * @param x x coordinate
  22755. * @param z z coordinate
  22756. * @param ref vector to store the result
  22757. * @returns the GroundMesh.
  22758. */
  22759. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22760. /**
  22761. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22762. * if the ground has been updated.
  22763. * This can be used in the render loop.
  22764. * @returns the GroundMesh.
  22765. */
  22766. updateCoordinateHeights(): GroundMesh;
  22767. private _getFacetAt;
  22768. private _initHeightQuads;
  22769. private _computeHeightQuads;
  22770. /**
  22771. * Serializes this ground mesh
  22772. * @param serializationObject object to write serialization to
  22773. */
  22774. serialize(serializationObject: any): void;
  22775. /**
  22776. * Parses a serialized ground mesh
  22777. * @param parsedMesh the serialized mesh
  22778. * @param scene the scene to create the ground mesh in
  22779. * @returns the created ground mesh
  22780. */
  22781. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22782. }
  22783. }
  22784. declare module "babylonjs/Physics/physicsJoint" {
  22785. import { Vector3 } from "babylonjs/Maths/math.vector";
  22786. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22787. /**
  22788. * Interface for Physics-Joint data
  22789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22790. */
  22791. export interface PhysicsJointData {
  22792. /**
  22793. * The main pivot of the joint
  22794. */
  22795. mainPivot?: Vector3;
  22796. /**
  22797. * The connected pivot of the joint
  22798. */
  22799. connectedPivot?: Vector3;
  22800. /**
  22801. * The main axis of the joint
  22802. */
  22803. mainAxis?: Vector3;
  22804. /**
  22805. * The connected axis of the joint
  22806. */
  22807. connectedAxis?: Vector3;
  22808. /**
  22809. * The collision of the joint
  22810. */
  22811. collision?: boolean;
  22812. /**
  22813. * Native Oimo/Cannon/Energy data
  22814. */
  22815. nativeParams?: any;
  22816. }
  22817. /**
  22818. * This is a holder class for the physics joint created by the physics plugin
  22819. * It holds a set of functions to control the underlying joint
  22820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22821. */
  22822. export class PhysicsJoint {
  22823. /**
  22824. * The type of the physics joint
  22825. */
  22826. type: number;
  22827. /**
  22828. * The data for the physics joint
  22829. */
  22830. jointData: PhysicsJointData;
  22831. private _physicsJoint;
  22832. protected _physicsPlugin: IPhysicsEnginePlugin;
  22833. /**
  22834. * Initializes the physics joint
  22835. * @param type The type of the physics joint
  22836. * @param jointData The data for the physics joint
  22837. */
  22838. constructor(
  22839. /**
  22840. * The type of the physics joint
  22841. */
  22842. type: number,
  22843. /**
  22844. * The data for the physics joint
  22845. */
  22846. jointData: PhysicsJointData);
  22847. /**
  22848. * Gets the physics joint
  22849. */
  22850. /**
  22851. * Sets the physics joint
  22852. */
  22853. physicsJoint: any;
  22854. /**
  22855. * Sets the physics plugin
  22856. */
  22857. physicsPlugin: IPhysicsEnginePlugin;
  22858. /**
  22859. * Execute a function that is physics-plugin specific.
  22860. * @param {Function} func the function that will be executed.
  22861. * It accepts two parameters: the physics world and the physics joint
  22862. */
  22863. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22864. /**
  22865. * Distance-Joint type
  22866. */
  22867. static DistanceJoint: number;
  22868. /**
  22869. * Hinge-Joint type
  22870. */
  22871. static HingeJoint: number;
  22872. /**
  22873. * Ball-and-Socket joint type
  22874. */
  22875. static BallAndSocketJoint: number;
  22876. /**
  22877. * Wheel-Joint type
  22878. */
  22879. static WheelJoint: number;
  22880. /**
  22881. * Slider-Joint type
  22882. */
  22883. static SliderJoint: number;
  22884. /**
  22885. * Prismatic-Joint type
  22886. */
  22887. static PrismaticJoint: number;
  22888. /**
  22889. * Universal-Joint type
  22890. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22891. */
  22892. static UniversalJoint: number;
  22893. /**
  22894. * Hinge-Joint 2 type
  22895. */
  22896. static Hinge2Joint: number;
  22897. /**
  22898. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22899. */
  22900. static PointToPointJoint: number;
  22901. /**
  22902. * Spring-Joint type
  22903. */
  22904. static SpringJoint: number;
  22905. /**
  22906. * Lock-Joint type
  22907. */
  22908. static LockJoint: number;
  22909. }
  22910. /**
  22911. * A class representing a physics distance joint
  22912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22913. */
  22914. export class DistanceJoint extends PhysicsJoint {
  22915. /**
  22916. *
  22917. * @param jointData The data for the Distance-Joint
  22918. */
  22919. constructor(jointData: DistanceJointData);
  22920. /**
  22921. * Update the predefined distance.
  22922. * @param maxDistance The maximum preferred distance
  22923. * @param minDistance The minimum preferred distance
  22924. */
  22925. updateDistance(maxDistance: number, minDistance?: number): void;
  22926. }
  22927. /**
  22928. * Represents a Motor-Enabled Joint
  22929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22930. */
  22931. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22932. /**
  22933. * Initializes the Motor-Enabled Joint
  22934. * @param type The type of the joint
  22935. * @param jointData The physica joint data for the joint
  22936. */
  22937. constructor(type: number, jointData: PhysicsJointData);
  22938. /**
  22939. * Set the motor values.
  22940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22941. * @param force the force to apply
  22942. * @param maxForce max force for this motor.
  22943. */
  22944. setMotor(force?: number, maxForce?: number): void;
  22945. /**
  22946. * Set the motor's limits.
  22947. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22948. * @param upperLimit The upper limit of the motor
  22949. * @param lowerLimit The lower limit of the motor
  22950. */
  22951. setLimit(upperLimit: number, lowerLimit?: number): void;
  22952. }
  22953. /**
  22954. * This class represents a single physics Hinge-Joint
  22955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22956. */
  22957. export class HingeJoint extends MotorEnabledJoint {
  22958. /**
  22959. * Initializes the Hinge-Joint
  22960. * @param jointData The joint data for the Hinge-Joint
  22961. */
  22962. constructor(jointData: PhysicsJointData);
  22963. /**
  22964. * Set the motor values.
  22965. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22966. * @param {number} force the force to apply
  22967. * @param {number} maxForce max force for this motor.
  22968. */
  22969. setMotor(force?: number, maxForce?: number): void;
  22970. /**
  22971. * Set the motor's limits.
  22972. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22973. * @param upperLimit The upper limit of the motor
  22974. * @param lowerLimit The lower limit of the motor
  22975. */
  22976. setLimit(upperLimit: number, lowerLimit?: number): void;
  22977. }
  22978. /**
  22979. * This class represents a dual hinge physics joint (same as wheel joint)
  22980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22981. */
  22982. export class Hinge2Joint extends MotorEnabledJoint {
  22983. /**
  22984. * Initializes the Hinge2-Joint
  22985. * @param jointData The joint data for the Hinge2-Joint
  22986. */
  22987. constructor(jointData: PhysicsJointData);
  22988. /**
  22989. * Set the motor values.
  22990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22991. * @param {number} targetSpeed the speed the motor is to reach
  22992. * @param {number} maxForce max force for this motor.
  22993. * @param {motorIndex} the motor's index, 0 or 1.
  22994. */
  22995. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22996. /**
  22997. * Set the motor limits.
  22998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22999. * @param {number} upperLimit the upper limit
  23000. * @param {number} lowerLimit lower limit
  23001. * @param {motorIndex} the motor's index, 0 or 1.
  23002. */
  23003. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23004. }
  23005. /**
  23006. * Interface for a motor enabled joint
  23007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23008. */
  23009. export interface IMotorEnabledJoint {
  23010. /**
  23011. * Physics joint
  23012. */
  23013. physicsJoint: any;
  23014. /**
  23015. * Sets the motor of the motor-enabled joint
  23016. * @param force The force of the motor
  23017. * @param maxForce The maximum force of the motor
  23018. * @param motorIndex The index of the motor
  23019. */
  23020. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23021. /**
  23022. * Sets the limit of the motor
  23023. * @param upperLimit The upper limit of the motor
  23024. * @param lowerLimit The lower limit of the motor
  23025. * @param motorIndex The index of the motor
  23026. */
  23027. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23028. }
  23029. /**
  23030. * Joint data for a Distance-Joint
  23031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23032. */
  23033. export interface DistanceJointData extends PhysicsJointData {
  23034. /**
  23035. * Max distance the 2 joint objects can be apart
  23036. */
  23037. maxDistance: number;
  23038. }
  23039. /**
  23040. * Joint data from a spring joint
  23041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23042. */
  23043. export interface SpringJointData extends PhysicsJointData {
  23044. /**
  23045. * Length of the spring
  23046. */
  23047. length: number;
  23048. /**
  23049. * Stiffness of the spring
  23050. */
  23051. stiffness: number;
  23052. /**
  23053. * Damping of the spring
  23054. */
  23055. damping: number;
  23056. /** this callback will be called when applying the force to the impostors. */
  23057. forceApplicationCallback: () => void;
  23058. }
  23059. }
  23060. declare module "babylonjs/Physics/physicsRaycastResult" {
  23061. import { Vector3 } from "babylonjs/Maths/math.vector";
  23062. /**
  23063. * Holds the data for the raycast result
  23064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23065. */
  23066. export class PhysicsRaycastResult {
  23067. private _hasHit;
  23068. private _hitDistance;
  23069. private _hitNormalWorld;
  23070. private _hitPointWorld;
  23071. private _rayFromWorld;
  23072. private _rayToWorld;
  23073. /**
  23074. * Gets if there was a hit
  23075. */
  23076. readonly hasHit: boolean;
  23077. /**
  23078. * Gets the distance from the hit
  23079. */
  23080. readonly hitDistance: number;
  23081. /**
  23082. * Gets the hit normal/direction in the world
  23083. */
  23084. readonly hitNormalWorld: Vector3;
  23085. /**
  23086. * Gets the hit point in the world
  23087. */
  23088. readonly hitPointWorld: Vector3;
  23089. /**
  23090. * Gets the ray "start point" of the ray in the world
  23091. */
  23092. readonly rayFromWorld: Vector3;
  23093. /**
  23094. * Gets the ray "end point" of the ray in the world
  23095. */
  23096. readonly rayToWorld: Vector3;
  23097. /**
  23098. * Sets the hit data (normal & point in world space)
  23099. * @param hitNormalWorld defines the normal in world space
  23100. * @param hitPointWorld defines the point in world space
  23101. */
  23102. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23103. /**
  23104. * Sets the distance from the start point to the hit point
  23105. * @param distance
  23106. */
  23107. setHitDistance(distance: number): void;
  23108. /**
  23109. * Calculates the distance manually
  23110. */
  23111. calculateHitDistance(): void;
  23112. /**
  23113. * Resets all the values to default
  23114. * @param from The from point on world space
  23115. * @param to The to point on world space
  23116. */
  23117. reset(from?: Vector3, to?: Vector3): void;
  23118. }
  23119. /**
  23120. * Interface for the size containing width and height
  23121. */
  23122. interface IXYZ {
  23123. /**
  23124. * X
  23125. */
  23126. x: number;
  23127. /**
  23128. * Y
  23129. */
  23130. y: number;
  23131. /**
  23132. * Z
  23133. */
  23134. z: number;
  23135. }
  23136. }
  23137. declare module "babylonjs/Physics/IPhysicsEngine" {
  23138. import { Nullable } from "babylonjs/types";
  23139. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23141. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23142. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23143. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23144. /**
  23145. * Interface used to describe a physics joint
  23146. */
  23147. export interface PhysicsImpostorJoint {
  23148. /** Defines the main impostor to which the joint is linked */
  23149. mainImpostor: PhysicsImpostor;
  23150. /** Defines the impostor that is connected to the main impostor using this joint */
  23151. connectedImpostor: PhysicsImpostor;
  23152. /** Defines the joint itself */
  23153. joint: PhysicsJoint;
  23154. }
  23155. /** @hidden */
  23156. export interface IPhysicsEnginePlugin {
  23157. world: any;
  23158. name: string;
  23159. setGravity(gravity: Vector3): void;
  23160. setTimeStep(timeStep: number): void;
  23161. getTimeStep(): number;
  23162. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23163. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23164. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23165. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23166. removePhysicsBody(impostor: PhysicsImpostor): void;
  23167. generateJoint(joint: PhysicsImpostorJoint): void;
  23168. removeJoint(joint: PhysicsImpostorJoint): void;
  23169. isSupported(): boolean;
  23170. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23171. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23172. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23173. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23174. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23176. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23177. getBodyMass(impostor: PhysicsImpostor): number;
  23178. getBodyFriction(impostor: PhysicsImpostor): number;
  23179. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23180. getBodyRestitution(impostor: PhysicsImpostor): number;
  23181. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23182. getBodyPressure?(impostor: PhysicsImpostor): number;
  23183. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23184. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23185. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23186. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23187. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23188. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23189. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23190. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23191. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23192. sleepBody(impostor: PhysicsImpostor): void;
  23193. wakeUpBody(impostor: PhysicsImpostor): void;
  23194. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23195. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23196. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23197. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23198. getRadius(impostor: PhysicsImpostor): number;
  23199. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23200. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23201. dispose(): void;
  23202. }
  23203. /**
  23204. * Interface used to define a physics engine
  23205. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23206. */
  23207. export interface IPhysicsEngine {
  23208. /**
  23209. * Gets the gravity vector used by the simulation
  23210. */
  23211. gravity: Vector3;
  23212. /**
  23213. * Sets the gravity vector used by the simulation
  23214. * @param gravity defines the gravity vector to use
  23215. */
  23216. setGravity(gravity: Vector3): void;
  23217. /**
  23218. * Set the time step of the physics engine.
  23219. * Default is 1/60.
  23220. * To slow it down, enter 1/600 for example.
  23221. * To speed it up, 1/30
  23222. * @param newTimeStep the new timestep to apply to this world.
  23223. */
  23224. setTimeStep(newTimeStep: number): void;
  23225. /**
  23226. * Get the time step of the physics engine.
  23227. * @returns the current time step
  23228. */
  23229. getTimeStep(): number;
  23230. /**
  23231. * Release all resources
  23232. */
  23233. dispose(): void;
  23234. /**
  23235. * Gets the name of the current physics plugin
  23236. * @returns the name of the plugin
  23237. */
  23238. getPhysicsPluginName(): string;
  23239. /**
  23240. * Adding a new impostor for the impostor tracking.
  23241. * This will be done by the impostor itself.
  23242. * @param impostor the impostor to add
  23243. */
  23244. addImpostor(impostor: PhysicsImpostor): void;
  23245. /**
  23246. * Remove an impostor from the engine.
  23247. * This impostor and its mesh will not longer be updated by the physics engine.
  23248. * @param impostor the impostor to remove
  23249. */
  23250. removeImpostor(impostor: PhysicsImpostor): void;
  23251. /**
  23252. * Add a joint to the physics engine
  23253. * @param mainImpostor defines the main impostor to which the joint is added.
  23254. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23255. * @param joint defines the joint that will connect both impostors.
  23256. */
  23257. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23258. /**
  23259. * Removes a joint from the simulation
  23260. * @param mainImpostor defines the impostor used with the joint
  23261. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23262. * @param joint defines the joint to remove
  23263. */
  23264. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23265. /**
  23266. * Gets the current plugin used to run the simulation
  23267. * @returns current plugin
  23268. */
  23269. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23270. /**
  23271. * Gets the list of physic impostors
  23272. * @returns an array of PhysicsImpostor
  23273. */
  23274. getImpostors(): Array<PhysicsImpostor>;
  23275. /**
  23276. * Gets the impostor for a physics enabled object
  23277. * @param object defines the object impersonated by the impostor
  23278. * @returns the PhysicsImpostor or null if not found
  23279. */
  23280. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23281. /**
  23282. * Gets the impostor for a physics body object
  23283. * @param body defines physics body used by the impostor
  23284. * @returns the PhysicsImpostor or null if not found
  23285. */
  23286. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23287. /**
  23288. * Does a raycast in the physics world
  23289. * @param from when should the ray start?
  23290. * @param to when should the ray end?
  23291. * @returns PhysicsRaycastResult
  23292. */
  23293. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23294. /**
  23295. * Called by the scene. No need to call it.
  23296. * @param delta defines the timespam between frames
  23297. */
  23298. _step(delta: number): void;
  23299. }
  23300. }
  23301. declare module "babylonjs/Physics/physicsImpostor" {
  23302. import { Nullable, IndicesArray } from "babylonjs/types";
  23303. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23306. import { Scene } from "babylonjs/scene";
  23307. import { Bone } from "babylonjs/Bones/bone";
  23308. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23309. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23310. import { Space } from "babylonjs/Maths/math.axis";
  23311. /**
  23312. * The interface for the physics imposter parameters
  23313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23314. */
  23315. export interface PhysicsImpostorParameters {
  23316. /**
  23317. * The mass of the physics imposter
  23318. */
  23319. mass: number;
  23320. /**
  23321. * The friction of the physics imposter
  23322. */
  23323. friction?: number;
  23324. /**
  23325. * The coefficient of restitution of the physics imposter
  23326. */
  23327. restitution?: number;
  23328. /**
  23329. * The native options of the physics imposter
  23330. */
  23331. nativeOptions?: any;
  23332. /**
  23333. * Specifies if the parent should be ignored
  23334. */
  23335. ignoreParent?: boolean;
  23336. /**
  23337. * Specifies if bi-directional transformations should be disabled
  23338. */
  23339. disableBidirectionalTransformation?: boolean;
  23340. /**
  23341. * The pressure inside the physics imposter, soft object only
  23342. */
  23343. pressure?: number;
  23344. /**
  23345. * The stiffness the physics imposter, soft object only
  23346. */
  23347. stiffness?: number;
  23348. /**
  23349. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23350. */
  23351. velocityIterations?: number;
  23352. /**
  23353. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23354. */
  23355. positionIterations?: number;
  23356. /**
  23357. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23358. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23359. * Add to fix multiple points
  23360. */
  23361. fixedPoints?: number;
  23362. /**
  23363. * The collision margin around a soft object
  23364. */
  23365. margin?: number;
  23366. /**
  23367. * The collision margin around a soft object
  23368. */
  23369. damping?: number;
  23370. /**
  23371. * The path for a rope based on an extrusion
  23372. */
  23373. path?: any;
  23374. /**
  23375. * The shape of an extrusion used for a rope based on an extrusion
  23376. */
  23377. shape?: any;
  23378. }
  23379. /**
  23380. * Interface for a physics-enabled object
  23381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23382. */
  23383. export interface IPhysicsEnabledObject {
  23384. /**
  23385. * The position of the physics-enabled object
  23386. */
  23387. position: Vector3;
  23388. /**
  23389. * The rotation of the physics-enabled object
  23390. */
  23391. rotationQuaternion: Nullable<Quaternion>;
  23392. /**
  23393. * The scale of the physics-enabled object
  23394. */
  23395. scaling: Vector3;
  23396. /**
  23397. * The rotation of the physics-enabled object
  23398. */
  23399. rotation?: Vector3;
  23400. /**
  23401. * The parent of the physics-enabled object
  23402. */
  23403. parent?: any;
  23404. /**
  23405. * The bounding info of the physics-enabled object
  23406. * @returns The bounding info of the physics-enabled object
  23407. */
  23408. getBoundingInfo(): BoundingInfo;
  23409. /**
  23410. * Computes the world matrix
  23411. * @param force Specifies if the world matrix should be computed by force
  23412. * @returns A world matrix
  23413. */
  23414. computeWorldMatrix(force: boolean): Matrix;
  23415. /**
  23416. * Gets the world matrix
  23417. * @returns A world matrix
  23418. */
  23419. getWorldMatrix?(): Matrix;
  23420. /**
  23421. * Gets the child meshes
  23422. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23423. * @returns An array of abstract meshes
  23424. */
  23425. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23426. /**
  23427. * Gets the vertex data
  23428. * @param kind The type of vertex data
  23429. * @returns A nullable array of numbers, or a float32 array
  23430. */
  23431. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23432. /**
  23433. * Gets the indices from the mesh
  23434. * @returns A nullable array of index arrays
  23435. */
  23436. getIndices?(): Nullable<IndicesArray>;
  23437. /**
  23438. * Gets the scene from the mesh
  23439. * @returns the indices array or null
  23440. */
  23441. getScene?(): Scene;
  23442. /**
  23443. * Gets the absolute position from the mesh
  23444. * @returns the absolute position
  23445. */
  23446. getAbsolutePosition(): Vector3;
  23447. /**
  23448. * Gets the absolute pivot point from the mesh
  23449. * @returns the absolute pivot point
  23450. */
  23451. getAbsolutePivotPoint(): Vector3;
  23452. /**
  23453. * Rotates the mesh
  23454. * @param axis The axis of rotation
  23455. * @param amount The amount of rotation
  23456. * @param space The space of the rotation
  23457. * @returns The rotation transform node
  23458. */
  23459. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23460. /**
  23461. * Translates the mesh
  23462. * @param axis The axis of translation
  23463. * @param distance The distance of translation
  23464. * @param space The space of the translation
  23465. * @returns The transform node
  23466. */
  23467. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23468. /**
  23469. * Sets the absolute position of the mesh
  23470. * @param absolutePosition The absolute position of the mesh
  23471. * @returns The transform node
  23472. */
  23473. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23474. /**
  23475. * Gets the class name of the mesh
  23476. * @returns The class name
  23477. */
  23478. getClassName(): string;
  23479. }
  23480. /**
  23481. * Represents a physics imposter
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export class PhysicsImpostor {
  23485. /**
  23486. * The physics-enabled object used as the physics imposter
  23487. */
  23488. object: IPhysicsEnabledObject;
  23489. /**
  23490. * The type of the physics imposter
  23491. */
  23492. type: number;
  23493. private _options;
  23494. private _scene?;
  23495. /**
  23496. * The default object size of the imposter
  23497. */
  23498. static DEFAULT_OBJECT_SIZE: Vector3;
  23499. /**
  23500. * The identity quaternion of the imposter
  23501. */
  23502. static IDENTITY_QUATERNION: Quaternion;
  23503. /** @hidden */
  23504. _pluginData: any;
  23505. private _physicsEngine;
  23506. private _physicsBody;
  23507. private _bodyUpdateRequired;
  23508. private _onBeforePhysicsStepCallbacks;
  23509. private _onAfterPhysicsStepCallbacks;
  23510. /** @hidden */
  23511. _onPhysicsCollideCallbacks: Array<{
  23512. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23513. otherImpostors: Array<PhysicsImpostor>;
  23514. }>;
  23515. private _deltaPosition;
  23516. private _deltaRotation;
  23517. private _deltaRotationConjugated;
  23518. /** @hidden */
  23519. _isFromLine: boolean;
  23520. private _parent;
  23521. private _isDisposed;
  23522. private static _tmpVecs;
  23523. private static _tmpQuat;
  23524. /**
  23525. * Specifies if the physics imposter is disposed
  23526. */
  23527. readonly isDisposed: boolean;
  23528. /**
  23529. * Gets the mass of the physics imposter
  23530. */
  23531. mass: number;
  23532. /**
  23533. * Gets the coefficient of friction
  23534. */
  23535. /**
  23536. * Sets the coefficient of friction
  23537. */
  23538. friction: number;
  23539. /**
  23540. * Gets the coefficient of restitution
  23541. */
  23542. /**
  23543. * Sets the coefficient of restitution
  23544. */
  23545. restitution: number;
  23546. /**
  23547. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23548. */
  23549. /**
  23550. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23551. */
  23552. pressure: number;
  23553. /**
  23554. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23555. */
  23556. /**
  23557. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23558. */
  23559. stiffness: number;
  23560. /**
  23561. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23562. */
  23563. /**
  23564. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23565. */
  23566. velocityIterations: number;
  23567. /**
  23568. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23569. */
  23570. /**
  23571. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23572. */
  23573. positionIterations: number;
  23574. /**
  23575. * The unique id of the physics imposter
  23576. * set by the physics engine when adding this impostor to the array
  23577. */
  23578. uniqueId: number;
  23579. /**
  23580. * @hidden
  23581. */
  23582. soft: boolean;
  23583. /**
  23584. * @hidden
  23585. */
  23586. segments: number;
  23587. private _joints;
  23588. /**
  23589. * Initializes the physics imposter
  23590. * @param object The physics-enabled object used as the physics imposter
  23591. * @param type The type of the physics imposter
  23592. * @param _options The options for the physics imposter
  23593. * @param _scene The Babylon scene
  23594. */
  23595. constructor(
  23596. /**
  23597. * The physics-enabled object used as the physics imposter
  23598. */
  23599. object: IPhysicsEnabledObject,
  23600. /**
  23601. * The type of the physics imposter
  23602. */
  23603. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23604. /**
  23605. * This function will completly initialize this impostor.
  23606. * It will create a new body - but only if this mesh has no parent.
  23607. * If it has, this impostor will not be used other than to define the impostor
  23608. * of the child mesh.
  23609. * @hidden
  23610. */
  23611. _init(): void;
  23612. private _getPhysicsParent;
  23613. /**
  23614. * Should a new body be generated.
  23615. * @returns boolean specifying if body initialization is required
  23616. */
  23617. isBodyInitRequired(): boolean;
  23618. /**
  23619. * Sets the updated scaling
  23620. * @param updated Specifies if the scaling is updated
  23621. */
  23622. setScalingUpdated(): void;
  23623. /**
  23624. * Force a regeneration of this or the parent's impostor's body.
  23625. * Use under cautious - This will remove all joints already implemented.
  23626. */
  23627. forceUpdate(): void;
  23628. /**
  23629. * Gets the body that holds this impostor. Either its own, or its parent.
  23630. */
  23631. /**
  23632. * Set the physics body. Used mainly by the physics engine/plugin
  23633. */
  23634. physicsBody: any;
  23635. /**
  23636. * Get the parent of the physics imposter
  23637. * @returns Physics imposter or null
  23638. */
  23639. /**
  23640. * Sets the parent of the physics imposter
  23641. */
  23642. parent: Nullable<PhysicsImpostor>;
  23643. /**
  23644. * Resets the update flags
  23645. */
  23646. resetUpdateFlags(): void;
  23647. /**
  23648. * Gets the object extend size
  23649. * @returns the object extend size
  23650. */
  23651. getObjectExtendSize(): Vector3;
  23652. /**
  23653. * Gets the object center
  23654. * @returns The object center
  23655. */
  23656. getObjectCenter(): Vector3;
  23657. /**
  23658. * Get a specific parametes from the options parameter
  23659. * @param paramName The object parameter name
  23660. * @returns The object parameter
  23661. */
  23662. getParam(paramName: string): any;
  23663. /**
  23664. * Sets a specific parameter in the options given to the physics plugin
  23665. * @param paramName The parameter name
  23666. * @param value The value of the parameter
  23667. */
  23668. setParam(paramName: string, value: number): void;
  23669. /**
  23670. * Specifically change the body's mass option. Won't recreate the physics body object
  23671. * @param mass The mass of the physics imposter
  23672. */
  23673. setMass(mass: number): void;
  23674. /**
  23675. * Gets the linear velocity
  23676. * @returns linear velocity or null
  23677. */
  23678. getLinearVelocity(): Nullable<Vector3>;
  23679. /**
  23680. * Sets the linear velocity
  23681. * @param velocity linear velocity or null
  23682. */
  23683. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23684. /**
  23685. * Gets the angular velocity
  23686. * @returns angular velocity or null
  23687. */
  23688. getAngularVelocity(): Nullable<Vector3>;
  23689. /**
  23690. * Sets the angular velocity
  23691. * @param velocity The velocity or null
  23692. */
  23693. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23694. /**
  23695. * Execute a function with the physics plugin native code
  23696. * Provide a function the will have two variables - the world object and the physics body object
  23697. * @param func The function to execute with the physics plugin native code
  23698. */
  23699. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23700. /**
  23701. * Register a function that will be executed before the physics world is stepping forward
  23702. * @param func The function to execute before the physics world is stepped forward
  23703. */
  23704. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23705. /**
  23706. * Unregister a function that will be executed before the physics world is stepping forward
  23707. * @param func The function to execute before the physics world is stepped forward
  23708. */
  23709. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23710. /**
  23711. * Register a function that will be executed after the physics step
  23712. * @param func The function to execute after physics step
  23713. */
  23714. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23715. /**
  23716. * Unregisters a function that will be executed after the physics step
  23717. * @param func The function to execute after physics step
  23718. */
  23719. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23720. /**
  23721. * register a function that will be executed when this impostor collides against a different body
  23722. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23723. * @param func Callback that is executed on collision
  23724. */
  23725. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23726. /**
  23727. * Unregisters the physics imposter on contact
  23728. * @param collideAgainst The physics object to collide against
  23729. * @param func Callback to execute on collision
  23730. */
  23731. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23732. private _tmpQuat;
  23733. private _tmpQuat2;
  23734. /**
  23735. * Get the parent rotation
  23736. * @returns The parent rotation
  23737. */
  23738. getParentsRotation(): Quaternion;
  23739. /**
  23740. * this function is executed by the physics engine.
  23741. */
  23742. beforeStep: () => void;
  23743. /**
  23744. * this function is executed by the physics engine
  23745. */
  23746. afterStep: () => void;
  23747. /**
  23748. * Legacy collision detection event support
  23749. */
  23750. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23751. /**
  23752. * event and body object due to cannon's event-based architecture.
  23753. */
  23754. onCollide: (e: {
  23755. body: any;
  23756. }) => void;
  23757. /**
  23758. * Apply a force
  23759. * @param force The force to apply
  23760. * @param contactPoint The contact point for the force
  23761. * @returns The physics imposter
  23762. */
  23763. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23764. /**
  23765. * Apply an impulse
  23766. * @param force The impulse force
  23767. * @param contactPoint The contact point for the impulse force
  23768. * @returns The physics imposter
  23769. */
  23770. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23771. /**
  23772. * A help function to create a joint
  23773. * @param otherImpostor A physics imposter used to create a joint
  23774. * @param jointType The type of joint
  23775. * @param jointData The data for the joint
  23776. * @returns The physics imposter
  23777. */
  23778. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23779. /**
  23780. * Add a joint to this impostor with a different impostor
  23781. * @param otherImpostor A physics imposter used to add a joint
  23782. * @param joint The joint to add
  23783. * @returns The physics imposter
  23784. */
  23785. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23786. /**
  23787. * Add an anchor to a cloth impostor
  23788. * @param otherImpostor rigid impostor to anchor to
  23789. * @param width ratio across width from 0 to 1
  23790. * @param height ratio up height from 0 to 1
  23791. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23792. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23793. * @returns impostor the soft imposter
  23794. */
  23795. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23796. /**
  23797. * Add a hook to a rope impostor
  23798. * @param otherImpostor rigid impostor to anchor to
  23799. * @param length ratio across rope from 0 to 1
  23800. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23801. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23802. * @returns impostor the rope imposter
  23803. */
  23804. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23805. /**
  23806. * Will keep this body still, in a sleep mode.
  23807. * @returns the physics imposter
  23808. */
  23809. sleep(): PhysicsImpostor;
  23810. /**
  23811. * Wake the body up.
  23812. * @returns The physics imposter
  23813. */
  23814. wakeUp(): PhysicsImpostor;
  23815. /**
  23816. * Clones the physics imposter
  23817. * @param newObject The physics imposter clones to this physics-enabled object
  23818. * @returns A nullable physics imposter
  23819. */
  23820. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23821. /**
  23822. * Disposes the physics imposter
  23823. */
  23824. dispose(): void;
  23825. /**
  23826. * Sets the delta position
  23827. * @param position The delta position amount
  23828. */
  23829. setDeltaPosition(position: Vector3): void;
  23830. /**
  23831. * Sets the delta rotation
  23832. * @param rotation The delta rotation amount
  23833. */
  23834. setDeltaRotation(rotation: Quaternion): void;
  23835. /**
  23836. * Gets the box size of the physics imposter and stores the result in the input parameter
  23837. * @param result Stores the box size
  23838. * @returns The physics imposter
  23839. */
  23840. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23841. /**
  23842. * Gets the radius of the physics imposter
  23843. * @returns Radius of the physics imposter
  23844. */
  23845. getRadius(): number;
  23846. /**
  23847. * Sync a bone with this impostor
  23848. * @param bone The bone to sync to the impostor.
  23849. * @param boneMesh The mesh that the bone is influencing.
  23850. * @param jointPivot The pivot of the joint / bone in local space.
  23851. * @param distToJoint Optional distance from the impostor to the joint.
  23852. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23853. */
  23854. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23855. /**
  23856. * Sync impostor to a bone
  23857. * @param bone The bone that the impostor will be synced to.
  23858. * @param boneMesh The mesh that the bone is influencing.
  23859. * @param jointPivot The pivot of the joint / bone in local space.
  23860. * @param distToJoint Optional distance from the impostor to the joint.
  23861. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23862. * @param boneAxis Optional vector3 axis the bone is aligned with
  23863. */
  23864. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23865. /**
  23866. * No-Imposter type
  23867. */
  23868. static NoImpostor: number;
  23869. /**
  23870. * Sphere-Imposter type
  23871. */
  23872. static SphereImpostor: number;
  23873. /**
  23874. * Box-Imposter type
  23875. */
  23876. static BoxImpostor: number;
  23877. /**
  23878. * Plane-Imposter type
  23879. */
  23880. static PlaneImpostor: number;
  23881. /**
  23882. * Mesh-imposter type
  23883. */
  23884. static MeshImpostor: number;
  23885. /**
  23886. * Capsule-Impostor type (Ammo.js plugin only)
  23887. */
  23888. static CapsuleImpostor: number;
  23889. /**
  23890. * Cylinder-Imposter type
  23891. */
  23892. static CylinderImpostor: number;
  23893. /**
  23894. * Particle-Imposter type
  23895. */
  23896. static ParticleImpostor: number;
  23897. /**
  23898. * Heightmap-Imposter type
  23899. */
  23900. static HeightmapImpostor: number;
  23901. /**
  23902. * ConvexHull-Impostor type (Ammo.js plugin only)
  23903. */
  23904. static ConvexHullImpostor: number;
  23905. /**
  23906. * Rope-Imposter type
  23907. */
  23908. static RopeImpostor: number;
  23909. /**
  23910. * Cloth-Imposter type
  23911. */
  23912. static ClothImpostor: number;
  23913. /**
  23914. * Softbody-Imposter type
  23915. */
  23916. static SoftbodyImpostor: number;
  23917. }
  23918. }
  23919. declare module "babylonjs/Meshes/mesh" {
  23920. import { Observable } from "babylonjs/Misc/observable";
  23921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23922. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23923. import { Camera } from "babylonjs/Cameras/camera";
  23924. import { Scene } from "babylonjs/scene";
  23925. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23926. import { Color4 } from "babylonjs/Maths/math.color";
  23927. import { Engine } from "babylonjs/Engines/engine";
  23928. import { Node } from "babylonjs/node";
  23929. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23930. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23931. import { Buffer } from "babylonjs/Meshes/buffer";
  23932. import { Geometry } from "babylonjs/Meshes/geometry";
  23933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23934. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23935. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23936. import { Effect } from "babylonjs/Materials/effect";
  23937. import { Material } from "babylonjs/Materials/material";
  23938. import { Skeleton } from "babylonjs/Bones/skeleton";
  23939. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23940. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23941. import { Path3D } from "babylonjs/Maths/math.path";
  23942. import { Plane } from "babylonjs/Maths/math.plane";
  23943. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23944. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23945. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23946. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23947. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23948. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23949. /**
  23950. * @hidden
  23951. **/
  23952. export class _CreationDataStorage {
  23953. closePath?: boolean;
  23954. closeArray?: boolean;
  23955. idx: number[];
  23956. dashSize: number;
  23957. gapSize: number;
  23958. path3D: Path3D;
  23959. pathArray: Vector3[][];
  23960. arc: number;
  23961. radius: number;
  23962. cap: number;
  23963. tessellation: number;
  23964. }
  23965. /**
  23966. * @hidden
  23967. **/
  23968. class _InstanceDataStorage {
  23969. visibleInstances: any;
  23970. batchCache: _InstancesBatch;
  23971. instancesBufferSize: number;
  23972. instancesBuffer: Nullable<Buffer>;
  23973. instancesData: Float32Array;
  23974. overridenInstanceCount: number;
  23975. isFrozen: boolean;
  23976. previousBatch: Nullable<_InstancesBatch>;
  23977. hardwareInstancedRendering: boolean;
  23978. sideOrientation: number;
  23979. }
  23980. /**
  23981. * @hidden
  23982. **/
  23983. export class _InstancesBatch {
  23984. mustReturn: boolean;
  23985. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23986. renderSelf: boolean[];
  23987. hardwareInstancedRendering: boolean[];
  23988. }
  23989. /**
  23990. * Class used to represent renderable models
  23991. */
  23992. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23993. /**
  23994. * Mesh side orientation : usually the external or front surface
  23995. */
  23996. static readonly FRONTSIDE: number;
  23997. /**
  23998. * Mesh side orientation : usually the internal or back surface
  23999. */
  24000. static readonly BACKSIDE: number;
  24001. /**
  24002. * Mesh side orientation : both internal and external or front and back surfaces
  24003. */
  24004. static readonly DOUBLESIDE: number;
  24005. /**
  24006. * Mesh side orientation : by default, `FRONTSIDE`
  24007. */
  24008. static readonly DEFAULTSIDE: number;
  24009. /**
  24010. * Mesh cap setting : no cap
  24011. */
  24012. static readonly NO_CAP: number;
  24013. /**
  24014. * Mesh cap setting : one cap at the beginning of the mesh
  24015. */
  24016. static readonly CAP_START: number;
  24017. /**
  24018. * Mesh cap setting : one cap at the end of the mesh
  24019. */
  24020. static readonly CAP_END: number;
  24021. /**
  24022. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24023. */
  24024. static readonly CAP_ALL: number;
  24025. /**
  24026. * Mesh pattern setting : no flip or rotate
  24027. */
  24028. static readonly NO_FLIP: number;
  24029. /**
  24030. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24031. */
  24032. static readonly FLIP_TILE: number;
  24033. /**
  24034. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24035. */
  24036. static readonly ROTATE_TILE: number;
  24037. /**
  24038. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24039. */
  24040. static readonly FLIP_ROW: number;
  24041. /**
  24042. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24043. */
  24044. static readonly ROTATE_ROW: number;
  24045. /**
  24046. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24047. */
  24048. static readonly FLIP_N_ROTATE_TILE: number;
  24049. /**
  24050. * Mesh pattern setting : rotate pattern and rotate
  24051. */
  24052. static readonly FLIP_N_ROTATE_ROW: number;
  24053. /**
  24054. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24055. */
  24056. static readonly CENTER: number;
  24057. /**
  24058. * Mesh tile positioning : part tiles on left
  24059. */
  24060. static readonly LEFT: number;
  24061. /**
  24062. * Mesh tile positioning : part tiles on right
  24063. */
  24064. static readonly RIGHT: number;
  24065. /**
  24066. * Mesh tile positioning : part tiles on top
  24067. */
  24068. static readonly TOP: number;
  24069. /**
  24070. * Mesh tile positioning : part tiles on bottom
  24071. */
  24072. static readonly BOTTOM: number;
  24073. /**
  24074. * Gets the default side orientation.
  24075. * @param orientation the orientation to value to attempt to get
  24076. * @returns the default orientation
  24077. * @hidden
  24078. */
  24079. static _GetDefaultSideOrientation(orientation?: number): number;
  24080. private _internalMeshDataInfo;
  24081. /**
  24082. * An event triggered before rendering the mesh
  24083. */
  24084. readonly onBeforeRenderObservable: Observable<Mesh>;
  24085. /**
  24086. * An event triggered before binding the mesh
  24087. */
  24088. readonly onBeforeBindObservable: Observable<Mesh>;
  24089. /**
  24090. * An event triggered after rendering the mesh
  24091. */
  24092. readonly onAfterRenderObservable: Observable<Mesh>;
  24093. /**
  24094. * An event triggered before drawing the mesh
  24095. */
  24096. readonly onBeforeDrawObservable: Observable<Mesh>;
  24097. private _onBeforeDrawObserver;
  24098. /**
  24099. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24100. */
  24101. onBeforeDraw: () => void;
  24102. readonly hasInstances: boolean;
  24103. /**
  24104. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24105. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24106. */
  24107. delayLoadState: number;
  24108. /**
  24109. * Gets the list of instances created from this mesh
  24110. * it is not supposed to be modified manually.
  24111. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24112. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24113. */
  24114. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24115. /**
  24116. * Gets the file containing delay loading data for this mesh
  24117. */
  24118. delayLoadingFile: string;
  24119. /** @hidden */
  24120. _binaryInfo: any;
  24121. /**
  24122. * User defined function used to change how LOD level selection is done
  24123. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24124. */
  24125. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24126. /**
  24127. * Gets or sets the morph target manager
  24128. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24129. */
  24130. morphTargetManager: Nullable<MorphTargetManager>;
  24131. /** @hidden */
  24132. _creationDataStorage: Nullable<_CreationDataStorage>;
  24133. /** @hidden */
  24134. _geometry: Nullable<Geometry>;
  24135. /** @hidden */
  24136. _delayInfo: Array<string>;
  24137. /** @hidden */
  24138. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24139. /** @hidden */
  24140. _instanceDataStorage: _InstanceDataStorage;
  24141. private _effectiveMaterial;
  24142. /** @hidden */
  24143. _shouldGenerateFlatShading: boolean;
  24144. /** @hidden */
  24145. _originalBuilderSideOrientation: number;
  24146. /**
  24147. * Use this property to change the original side orientation defined at construction time
  24148. */
  24149. overrideMaterialSideOrientation: Nullable<number>;
  24150. /**
  24151. * Gets the source mesh (the one used to clone this one from)
  24152. */
  24153. readonly source: Nullable<Mesh>;
  24154. /**
  24155. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24156. */
  24157. isUnIndexed: boolean;
  24158. /**
  24159. * @constructor
  24160. * @param name The value used by scene.getMeshByName() to do a lookup.
  24161. * @param scene The scene to add this mesh to.
  24162. * @param parent The parent of this mesh, if it has one
  24163. * @param source An optional Mesh from which geometry is shared, cloned.
  24164. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24165. * When false, achieved by calling a clone(), also passing False.
  24166. * This will make creation of children, recursive.
  24167. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24168. */
  24169. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24170. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24171. /**
  24172. * Gets the class name
  24173. * @returns the string "Mesh".
  24174. */
  24175. getClassName(): string;
  24176. /** @hidden */
  24177. readonly _isMesh: boolean;
  24178. /**
  24179. * Returns a description of this mesh
  24180. * @param fullDetails define if full details about this mesh must be used
  24181. * @returns a descriptive string representing this mesh
  24182. */
  24183. toString(fullDetails?: boolean): string;
  24184. /** @hidden */
  24185. _unBindEffect(): void;
  24186. /**
  24187. * Gets a boolean indicating if this mesh has LOD
  24188. */
  24189. readonly hasLODLevels: boolean;
  24190. /**
  24191. * Gets the list of MeshLODLevel associated with the current mesh
  24192. * @returns an array of MeshLODLevel
  24193. */
  24194. getLODLevels(): MeshLODLevel[];
  24195. private _sortLODLevels;
  24196. /**
  24197. * Add a mesh as LOD level triggered at the given distance.
  24198. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24199. * @param distance The distance from the center of the object to show this level
  24200. * @param mesh The mesh to be added as LOD level (can be null)
  24201. * @return This mesh (for chaining)
  24202. */
  24203. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24204. /**
  24205. * Returns the LOD level mesh at the passed distance or null if not found.
  24206. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24207. * @param distance The distance from the center of the object to show this level
  24208. * @returns a Mesh or `null`
  24209. */
  24210. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24211. /**
  24212. * Remove a mesh from the LOD array
  24213. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24214. * @param mesh defines the mesh to be removed
  24215. * @return This mesh (for chaining)
  24216. */
  24217. removeLODLevel(mesh: Mesh): Mesh;
  24218. /**
  24219. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24220. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24221. * @param camera defines the camera to use to compute distance
  24222. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24223. * @return This mesh (for chaining)
  24224. */
  24225. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24226. /**
  24227. * Gets the mesh internal Geometry object
  24228. */
  24229. readonly geometry: Nullable<Geometry>;
  24230. /**
  24231. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24232. * @returns the total number of vertices
  24233. */
  24234. getTotalVertices(): number;
  24235. /**
  24236. * Returns the content of an associated vertex buffer
  24237. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24238. * - VertexBuffer.PositionKind
  24239. * - VertexBuffer.UVKind
  24240. * - VertexBuffer.UV2Kind
  24241. * - VertexBuffer.UV3Kind
  24242. * - VertexBuffer.UV4Kind
  24243. * - VertexBuffer.UV5Kind
  24244. * - VertexBuffer.UV6Kind
  24245. * - VertexBuffer.ColorKind
  24246. * - VertexBuffer.MatricesIndicesKind
  24247. * - VertexBuffer.MatricesIndicesExtraKind
  24248. * - VertexBuffer.MatricesWeightsKind
  24249. * - VertexBuffer.MatricesWeightsExtraKind
  24250. * @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
  24251. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24252. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24253. */
  24254. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24255. /**
  24256. * Returns the mesh VertexBuffer object from the requested `kind`
  24257. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24258. * - VertexBuffer.PositionKind
  24259. * - VertexBuffer.NormalKind
  24260. * - VertexBuffer.UVKind
  24261. * - VertexBuffer.UV2Kind
  24262. * - VertexBuffer.UV3Kind
  24263. * - VertexBuffer.UV4Kind
  24264. * - VertexBuffer.UV5Kind
  24265. * - VertexBuffer.UV6Kind
  24266. * - VertexBuffer.ColorKind
  24267. * - VertexBuffer.MatricesIndicesKind
  24268. * - VertexBuffer.MatricesIndicesExtraKind
  24269. * - VertexBuffer.MatricesWeightsKind
  24270. * - VertexBuffer.MatricesWeightsExtraKind
  24271. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24272. */
  24273. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24274. /**
  24275. * Tests if a specific vertex buffer is associated with this mesh
  24276. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24277. * - VertexBuffer.PositionKind
  24278. * - VertexBuffer.NormalKind
  24279. * - VertexBuffer.UVKind
  24280. * - VertexBuffer.UV2Kind
  24281. * - VertexBuffer.UV3Kind
  24282. * - VertexBuffer.UV4Kind
  24283. * - VertexBuffer.UV5Kind
  24284. * - VertexBuffer.UV6Kind
  24285. * - VertexBuffer.ColorKind
  24286. * - VertexBuffer.MatricesIndicesKind
  24287. * - VertexBuffer.MatricesIndicesExtraKind
  24288. * - VertexBuffer.MatricesWeightsKind
  24289. * - VertexBuffer.MatricesWeightsExtraKind
  24290. * @returns a boolean
  24291. */
  24292. isVerticesDataPresent(kind: string): boolean;
  24293. /**
  24294. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24295. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24296. * - VertexBuffer.PositionKind
  24297. * - VertexBuffer.UVKind
  24298. * - VertexBuffer.UV2Kind
  24299. * - VertexBuffer.UV3Kind
  24300. * - VertexBuffer.UV4Kind
  24301. * - VertexBuffer.UV5Kind
  24302. * - VertexBuffer.UV6Kind
  24303. * - VertexBuffer.ColorKind
  24304. * - VertexBuffer.MatricesIndicesKind
  24305. * - VertexBuffer.MatricesIndicesExtraKind
  24306. * - VertexBuffer.MatricesWeightsKind
  24307. * - VertexBuffer.MatricesWeightsExtraKind
  24308. * @returns a boolean
  24309. */
  24310. isVertexBufferUpdatable(kind: string): boolean;
  24311. /**
  24312. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24313. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24314. * - VertexBuffer.PositionKind
  24315. * - VertexBuffer.NormalKind
  24316. * - VertexBuffer.UVKind
  24317. * - VertexBuffer.UV2Kind
  24318. * - VertexBuffer.UV3Kind
  24319. * - VertexBuffer.UV4Kind
  24320. * - VertexBuffer.UV5Kind
  24321. * - VertexBuffer.UV6Kind
  24322. * - VertexBuffer.ColorKind
  24323. * - VertexBuffer.MatricesIndicesKind
  24324. * - VertexBuffer.MatricesIndicesExtraKind
  24325. * - VertexBuffer.MatricesWeightsKind
  24326. * - VertexBuffer.MatricesWeightsExtraKind
  24327. * @returns an array of strings
  24328. */
  24329. getVerticesDataKinds(): string[];
  24330. /**
  24331. * Returns a positive integer : the total number of indices in this mesh geometry.
  24332. * @returns the numner of indices or zero if the mesh has no geometry.
  24333. */
  24334. getTotalIndices(): number;
  24335. /**
  24336. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24337. * @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.
  24338. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24339. * @returns the indices array or an empty array if the mesh has no geometry
  24340. */
  24341. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24342. readonly isBlocked: boolean;
  24343. /**
  24344. * Determine if the current mesh is ready to be rendered
  24345. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24346. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24347. * @returns true if all associated assets are ready (material, textures, shaders)
  24348. */
  24349. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24350. /**
  24351. * 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.
  24352. */
  24353. readonly areNormalsFrozen: boolean;
  24354. /**
  24355. * 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.
  24356. * @returns the current mesh
  24357. */
  24358. freezeNormals(): Mesh;
  24359. /**
  24360. * 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
  24361. * @returns the current mesh
  24362. */
  24363. unfreezeNormals(): Mesh;
  24364. /**
  24365. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24366. */
  24367. overridenInstanceCount: number;
  24368. /** @hidden */
  24369. _preActivate(): Mesh;
  24370. /** @hidden */
  24371. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24372. /** @hidden */
  24373. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24374. /**
  24375. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24376. * This means the mesh underlying bounding box and sphere are recomputed.
  24377. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24378. * @returns the current mesh
  24379. */
  24380. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24381. /** @hidden */
  24382. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24383. /**
  24384. * This function will subdivide the mesh into multiple submeshes
  24385. * @param count defines the expected number of submeshes
  24386. */
  24387. subdivide(count: number): void;
  24388. /**
  24389. * Copy a FloatArray into a specific associated vertex buffer
  24390. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24391. * - VertexBuffer.PositionKind
  24392. * - VertexBuffer.UVKind
  24393. * - VertexBuffer.UV2Kind
  24394. * - VertexBuffer.UV3Kind
  24395. * - VertexBuffer.UV4Kind
  24396. * - VertexBuffer.UV5Kind
  24397. * - VertexBuffer.UV6Kind
  24398. * - VertexBuffer.ColorKind
  24399. * - VertexBuffer.MatricesIndicesKind
  24400. * - VertexBuffer.MatricesIndicesExtraKind
  24401. * - VertexBuffer.MatricesWeightsKind
  24402. * - VertexBuffer.MatricesWeightsExtraKind
  24403. * @param data defines the data source
  24404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24405. * @param stride defines the data stride size (can be null)
  24406. * @returns the current mesh
  24407. */
  24408. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24409. /**
  24410. * Flags an associated vertex buffer as updatable
  24411. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24412. * - VertexBuffer.PositionKind
  24413. * - VertexBuffer.UVKind
  24414. * - VertexBuffer.UV2Kind
  24415. * - VertexBuffer.UV3Kind
  24416. * - VertexBuffer.UV4Kind
  24417. * - VertexBuffer.UV5Kind
  24418. * - VertexBuffer.UV6Kind
  24419. * - VertexBuffer.ColorKind
  24420. * - VertexBuffer.MatricesIndicesKind
  24421. * - VertexBuffer.MatricesIndicesExtraKind
  24422. * - VertexBuffer.MatricesWeightsKind
  24423. * - VertexBuffer.MatricesWeightsExtraKind
  24424. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24425. */
  24426. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24427. /**
  24428. * Sets the mesh global Vertex Buffer
  24429. * @param buffer defines the buffer to use
  24430. * @returns the current mesh
  24431. */
  24432. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24433. /**
  24434. * Update a specific associated vertex buffer
  24435. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24436. * - VertexBuffer.PositionKind
  24437. * - VertexBuffer.UVKind
  24438. * - VertexBuffer.UV2Kind
  24439. * - VertexBuffer.UV3Kind
  24440. * - VertexBuffer.UV4Kind
  24441. * - VertexBuffer.UV5Kind
  24442. * - VertexBuffer.UV6Kind
  24443. * - VertexBuffer.ColorKind
  24444. * - VertexBuffer.MatricesIndicesKind
  24445. * - VertexBuffer.MatricesIndicesExtraKind
  24446. * - VertexBuffer.MatricesWeightsKind
  24447. * - VertexBuffer.MatricesWeightsExtraKind
  24448. * @param data defines the data source
  24449. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24450. * @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)
  24451. * @returns the current mesh
  24452. */
  24453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24454. /**
  24455. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24456. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24457. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24458. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24459. * @returns the current mesh
  24460. */
  24461. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24462. /**
  24463. * Creates a un-shared specific occurence of the geometry for the mesh.
  24464. * @returns the current mesh
  24465. */
  24466. makeGeometryUnique(): Mesh;
  24467. /**
  24468. * Set the index buffer of this mesh
  24469. * @param indices defines the source data
  24470. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24471. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24472. * @returns the current mesh
  24473. */
  24474. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24475. /**
  24476. * Update the current index buffer
  24477. * @param indices defines the source data
  24478. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24479. * @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)
  24480. * @returns the current mesh
  24481. */
  24482. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24483. /**
  24484. * Invert the geometry to move from a right handed system to a left handed one.
  24485. * @returns the current mesh
  24486. */
  24487. toLeftHanded(): Mesh;
  24488. /** @hidden */
  24489. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24490. /** @hidden */
  24491. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24492. /**
  24493. * Registers for this mesh a javascript function called just before the rendering process
  24494. * @param func defines the function to call before rendering this mesh
  24495. * @returns the current mesh
  24496. */
  24497. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24498. /**
  24499. * Disposes a previously registered javascript function called before the rendering
  24500. * @param func defines the function to remove
  24501. * @returns the current mesh
  24502. */
  24503. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24504. /**
  24505. * Registers for this mesh a javascript function called just after the rendering is complete
  24506. * @param func defines the function to call after rendering this mesh
  24507. * @returns the current mesh
  24508. */
  24509. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24510. /**
  24511. * Disposes a previously registered javascript function called after the rendering.
  24512. * @param func defines the function to remove
  24513. * @returns the current mesh
  24514. */
  24515. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24516. /** @hidden */
  24517. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24518. /** @hidden */
  24519. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24520. /** @hidden */
  24521. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24522. /** @hidden */
  24523. _rebuild(): void;
  24524. /** @hidden */
  24525. _freeze(): void;
  24526. /** @hidden */
  24527. _unFreeze(): void;
  24528. /**
  24529. * 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
  24530. * @param subMesh defines the subMesh to render
  24531. * @param enableAlphaMode defines if alpha mode can be changed
  24532. * @returns the current mesh
  24533. */
  24534. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24535. private _onBeforeDraw;
  24536. /**
  24537. * Renormalize the mesh and patch it up if there are no weights
  24538. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24539. * However in the case of zero weights then we set just a single influence to 1.
  24540. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24541. */
  24542. cleanMatrixWeights(): void;
  24543. private normalizeSkinFourWeights;
  24544. private normalizeSkinWeightsAndExtra;
  24545. /**
  24546. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24547. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24548. * the user know there was an issue with importing the mesh
  24549. * @returns a validation object with skinned, valid and report string
  24550. */
  24551. validateSkinning(): {
  24552. skinned: boolean;
  24553. valid: boolean;
  24554. report: string;
  24555. };
  24556. /** @hidden */
  24557. _checkDelayState(): Mesh;
  24558. private _queueLoad;
  24559. /**
  24560. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24561. * A mesh is in the frustum if its bounding box intersects the frustum
  24562. * @param frustumPlanes defines the frustum to test
  24563. * @returns true if the mesh is in the frustum planes
  24564. */
  24565. isInFrustum(frustumPlanes: Plane[]): boolean;
  24566. /**
  24567. * Sets the mesh material by the material or multiMaterial `id` property
  24568. * @param id is a string identifying the material or the multiMaterial
  24569. * @returns the current mesh
  24570. */
  24571. setMaterialByID(id: string): Mesh;
  24572. /**
  24573. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24574. * @returns an array of IAnimatable
  24575. */
  24576. getAnimatables(): IAnimatable[];
  24577. /**
  24578. * Modifies the mesh geometry according to the passed transformation matrix.
  24579. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24580. * The mesh normals are modified using the same transformation.
  24581. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24582. * @param transform defines the transform matrix to use
  24583. * @see http://doc.babylonjs.com/resources/baking_transformations
  24584. * @returns the current mesh
  24585. */
  24586. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24587. /**
  24588. * Modifies the mesh geometry according to its own current World Matrix.
  24589. * The mesh World Matrix is then reset.
  24590. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24591. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24592. * @see http://doc.babylonjs.com/resources/baking_transformations
  24593. * @returns the current mesh
  24594. */
  24595. bakeCurrentTransformIntoVertices(): Mesh;
  24596. /** @hidden */
  24597. readonly _positions: Nullable<Vector3[]>;
  24598. /** @hidden */
  24599. _resetPointsArrayCache(): Mesh;
  24600. /** @hidden */
  24601. _generatePointsArray(): boolean;
  24602. /**
  24603. * Returns a new Mesh object generated from the current mesh properties.
  24604. * This method must not get confused with createInstance()
  24605. * @param name is a string, the name given to the new mesh
  24606. * @param newParent can be any Node object (default `null`)
  24607. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24608. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24609. * @returns a new mesh
  24610. */
  24611. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24612. /**
  24613. * Releases resources associated with this mesh.
  24614. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24615. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24616. */
  24617. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24618. /**
  24619. * Modifies the mesh geometry according to a displacement map.
  24620. * 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.
  24621. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24622. * @param url is a string, the URL from the image file is to be downloaded.
  24623. * @param minHeight is the lower limit of the displacement.
  24624. * @param maxHeight is the upper limit of the displacement.
  24625. * @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.
  24626. * @param uvOffset is an optional vector2 used to offset UV.
  24627. * @param uvScale is an optional vector2 used to scale UV.
  24628. * @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.
  24629. * @returns the Mesh.
  24630. */
  24631. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24632. /**
  24633. * Modifies the mesh geometry according to a displacementMap buffer.
  24634. * 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.
  24635. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24636. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24637. * @param heightMapWidth is the width of the buffer image.
  24638. * @param heightMapHeight is the height of the buffer image.
  24639. * @param minHeight is the lower limit of the displacement.
  24640. * @param maxHeight is the upper limit of the displacement.
  24641. * @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.
  24642. * @param uvOffset is an optional vector2 used to offset UV.
  24643. * @param uvScale is an optional vector2 used to scale UV.
  24644. * @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.
  24645. * @returns the Mesh.
  24646. */
  24647. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24648. /**
  24649. * Modify the mesh to get a flat shading rendering.
  24650. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24651. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24652. * @returns current mesh
  24653. */
  24654. convertToFlatShadedMesh(): Mesh;
  24655. /**
  24656. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24657. * In other words, more vertices, no more indices and a single bigger VBO.
  24658. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24659. * @returns current mesh
  24660. */
  24661. convertToUnIndexedMesh(): Mesh;
  24662. /**
  24663. * Inverses facet orientations.
  24664. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24665. * @param flipNormals will also inverts the normals
  24666. * @returns current mesh
  24667. */
  24668. flipFaces(flipNormals?: boolean): Mesh;
  24669. /**
  24670. * Increase the number of facets and hence vertices in a mesh
  24671. * Vertex normals are interpolated from existing vertex normals
  24672. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24673. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24674. */
  24675. increaseVertices(numberPerEdge: number): void;
  24676. /**
  24677. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24678. * This will undo any application of covertToFlatShadedMesh
  24679. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24680. */
  24681. forceSharedVertices(): void;
  24682. /** @hidden */
  24683. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24684. /** @hidden */
  24685. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24686. /**
  24687. * Creates a new InstancedMesh object from the mesh model.
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24689. * @param name defines the name of the new instance
  24690. * @returns a new InstancedMesh
  24691. */
  24692. createInstance(name: string): InstancedMesh;
  24693. /**
  24694. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24695. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24696. * @returns the current mesh
  24697. */
  24698. synchronizeInstances(): Mesh;
  24699. /**
  24700. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24701. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24702. * This should be used together with the simplification to avoid disappearing triangles.
  24703. * @param successCallback an optional success callback to be called after the optimization finished.
  24704. * @returns the current mesh
  24705. */
  24706. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24707. /**
  24708. * Serialize current mesh
  24709. * @param serializationObject defines the object which will receive the serialization data
  24710. */
  24711. serialize(serializationObject: any): void;
  24712. /** @hidden */
  24713. _syncGeometryWithMorphTargetManager(): void;
  24714. /** @hidden */
  24715. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24716. /**
  24717. * Returns a new Mesh object parsed from the source provided.
  24718. * @param parsedMesh is the source
  24719. * @param scene defines the hosting scene
  24720. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24721. * @returns a new Mesh
  24722. */
  24723. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24724. /**
  24725. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24726. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24727. * @param name defines the name of the mesh to create
  24728. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24729. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24730. * @param closePath creates a seam between the first and the last points of each path of the path array
  24731. * @param offset is taken in account only if the `pathArray` is containing a single path
  24732. * @param scene defines the hosting scene
  24733. * @param updatable defines if the mesh must be flagged as updatable
  24734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24735. * @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)
  24736. * @returns a new Mesh
  24737. */
  24738. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24739. /**
  24740. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24741. * @param name defines the name of the mesh to create
  24742. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24743. * @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
  24744. * @param scene defines the hosting scene
  24745. * @param updatable defines if the mesh must be flagged as updatable
  24746. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24747. * @returns a new Mesh
  24748. */
  24749. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24750. /**
  24751. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24752. * @param name defines the name of the mesh to create
  24753. * @param size sets the size (float) of each box side (default 1)
  24754. * @param scene defines the hosting scene
  24755. * @param updatable defines if the mesh must be flagged as updatable
  24756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24757. * @returns a new Mesh
  24758. */
  24759. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24760. /**
  24761. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24762. * @param name defines the name of the mesh to create
  24763. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24764. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24765. * @param scene defines the hosting scene
  24766. * @param updatable defines if the mesh must be flagged as updatable
  24767. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24768. * @returns a new Mesh
  24769. */
  24770. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24771. /**
  24772. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24773. * @param name defines the name of the mesh to create
  24774. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24775. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24776. * @param scene defines the hosting scene
  24777. * @returns a new Mesh
  24778. */
  24779. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24780. /**
  24781. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24782. * @param name defines the name of the mesh to create
  24783. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24784. * @param diameterTop set the top cap diameter (floats, default 1)
  24785. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24786. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24787. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24788. * @param scene defines the hosting scene
  24789. * @param updatable defines if the mesh must be flagged as updatable
  24790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24791. * @returns a new Mesh
  24792. */
  24793. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24794. /**
  24795. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24796. * @param name defines the name of the mesh to create
  24797. * @param diameter sets the diameter size (float) of the torus (default 1)
  24798. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24799. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24800. * @param scene defines the hosting scene
  24801. * @param updatable defines if the mesh must be flagged as updatable
  24802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24803. * @returns a new Mesh
  24804. */
  24805. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24806. /**
  24807. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24808. * @param name defines the name of the mesh to create
  24809. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24810. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24811. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24812. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24813. * @param p the number of windings on X axis (positive integers, default 2)
  24814. * @param q the number of windings on Y axis (positive integers, default 3)
  24815. * @param scene defines the hosting scene
  24816. * @param updatable defines if the mesh must be flagged as updatable
  24817. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24818. * @returns a new Mesh
  24819. */
  24820. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24821. /**
  24822. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24823. * @param name defines the name of the mesh to create
  24824. * @param points is an array successive Vector3
  24825. * @param scene defines the hosting scene
  24826. * @param updatable defines if the mesh must be flagged as updatable
  24827. * @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).
  24828. * @returns a new Mesh
  24829. */
  24830. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24831. /**
  24832. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24833. * @param name defines the name of the mesh to create
  24834. * @param points is an array successive Vector3
  24835. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24836. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24837. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24838. * @param scene defines the hosting scene
  24839. * @param updatable defines if the mesh must be flagged as updatable
  24840. * @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)
  24841. * @returns a new Mesh
  24842. */
  24843. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24844. /**
  24845. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24846. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24847. * 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.
  24848. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24849. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24850. * Remember you can only change the shape positions, not their number when updating a polygon.
  24851. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24852. * @param name defines the name of the mesh to create
  24853. * @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
  24854. * @param scene defines the hosting scene
  24855. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24858. * @param earcutInjection can be used to inject your own earcut reference
  24859. * @returns a new Mesh
  24860. */
  24861. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24862. /**
  24863. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24864. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24865. * @param name defines the name of the mesh to create
  24866. * @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
  24867. * @param depth defines the height of extrusion
  24868. * @param scene defines the hosting scene
  24869. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24870. * @param updatable defines if the mesh must be flagged as updatable
  24871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24872. * @param earcutInjection can be used to inject your own earcut reference
  24873. * @returns a new Mesh
  24874. */
  24875. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24876. /**
  24877. * Creates an extruded shape mesh.
  24878. * 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
  24879. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24880. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24881. * @param name defines the name of the mesh to create
  24882. * @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
  24883. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24884. * @param scale is the value to scale the shape
  24885. * @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
  24886. * @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
  24887. * @param scene defines the hosting scene
  24888. * @param updatable defines if the mesh must be flagged as updatable
  24889. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24890. * @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)
  24891. * @returns a new Mesh
  24892. */
  24893. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24894. /**
  24895. * Creates an custom extruded shape mesh.
  24896. * The custom extrusion is a parametric shape.
  24897. * It has no predefined shape. Its final shape will depend on the input parameters.
  24898. * Please consider using the same method from the MeshBuilder class instead
  24899. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24900. * @param name defines the name of the mesh to create
  24901. * @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
  24902. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24903. * @param scaleFunction is a custom Javascript function called on each path point
  24904. * @param rotationFunction is a custom Javascript function called on each path point
  24905. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24906. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24907. * @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
  24908. * @param scene defines the hosting scene
  24909. * @param updatable defines if the mesh must be flagged as updatable
  24910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24911. * @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)
  24912. * @returns a new Mesh
  24913. */
  24914. 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;
  24915. /**
  24916. * Creates lathe mesh.
  24917. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24918. * Please consider using the same method from the MeshBuilder class instead
  24919. * @param name defines the name of the mesh to create
  24920. * @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
  24921. * @param radius is the radius value of the lathe
  24922. * @param tessellation is the side number of the lathe.
  24923. * @param scene defines the hosting scene
  24924. * @param updatable defines if the mesh must be flagged as updatable
  24925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24926. * @returns a new Mesh
  24927. */
  24928. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24929. /**
  24930. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24931. * @param name defines the name of the mesh to create
  24932. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24933. * @param scene defines the hosting scene
  24934. * @param updatable defines if the mesh must be flagged as updatable
  24935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24936. * @returns a new Mesh
  24937. */
  24938. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24939. /**
  24940. * Creates a ground mesh.
  24941. * Please consider using the same method from the MeshBuilder class instead
  24942. * @param name defines the name of the mesh to create
  24943. * @param width set the width of the ground
  24944. * @param height set the height of the ground
  24945. * @param subdivisions sets the number of subdivisions per side
  24946. * @param scene defines the hosting scene
  24947. * @param updatable defines if the mesh must be flagged as updatable
  24948. * @returns a new Mesh
  24949. */
  24950. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24951. /**
  24952. * Creates a tiled ground mesh.
  24953. * Please consider using the same method from the MeshBuilder class instead
  24954. * @param name defines the name of the mesh to create
  24955. * @param xmin set the ground minimum X coordinate
  24956. * @param zmin set the ground minimum Y coordinate
  24957. * @param xmax set the ground maximum X coordinate
  24958. * @param zmax set the ground maximum Z coordinate
  24959. * @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
  24960. * @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
  24961. * @param scene defines the hosting scene
  24962. * @param updatable defines if the mesh must be flagged as updatable
  24963. * @returns a new Mesh
  24964. */
  24965. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24966. w: number;
  24967. h: number;
  24968. }, precision: {
  24969. w: number;
  24970. h: number;
  24971. }, scene: Scene, updatable?: boolean): Mesh;
  24972. /**
  24973. * Creates a ground mesh from a height map.
  24974. * Please consider using the same method from the MeshBuilder class instead
  24975. * @see http://doc.babylonjs.com/babylon101/height_map
  24976. * @param name defines the name of the mesh to create
  24977. * @param url sets the URL of the height map image resource
  24978. * @param width set the ground width size
  24979. * @param height set the ground height size
  24980. * @param subdivisions sets the number of subdivision per side
  24981. * @param minHeight is the minimum altitude on the ground
  24982. * @param maxHeight is the maximum altitude on the ground
  24983. * @param scene defines the hosting scene
  24984. * @param updatable defines if the mesh must be flagged as updatable
  24985. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24986. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24987. * @returns a new Mesh
  24988. */
  24989. 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;
  24990. /**
  24991. * Creates a tube mesh.
  24992. * The tube is a parametric shape.
  24993. * It has no predefined shape. Its final shape will depend on the input parameters.
  24994. * Please consider using the same method from the MeshBuilder class instead
  24995. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24996. * @param name defines the name of the mesh to create
  24997. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24998. * @param radius sets the tube radius size
  24999. * @param tessellation is the number of sides on the tubular surface
  25000. * @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
  25001. * @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
  25002. * @param scene defines the hosting scene
  25003. * @param updatable defines if the mesh must be flagged as updatable
  25004. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25005. * @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)
  25006. * @returns a new Mesh
  25007. */
  25008. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25009. (i: number, distance: number): number;
  25010. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25011. /**
  25012. * Creates a polyhedron mesh.
  25013. * Please consider using the same method from the MeshBuilder class instead.
  25014. * * 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
  25015. * * The parameter `size` (positive float, default 1) sets the polygon size
  25016. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25017. * * 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`
  25018. * * 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
  25019. * * 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)`)
  25020. * * 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
  25021. * * 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
  25022. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25023. * * If you create a double-sided mesh, you can choose what parts of 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
  25024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25025. * @param name defines the name of the mesh to create
  25026. * @param options defines the options used to create the mesh
  25027. * @param scene defines the hosting scene
  25028. * @returns a new Mesh
  25029. */
  25030. static CreatePolyhedron(name: string, options: {
  25031. type?: number;
  25032. size?: number;
  25033. sizeX?: number;
  25034. sizeY?: number;
  25035. sizeZ?: number;
  25036. custom?: any;
  25037. faceUV?: Vector4[];
  25038. faceColors?: Color4[];
  25039. updatable?: boolean;
  25040. sideOrientation?: number;
  25041. }, scene: Scene): Mesh;
  25042. /**
  25043. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25044. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25045. * * 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`)
  25046. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25047. * * 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
  25048. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25049. * * If you create a double-sided mesh, you can choose what parts of 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
  25050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25051. * @param name defines the name of the mesh
  25052. * @param options defines the options used to create the mesh
  25053. * @param scene defines the hosting scene
  25054. * @returns a new Mesh
  25055. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25056. */
  25057. static CreateIcoSphere(name: string, options: {
  25058. radius?: number;
  25059. flat?: boolean;
  25060. subdivisions?: number;
  25061. sideOrientation?: number;
  25062. updatable?: boolean;
  25063. }, scene: Scene): Mesh;
  25064. /**
  25065. * Creates a decal mesh.
  25066. * Please consider using the same method from the MeshBuilder class instead.
  25067. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25068. * @param name defines the name of the mesh
  25069. * @param sourceMesh defines the mesh receiving the decal
  25070. * @param position sets the position of the decal in world coordinates
  25071. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25072. * @param size sets the decal scaling
  25073. * @param angle sets the angle to rotate the decal
  25074. * @returns a new Mesh
  25075. */
  25076. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25077. /**
  25078. * Prepare internal position array for software CPU skinning
  25079. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25080. */
  25081. setPositionsForCPUSkinning(): Float32Array;
  25082. /**
  25083. * Prepare internal normal array for software CPU skinning
  25084. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25085. */
  25086. setNormalsForCPUSkinning(): Float32Array;
  25087. /**
  25088. * Updates the vertex buffer by applying transformation from the bones
  25089. * @param skeleton defines the skeleton to apply to current mesh
  25090. * @returns the current mesh
  25091. */
  25092. applySkeleton(skeleton: Skeleton): Mesh;
  25093. /**
  25094. * 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
  25095. * @param meshes defines the list of meshes to scan
  25096. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25097. */
  25098. static MinMax(meshes: AbstractMesh[]): {
  25099. min: Vector3;
  25100. max: Vector3;
  25101. };
  25102. /**
  25103. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25104. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25105. * @returns a vector3
  25106. */
  25107. static Center(meshesOrMinMaxVector: {
  25108. min: Vector3;
  25109. max: Vector3;
  25110. } | AbstractMesh[]): Vector3;
  25111. /**
  25112. * Merge the array of meshes into a single mesh for performance reasons.
  25113. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25114. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25115. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25116. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25117. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25118. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25119. * @returns a new mesh
  25120. */
  25121. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25122. /** @hidden */
  25123. addInstance(instance: InstancedMesh): void;
  25124. /** @hidden */
  25125. removeInstance(instance: InstancedMesh): void;
  25126. }
  25127. }
  25128. declare module "babylonjs/Cameras/camera" {
  25129. import { SmartArray } from "babylonjs/Misc/smartArray";
  25130. import { Observable } from "babylonjs/Misc/observable";
  25131. import { Nullable } from "babylonjs/types";
  25132. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25133. import { Scene } from "babylonjs/scene";
  25134. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25135. import { Node } from "babylonjs/node";
  25136. import { Mesh } from "babylonjs/Meshes/mesh";
  25137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25138. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25139. import { Viewport } from "babylonjs/Maths/math.viewport";
  25140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25142. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25143. import { Ray } from "babylonjs/Culling/ray";
  25144. /**
  25145. * This is the base class of all the camera used in the application.
  25146. * @see http://doc.babylonjs.com/features/cameras
  25147. */
  25148. export class Camera extends Node {
  25149. /** @hidden */
  25150. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25151. /**
  25152. * This is the default projection mode used by the cameras.
  25153. * It helps recreating a feeling of perspective and better appreciate depth.
  25154. * This is the best way to simulate real life cameras.
  25155. */
  25156. static readonly PERSPECTIVE_CAMERA: number;
  25157. /**
  25158. * This helps creating camera with an orthographic mode.
  25159. * 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.
  25160. */
  25161. static readonly ORTHOGRAPHIC_CAMERA: number;
  25162. /**
  25163. * This is the default FOV mode for perspective cameras.
  25164. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25165. */
  25166. static readonly FOVMODE_VERTICAL_FIXED: number;
  25167. /**
  25168. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25169. */
  25170. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25171. /**
  25172. * This specifies ther is no need for a camera rig.
  25173. * Basically only one eye is rendered corresponding to the camera.
  25174. */
  25175. static readonly RIG_MODE_NONE: number;
  25176. /**
  25177. * Simulates a camera Rig with one blue eye and one red eye.
  25178. * This can be use with 3d blue and red glasses.
  25179. */
  25180. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25181. /**
  25182. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25183. */
  25184. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25185. /**
  25186. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25187. */
  25188. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25189. /**
  25190. * Defines that both eyes of the camera will be rendered over under each other.
  25191. */
  25192. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25193. /**
  25194. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25195. */
  25196. static readonly RIG_MODE_VR: number;
  25197. /**
  25198. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25199. */
  25200. static readonly RIG_MODE_WEBVR: number;
  25201. /**
  25202. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25203. */
  25204. static readonly RIG_MODE_CUSTOM: number;
  25205. /**
  25206. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25207. */
  25208. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25209. /**
  25210. * Define the input manager associated with the camera.
  25211. */
  25212. inputs: CameraInputsManager<Camera>;
  25213. /** @hidden */
  25214. _position: Vector3;
  25215. /**
  25216. * Define the current local position of the camera in the scene
  25217. */
  25218. position: Vector3;
  25219. /**
  25220. * The vector the camera should consider as up.
  25221. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25222. */
  25223. upVector: Vector3;
  25224. /**
  25225. * Define the current limit on the left side for an orthographic camera
  25226. * In scene unit
  25227. */
  25228. orthoLeft: Nullable<number>;
  25229. /**
  25230. * Define the current limit on the right side for an orthographic camera
  25231. * In scene unit
  25232. */
  25233. orthoRight: Nullable<number>;
  25234. /**
  25235. * Define the current limit on the bottom side for an orthographic camera
  25236. * In scene unit
  25237. */
  25238. orthoBottom: Nullable<number>;
  25239. /**
  25240. * Define the current limit on the top side for an orthographic camera
  25241. * In scene unit
  25242. */
  25243. orthoTop: Nullable<number>;
  25244. /**
  25245. * Field Of View is set in Radians. (default is 0.8)
  25246. */
  25247. fov: number;
  25248. /**
  25249. * Define the minimum distance the camera can see from.
  25250. * This is important to note that the depth buffer are not infinite and the closer it starts
  25251. * the more your scene might encounter depth fighting issue.
  25252. */
  25253. minZ: number;
  25254. /**
  25255. * Define the maximum distance the camera can see to.
  25256. * This is important to note that the depth buffer are not infinite and the further it end
  25257. * the more your scene might encounter depth fighting issue.
  25258. */
  25259. maxZ: number;
  25260. /**
  25261. * Define the default inertia of the camera.
  25262. * This helps giving a smooth feeling to the camera movement.
  25263. */
  25264. inertia: number;
  25265. /**
  25266. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25267. */
  25268. mode: number;
  25269. /**
  25270. * Define wether the camera is intermediate.
  25271. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25272. */
  25273. isIntermediate: boolean;
  25274. /**
  25275. * Define the viewport of the camera.
  25276. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25277. */
  25278. viewport: Viewport;
  25279. /**
  25280. * Restricts the camera to viewing objects with the same layerMask.
  25281. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25282. */
  25283. layerMask: number;
  25284. /**
  25285. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25286. */
  25287. fovMode: number;
  25288. /**
  25289. * Rig mode of the camera.
  25290. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25291. * This is normally controlled byt the camera themselves as internal use.
  25292. */
  25293. cameraRigMode: number;
  25294. /**
  25295. * Defines the distance between both "eyes" in case of a RIG
  25296. */
  25297. interaxialDistance: number;
  25298. /**
  25299. * Defines if stereoscopic rendering is done side by side or over under.
  25300. */
  25301. isStereoscopicSideBySide: boolean;
  25302. /**
  25303. * 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
  25304. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25305. * else in the scene. (Eg. security camera)
  25306. *
  25307. * 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)
  25308. */
  25309. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25310. /**
  25311. * When set, the camera will render to this render target instead of the default canvas
  25312. *
  25313. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25314. */
  25315. outputRenderTarget: Nullable<RenderTargetTexture>;
  25316. /**
  25317. * Observable triggered when the camera view matrix has changed.
  25318. */
  25319. onViewMatrixChangedObservable: Observable<Camera>;
  25320. /**
  25321. * Observable triggered when the camera Projection matrix has changed.
  25322. */
  25323. onProjectionMatrixChangedObservable: Observable<Camera>;
  25324. /**
  25325. * Observable triggered when the inputs have been processed.
  25326. */
  25327. onAfterCheckInputsObservable: Observable<Camera>;
  25328. /**
  25329. * Observable triggered when reset has been called and applied to the camera.
  25330. */
  25331. onRestoreStateObservable: Observable<Camera>;
  25332. /** @hidden */
  25333. _cameraRigParams: any;
  25334. /** @hidden */
  25335. _rigCameras: Camera[];
  25336. /** @hidden */
  25337. _rigPostProcess: Nullable<PostProcess>;
  25338. protected _webvrViewMatrix: Matrix;
  25339. /** @hidden */
  25340. _skipRendering: boolean;
  25341. /** @hidden */
  25342. _projectionMatrix: Matrix;
  25343. /** @hidden */
  25344. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25345. /** @hidden */
  25346. _activeMeshes: SmartArray<AbstractMesh>;
  25347. protected _globalPosition: Vector3;
  25348. /** @hidden */
  25349. _computedViewMatrix: Matrix;
  25350. private _doNotComputeProjectionMatrix;
  25351. private _transformMatrix;
  25352. private _frustumPlanes;
  25353. private _refreshFrustumPlanes;
  25354. private _storedFov;
  25355. private _stateStored;
  25356. /**
  25357. * Instantiates a new camera object.
  25358. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25359. * @see http://doc.babylonjs.com/features/cameras
  25360. * @param name Defines the name of the camera in the scene
  25361. * @param position Defines the position of the camera
  25362. * @param scene Defines the scene the camera belongs too
  25363. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25364. */
  25365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25366. /**
  25367. * Store current camera state (fov, position, etc..)
  25368. * @returns the camera
  25369. */
  25370. storeState(): Camera;
  25371. /**
  25372. * Restores the camera state values if it has been stored. You must call storeState() first
  25373. */
  25374. protected _restoreStateValues(): boolean;
  25375. /**
  25376. * Restored camera state. You must call storeState() first.
  25377. * @returns true if restored and false otherwise
  25378. */
  25379. restoreState(): boolean;
  25380. /**
  25381. * Gets the class name of the camera.
  25382. * @returns the class name
  25383. */
  25384. getClassName(): string;
  25385. /** @hidden */
  25386. readonly _isCamera: boolean;
  25387. /**
  25388. * Gets a string representation of the camera useful for debug purpose.
  25389. * @param fullDetails Defines that a more verboe level of logging is required
  25390. * @returns the string representation
  25391. */
  25392. toString(fullDetails?: boolean): string;
  25393. /**
  25394. * Gets the current world space position of the camera.
  25395. */
  25396. readonly globalPosition: Vector3;
  25397. /**
  25398. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25399. * @returns the active meshe list
  25400. */
  25401. getActiveMeshes(): SmartArray<AbstractMesh>;
  25402. /**
  25403. * Check wether a mesh is part of the current active mesh list of the camera
  25404. * @param mesh Defines the mesh to check
  25405. * @returns true if active, false otherwise
  25406. */
  25407. isActiveMesh(mesh: Mesh): boolean;
  25408. /**
  25409. * Is this camera ready to be used/rendered
  25410. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25411. * @return true if the camera is ready
  25412. */
  25413. isReady(completeCheck?: boolean): boolean;
  25414. /** @hidden */
  25415. _initCache(): void;
  25416. /** @hidden */
  25417. _updateCache(ignoreParentClass?: boolean): void;
  25418. /** @hidden */
  25419. _isSynchronized(): boolean;
  25420. /** @hidden */
  25421. _isSynchronizedViewMatrix(): boolean;
  25422. /** @hidden */
  25423. _isSynchronizedProjectionMatrix(): boolean;
  25424. /**
  25425. * Attach the input controls to a specific dom element to get the input from.
  25426. * @param element Defines the element the controls should be listened from
  25427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25428. */
  25429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25430. /**
  25431. * Detach the current controls from the specified dom element.
  25432. * @param element Defines the element to stop listening the inputs from
  25433. */
  25434. detachControl(element: HTMLElement): void;
  25435. /**
  25436. * Update the camera state according to the different inputs gathered during the frame.
  25437. */
  25438. update(): void;
  25439. /** @hidden */
  25440. _checkInputs(): void;
  25441. /** @hidden */
  25442. readonly rigCameras: Camera[];
  25443. /**
  25444. * Gets the post process used by the rig cameras
  25445. */
  25446. readonly rigPostProcess: Nullable<PostProcess>;
  25447. /**
  25448. * Internal, gets the first post proces.
  25449. * @returns the first post process to be run on this camera.
  25450. */
  25451. _getFirstPostProcess(): Nullable<PostProcess>;
  25452. private _cascadePostProcessesToRigCams;
  25453. /**
  25454. * Attach a post process to the camera.
  25455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25456. * @param postProcess The post process to attach to the camera
  25457. * @param insertAt The position of the post process in case several of them are in use in the scene
  25458. * @returns the position the post process has been inserted at
  25459. */
  25460. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25461. /**
  25462. * Detach a post process to the camera.
  25463. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25464. * @param postProcess The post process to detach from the camera
  25465. */
  25466. detachPostProcess(postProcess: PostProcess): void;
  25467. /**
  25468. * Gets the current world matrix of the camera
  25469. */
  25470. getWorldMatrix(): Matrix;
  25471. /** @hidden */
  25472. _getViewMatrix(): Matrix;
  25473. /**
  25474. * Gets the current view matrix of the camera.
  25475. * @param force forces the camera to recompute the matrix without looking at the cached state
  25476. * @returns the view matrix
  25477. */
  25478. getViewMatrix(force?: boolean): Matrix;
  25479. /**
  25480. * Freeze the projection matrix.
  25481. * It will prevent the cache check of the camera projection compute and can speed up perf
  25482. * if no parameter of the camera are meant to change
  25483. * @param projection Defines manually a projection if necessary
  25484. */
  25485. freezeProjectionMatrix(projection?: Matrix): void;
  25486. /**
  25487. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25488. */
  25489. unfreezeProjectionMatrix(): void;
  25490. /**
  25491. * Gets the current projection matrix of the camera.
  25492. * @param force forces the camera to recompute the matrix without looking at the cached state
  25493. * @returns the projection matrix
  25494. */
  25495. getProjectionMatrix(force?: boolean): Matrix;
  25496. /**
  25497. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25498. * @returns a Matrix
  25499. */
  25500. getTransformationMatrix(): Matrix;
  25501. private _updateFrustumPlanes;
  25502. /**
  25503. * Checks if a cullable object (mesh...) is in the camera frustum
  25504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25505. * @param target The object to check
  25506. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25507. * @returns true if the object is in frustum otherwise false
  25508. */
  25509. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25510. /**
  25511. * Checks if a cullable object (mesh...) is in the camera frustum
  25512. * Unlike isInFrustum this cheks the full bounding box
  25513. * @param target The object to check
  25514. * @returns true if the object is in frustum otherwise false
  25515. */
  25516. isCompletelyInFrustum(target: ICullable): boolean;
  25517. /**
  25518. * Gets a ray in the forward direction from the camera.
  25519. * @param length Defines the length of the ray to create
  25520. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25521. * @param origin Defines the start point of the ray which defaults to the camera position
  25522. * @returns the forward ray
  25523. */
  25524. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25525. /**
  25526. * Releases resources associated with this node.
  25527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25529. */
  25530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25531. /** @hidden */
  25532. _isLeftCamera: boolean;
  25533. /**
  25534. * Gets the left camera of a rig setup in case of Rigged Camera
  25535. */
  25536. readonly isLeftCamera: boolean;
  25537. /** @hidden */
  25538. _isRightCamera: boolean;
  25539. /**
  25540. * Gets the right camera of a rig setup in case of Rigged Camera
  25541. */
  25542. readonly isRightCamera: boolean;
  25543. /**
  25544. * Gets the left camera of a rig setup in case of Rigged Camera
  25545. */
  25546. readonly leftCamera: Nullable<FreeCamera>;
  25547. /**
  25548. * Gets the right camera of a rig setup in case of Rigged Camera
  25549. */
  25550. readonly rightCamera: Nullable<FreeCamera>;
  25551. /**
  25552. * Gets the left camera target of a rig setup in case of Rigged Camera
  25553. * @returns the target position
  25554. */
  25555. getLeftTarget(): Nullable<Vector3>;
  25556. /**
  25557. * Gets the right camera target of a rig setup in case of Rigged Camera
  25558. * @returns the target position
  25559. */
  25560. getRightTarget(): Nullable<Vector3>;
  25561. /**
  25562. * @hidden
  25563. */
  25564. setCameraRigMode(mode: number, rigParams: any): void;
  25565. /** @hidden */
  25566. static _setStereoscopicRigMode(camera: Camera): void;
  25567. /** @hidden */
  25568. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25569. /** @hidden */
  25570. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25571. /** @hidden */
  25572. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25573. /** @hidden */
  25574. _getVRProjectionMatrix(): Matrix;
  25575. protected _updateCameraRotationMatrix(): void;
  25576. protected _updateWebVRCameraRotationMatrix(): void;
  25577. /**
  25578. * This function MUST be overwritten by the different WebVR cameras available.
  25579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25580. * @hidden
  25581. */
  25582. _getWebVRProjectionMatrix(): Matrix;
  25583. /**
  25584. * This function MUST be overwritten by the different WebVR cameras available.
  25585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25586. * @hidden
  25587. */
  25588. _getWebVRViewMatrix(): Matrix;
  25589. /** @hidden */
  25590. setCameraRigParameter(name: string, value: any): void;
  25591. /**
  25592. * needs to be overridden by children so sub has required properties to be copied
  25593. * @hidden
  25594. */
  25595. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25596. /**
  25597. * May need to be overridden by children
  25598. * @hidden
  25599. */
  25600. _updateRigCameras(): void;
  25601. /** @hidden */
  25602. _setupInputs(): void;
  25603. /**
  25604. * Serialiaze the camera setup to a json represention
  25605. * @returns the JSON representation
  25606. */
  25607. serialize(): any;
  25608. /**
  25609. * Clones the current camera.
  25610. * @param name The cloned camera name
  25611. * @returns the cloned camera
  25612. */
  25613. clone(name: string): Camera;
  25614. /**
  25615. * Gets the direction of the camera relative to a given local axis.
  25616. * @param localAxis Defines the reference axis to provide a relative direction.
  25617. * @return the direction
  25618. */
  25619. getDirection(localAxis: Vector3): Vector3;
  25620. /**
  25621. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25622. * @param localAxis Defines the reference axis to provide a relative direction.
  25623. * @param result Defines the vector to store the result in
  25624. */
  25625. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25626. /**
  25627. * Gets a camera constructor for a given camera type
  25628. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25629. * @param name The name of the camera the result will be able to instantiate
  25630. * @param scene The scene the result will construct the camera in
  25631. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25632. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25633. * @returns a factory method to construc the camera
  25634. */
  25635. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25636. /**
  25637. * Compute the world matrix of the camera.
  25638. * @returns the camera workd matrix
  25639. */
  25640. computeWorldMatrix(): Matrix;
  25641. /**
  25642. * Parse a JSON and creates the camera from the parsed information
  25643. * @param parsedCamera The JSON to parse
  25644. * @param scene The scene to instantiate the camera in
  25645. * @returns the newly constructed camera
  25646. */
  25647. static Parse(parsedCamera: any, scene: Scene): Camera;
  25648. }
  25649. }
  25650. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25651. import { Nullable } from "babylonjs/types";
  25652. import { Scene } from "babylonjs/scene";
  25653. import { Vector4 } from "babylonjs/Maths/math.vector";
  25654. import { Mesh } from "babylonjs/Meshes/mesh";
  25655. /**
  25656. * Class containing static functions to help procedurally build meshes
  25657. */
  25658. export class DiscBuilder {
  25659. /**
  25660. * Creates a plane polygonal mesh. By default, this is a disc
  25661. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25662. * * 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
  25663. * * 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
  25664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25667. * @param name defines the name of the mesh
  25668. * @param options defines the options used to create the mesh
  25669. * @param scene defines the hosting scene
  25670. * @returns the plane polygonal mesh
  25671. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25672. */
  25673. static CreateDisc(name: string, options: {
  25674. radius?: number;
  25675. tessellation?: number;
  25676. arc?: number;
  25677. updatable?: boolean;
  25678. sideOrientation?: number;
  25679. frontUVs?: Vector4;
  25680. backUVs?: Vector4;
  25681. }, scene?: Nullable<Scene>): Mesh;
  25682. }
  25683. }
  25684. declare module "babylonjs/Particles/solidParticleSystem" {
  25685. import { Vector3 } from "babylonjs/Maths/math.vector";
  25686. import { Mesh } from "babylonjs/Meshes/mesh";
  25687. import { Scene, IDisposable } from "babylonjs/scene";
  25688. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25689. /**
  25690. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25691. *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.
  25692. * The SPS is also a particle system. It provides some methods to manage the particles.
  25693. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25694. *
  25695. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25696. */
  25697. export class SolidParticleSystem implements IDisposable {
  25698. /**
  25699. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25700. * Example : var p = SPS.particles[i];
  25701. */
  25702. particles: SolidParticle[];
  25703. /**
  25704. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25705. */
  25706. nbParticles: number;
  25707. /**
  25708. * If the particles must ever face the camera (default false). Useful for planar particles.
  25709. */
  25710. billboard: boolean;
  25711. /**
  25712. * Recompute normals when adding a shape
  25713. */
  25714. recomputeNormals: boolean;
  25715. /**
  25716. * This a counter ofr your own usage. It's not set by any SPS functions.
  25717. */
  25718. counter: number;
  25719. /**
  25720. * The SPS name. This name is also given to the underlying mesh.
  25721. */
  25722. name: string;
  25723. /**
  25724. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25725. */
  25726. mesh: Mesh;
  25727. /**
  25728. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25729. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25730. */
  25731. vars: any;
  25732. /**
  25733. * This array is populated when the SPS is set as 'pickable'.
  25734. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25735. * Each element of this array is an object `{idx: int, faceId: int}`.
  25736. * `idx` is the picked particle index in the `SPS.particles` array
  25737. * `faceId` is the picked face index counted within this particle.
  25738. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25739. */
  25740. pickedParticles: {
  25741. idx: number;
  25742. faceId: number;
  25743. }[];
  25744. /**
  25745. * This array is populated when `enableDepthSort` is set to true.
  25746. * Each element of this array is an instance of the class DepthSortedParticle.
  25747. */
  25748. depthSortedParticles: DepthSortedParticle[];
  25749. /**
  25750. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25751. * @hidden
  25752. */
  25753. _bSphereOnly: boolean;
  25754. /**
  25755. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25756. * @hidden
  25757. */
  25758. _bSphereRadiusFactor: number;
  25759. private _scene;
  25760. private _positions;
  25761. private _indices;
  25762. private _normals;
  25763. private _colors;
  25764. private _uvs;
  25765. private _indices32;
  25766. private _positions32;
  25767. private _normals32;
  25768. private _fixedNormal32;
  25769. private _colors32;
  25770. private _uvs32;
  25771. private _index;
  25772. private _updatable;
  25773. private _pickable;
  25774. private _isVisibilityBoxLocked;
  25775. private _alwaysVisible;
  25776. private _depthSort;
  25777. private _shapeCounter;
  25778. private _copy;
  25779. private _color;
  25780. private _computeParticleColor;
  25781. private _computeParticleTexture;
  25782. private _computeParticleRotation;
  25783. private _computeParticleVertex;
  25784. private _computeBoundingBox;
  25785. private _depthSortParticles;
  25786. private _camera;
  25787. private _mustUnrotateFixedNormals;
  25788. private _particlesIntersect;
  25789. private _needs32Bits;
  25790. /**
  25791. * Creates a SPS (Solid Particle System) object.
  25792. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25793. * @param scene (Scene) is the scene in which the SPS is added.
  25794. * @param options defines the options of the sps e.g.
  25795. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25796. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25797. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25798. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25799. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25800. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25801. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25802. */
  25803. constructor(name: string, scene: Scene, options?: {
  25804. updatable?: boolean;
  25805. isPickable?: boolean;
  25806. enableDepthSort?: boolean;
  25807. particleIntersection?: boolean;
  25808. boundingSphereOnly?: boolean;
  25809. bSphereRadiusFactor?: number;
  25810. });
  25811. /**
  25812. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25813. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25814. * @returns the created mesh
  25815. */
  25816. buildMesh(): Mesh;
  25817. /**
  25818. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25819. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25820. * Thus the particles generated from `digest()` have their property `position` set yet.
  25821. * @param mesh ( Mesh ) is the mesh to be digested
  25822. * @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
  25823. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25824. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25825. * @returns the current SPS
  25826. */
  25827. digest(mesh: Mesh, options?: {
  25828. facetNb?: number;
  25829. number?: number;
  25830. delta?: number;
  25831. }): SolidParticleSystem;
  25832. private _unrotateFixedNormals;
  25833. private _resetCopy;
  25834. private _meshBuilder;
  25835. private _posToShape;
  25836. private _uvsToShapeUV;
  25837. private _addParticle;
  25838. /**
  25839. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25840. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25841. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25842. * @param nb (positive integer) the number of particles to be created from this model
  25843. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25844. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25845. * @returns the number of shapes in the system
  25846. */
  25847. addShape(mesh: Mesh, nb: number, options?: {
  25848. positionFunction?: any;
  25849. vertexFunction?: any;
  25850. }): number;
  25851. private _rebuildParticle;
  25852. /**
  25853. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25854. * @returns the SPS.
  25855. */
  25856. rebuildMesh(): SolidParticleSystem;
  25857. /**
  25858. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25859. * This method calls `updateParticle()` for each particle of the SPS.
  25860. * For an animated SPS, it is usually called within the render loop.
  25861. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25862. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25863. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25864. * @returns the SPS.
  25865. */
  25866. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25867. /**
  25868. * Disposes the SPS.
  25869. */
  25870. dispose(): void;
  25871. /**
  25872. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25873. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25874. * @returns the SPS.
  25875. */
  25876. refreshVisibleSize(): SolidParticleSystem;
  25877. /**
  25878. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25879. * @param size the size (float) of the visibility box
  25880. * note : this doesn't lock the SPS mesh bounding box.
  25881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25882. */
  25883. setVisibilityBox(size: number): void;
  25884. /**
  25885. * Gets whether the SPS as always visible or not
  25886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25887. */
  25888. /**
  25889. * Sets the SPS as always visible or not
  25890. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25891. */
  25892. isAlwaysVisible: boolean;
  25893. /**
  25894. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25896. */
  25897. /**
  25898. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25899. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25900. */
  25901. isVisibilityBoxLocked: boolean;
  25902. /**
  25903. * Tells to `setParticles()` to compute the particle rotations or not.
  25904. * Default value : true. The SPS is faster when it's set to false.
  25905. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25906. */
  25907. /**
  25908. * Gets if `setParticles()` computes the particle rotations or not.
  25909. * Default value : true. The SPS is faster when it's set to false.
  25910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25911. */
  25912. computeParticleRotation: boolean;
  25913. /**
  25914. * Tells to `setParticles()` to compute the particle colors or not.
  25915. * Default value : true. The SPS is faster when it's set to false.
  25916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25917. */
  25918. /**
  25919. * Gets if `setParticles()` computes the particle colors or not.
  25920. * Default value : true. The SPS is faster when it's set to false.
  25921. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25922. */
  25923. computeParticleColor: boolean;
  25924. /**
  25925. * Gets if `setParticles()` computes the particle textures or not.
  25926. * Default value : true. The SPS is faster when it's set to false.
  25927. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25928. */
  25929. computeParticleTexture: boolean;
  25930. /**
  25931. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25932. * Default value : false. The SPS is faster when it's set to false.
  25933. * Note : the particle custom vertex positions aren't stored values.
  25934. */
  25935. /**
  25936. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25937. * Default value : false. The SPS is faster when it's set to false.
  25938. * Note : the particle custom vertex positions aren't stored values.
  25939. */
  25940. computeParticleVertex: boolean;
  25941. /**
  25942. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25943. */
  25944. /**
  25945. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25946. */
  25947. computeBoundingBox: boolean;
  25948. /**
  25949. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25950. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25951. * Default : `true`
  25952. */
  25953. /**
  25954. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25956. * Default : `true`
  25957. */
  25958. depthSortParticles: boolean;
  25959. /**
  25960. * This function does nothing. It may be overwritten to set all the particle first values.
  25961. * The SPS doesn't call this function, you may have to call it by your own.
  25962. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25963. */
  25964. initParticles(): void;
  25965. /**
  25966. * This function does nothing. It may be overwritten to recycle a particle.
  25967. * The SPS doesn't call this function, you may have to call it by your own.
  25968. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25969. * @param particle The particle to recycle
  25970. * @returns the recycled particle
  25971. */
  25972. recycleParticle(particle: SolidParticle): SolidParticle;
  25973. /**
  25974. * Updates a particle : this function should be overwritten by the user.
  25975. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25976. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25977. * @example : just set a particle position or velocity and recycle conditions
  25978. * @param particle The particle to update
  25979. * @returns the updated particle
  25980. */
  25981. updateParticle(particle: SolidParticle): SolidParticle;
  25982. /**
  25983. * Updates a vertex of a particle : it can be overwritten by the user.
  25984. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25985. * @param particle the current particle
  25986. * @param vertex the current index of the current particle
  25987. * @param pt the index of the current vertex in the particle shape
  25988. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25989. * @example : just set a vertex particle position
  25990. * @returns the updated vertex
  25991. */
  25992. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25993. /**
  25994. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25995. * This does nothing and may be overwritten by the user.
  25996. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25997. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25998. * @param update the boolean update value actually passed to setParticles()
  25999. */
  26000. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26001. /**
  26002. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26003. * This will be passed three parameters.
  26004. * This does nothing and may be overwritten by the user.
  26005. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26006. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26007. * @param update the boolean update value actually passed to setParticles()
  26008. */
  26009. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26010. }
  26011. }
  26012. declare module "babylonjs/Particles/solidParticle" {
  26013. import { Nullable } from "babylonjs/types";
  26014. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26015. import { Color4 } from "babylonjs/Maths/math.color";
  26016. import { Mesh } from "babylonjs/Meshes/mesh";
  26017. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26018. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26019. import { Plane } from "babylonjs/Maths/math.plane";
  26020. /**
  26021. * Represents one particle of a solid particle system.
  26022. */
  26023. export class SolidParticle {
  26024. /**
  26025. * particle global index
  26026. */
  26027. idx: number;
  26028. /**
  26029. * The color of the particle
  26030. */
  26031. color: Nullable<Color4>;
  26032. /**
  26033. * The world space position of the particle.
  26034. */
  26035. position: Vector3;
  26036. /**
  26037. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26038. */
  26039. rotation: Vector3;
  26040. /**
  26041. * The world space rotation quaternion of the particle.
  26042. */
  26043. rotationQuaternion: Nullable<Quaternion>;
  26044. /**
  26045. * The scaling of the particle.
  26046. */
  26047. scaling: Vector3;
  26048. /**
  26049. * The uvs of the particle.
  26050. */
  26051. uvs: Vector4;
  26052. /**
  26053. * The current speed of the particle.
  26054. */
  26055. velocity: Vector3;
  26056. /**
  26057. * The pivot point in the particle local space.
  26058. */
  26059. pivot: Vector3;
  26060. /**
  26061. * Must the particle be translated from its pivot point in its local space ?
  26062. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26063. * Default : false
  26064. */
  26065. translateFromPivot: boolean;
  26066. /**
  26067. * Is the particle active or not ?
  26068. */
  26069. alive: boolean;
  26070. /**
  26071. * Is the particle visible or not ?
  26072. */
  26073. isVisible: boolean;
  26074. /**
  26075. * Index of this particle in the global "positions" array (Internal use)
  26076. * @hidden
  26077. */
  26078. _pos: number;
  26079. /**
  26080. * @hidden Index of this particle in the global "indices" array (Internal use)
  26081. */
  26082. _ind: number;
  26083. /**
  26084. * @hidden ModelShape of this particle (Internal use)
  26085. */
  26086. _model: ModelShape;
  26087. /**
  26088. * ModelShape id of this particle
  26089. */
  26090. shapeId: number;
  26091. /**
  26092. * Index of the particle in its shape id
  26093. */
  26094. idxInShape: number;
  26095. /**
  26096. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26097. */
  26098. _modelBoundingInfo: BoundingInfo;
  26099. /**
  26100. * @hidden Particle BoundingInfo object (Internal use)
  26101. */
  26102. _boundingInfo: BoundingInfo;
  26103. /**
  26104. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26105. */
  26106. _sps: SolidParticleSystem;
  26107. /**
  26108. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26109. */
  26110. _stillInvisible: boolean;
  26111. /**
  26112. * @hidden Last computed particle rotation matrix
  26113. */
  26114. _rotationMatrix: number[];
  26115. /**
  26116. * Parent particle Id, if any.
  26117. * Default null.
  26118. */
  26119. parentId: Nullable<number>;
  26120. /**
  26121. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26122. * The possible values are :
  26123. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26124. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26125. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26126. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26127. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26128. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26129. * */
  26130. cullingStrategy: number;
  26131. /**
  26132. * @hidden Internal global position in the SPS.
  26133. */
  26134. _globalPosition: Vector3;
  26135. /**
  26136. * Creates a Solid Particle object.
  26137. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26138. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26139. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26140. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26141. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26142. * @param shapeId (integer) is the model shape identifier in the SPS.
  26143. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26144. * @param sps defines the sps it is associated to
  26145. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26146. */
  26147. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26148. /**
  26149. * Legacy support, changed scale to scaling
  26150. */
  26151. /**
  26152. * Legacy support, changed scale to scaling
  26153. */
  26154. scale: Vector3;
  26155. /**
  26156. * Legacy support, changed quaternion to rotationQuaternion
  26157. */
  26158. /**
  26159. * Legacy support, changed quaternion to rotationQuaternion
  26160. */
  26161. quaternion: Nullable<Quaternion>;
  26162. /**
  26163. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26164. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26165. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26166. * @returns true if it intersects
  26167. */
  26168. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26169. /**
  26170. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26171. * A particle is in the frustum if its bounding box intersects the frustum
  26172. * @param frustumPlanes defines the frustum to test
  26173. * @returns true if the particle is in the frustum planes
  26174. */
  26175. isInFrustum(frustumPlanes: Plane[]): boolean;
  26176. /**
  26177. * get the rotation matrix of the particle
  26178. * @hidden
  26179. */
  26180. getRotationMatrix(m: Matrix): void;
  26181. }
  26182. /**
  26183. * Represents the shape of the model used by one particle of a solid particle system.
  26184. * SPS internal tool, don't use it manually.
  26185. */
  26186. export class ModelShape {
  26187. /**
  26188. * The shape id
  26189. * @hidden
  26190. */
  26191. shapeID: number;
  26192. /**
  26193. * flat array of model positions (internal use)
  26194. * @hidden
  26195. */
  26196. _shape: Vector3[];
  26197. /**
  26198. * flat array of model UVs (internal use)
  26199. * @hidden
  26200. */
  26201. _shapeUV: number[];
  26202. /**
  26203. * length of the shape in the model indices array (internal use)
  26204. * @hidden
  26205. */
  26206. _indicesLength: number;
  26207. /**
  26208. * Custom position function (internal use)
  26209. * @hidden
  26210. */
  26211. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26212. /**
  26213. * Custom vertex function (internal use)
  26214. * @hidden
  26215. */
  26216. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26217. /**
  26218. * 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.
  26219. * SPS internal tool, don't use it manually.
  26220. * @hidden
  26221. */
  26222. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26223. }
  26224. /**
  26225. * Represents a Depth Sorted Particle in the solid particle system.
  26226. */
  26227. export class DepthSortedParticle {
  26228. /**
  26229. * Index of the particle in the "indices" array
  26230. */
  26231. ind: number;
  26232. /**
  26233. * Length of the particle shape in the "indices" array
  26234. */
  26235. indicesLength: number;
  26236. /**
  26237. * Squared distance from the particle to the camera
  26238. */
  26239. sqDistance: number;
  26240. }
  26241. }
  26242. declare module "babylonjs/Collisions/meshCollisionData" {
  26243. import { Collider } from "babylonjs/Collisions/collider";
  26244. import { Vector3 } from "babylonjs/Maths/math.vector";
  26245. import { Nullable } from "babylonjs/types";
  26246. import { Observer } from "babylonjs/Misc/observable";
  26247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26248. /**
  26249. * @hidden
  26250. */
  26251. export class _MeshCollisionData {
  26252. _checkCollisions: boolean;
  26253. _collisionMask: number;
  26254. _collisionGroup: number;
  26255. _collider: Nullable<Collider>;
  26256. _oldPositionForCollisions: Vector3;
  26257. _diffPositionForCollisions: Vector3;
  26258. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26259. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26260. }
  26261. }
  26262. declare module "babylonjs/Meshes/abstractMesh" {
  26263. import { Observable } from "babylonjs/Misc/observable";
  26264. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26265. import { Camera } from "babylonjs/Cameras/camera";
  26266. import { Scene, IDisposable } from "babylonjs/scene";
  26267. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26268. import { Node } from "babylonjs/node";
  26269. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26270. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26272. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26273. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26274. import { Material } from "babylonjs/Materials/material";
  26275. import { Light } from "babylonjs/Lights/light";
  26276. import { Skeleton } from "babylonjs/Bones/skeleton";
  26277. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26278. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26279. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26280. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26281. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26282. import { Plane } from "babylonjs/Maths/math.plane";
  26283. import { Ray } from "babylonjs/Culling/ray";
  26284. import { Collider } from "babylonjs/Collisions/collider";
  26285. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26286. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26287. /** @hidden */
  26288. class _FacetDataStorage {
  26289. facetPositions: Vector3[];
  26290. facetNormals: Vector3[];
  26291. facetPartitioning: number[][];
  26292. facetNb: number;
  26293. partitioningSubdivisions: number;
  26294. partitioningBBoxRatio: number;
  26295. facetDataEnabled: boolean;
  26296. facetParameters: any;
  26297. bbSize: Vector3;
  26298. subDiv: {
  26299. max: number;
  26300. X: number;
  26301. Y: number;
  26302. Z: number;
  26303. };
  26304. facetDepthSort: boolean;
  26305. facetDepthSortEnabled: boolean;
  26306. depthSortedIndices: IndicesArray;
  26307. depthSortedFacets: {
  26308. ind: number;
  26309. sqDistance: number;
  26310. }[];
  26311. facetDepthSortFunction: (f1: {
  26312. ind: number;
  26313. sqDistance: number;
  26314. }, f2: {
  26315. ind: number;
  26316. sqDistance: number;
  26317. }) => number;
  26318. facetDepthSortFrom: Vector3;
  26319. facetDepthSortOrigin: Vector3;
  26320. invertedMatrix: Matrix;
  26321. }
  26322. /**
  26323. * @hidden
  26324. **/
  26325. class _InternalAbstractMeshDataInfo {
  26326. _hasVertexAlpha: boolean;
  26327. _useVertexColors: boolean;
  26328. _numBoneInfluencers: number;
  26329. _applyFog: boolean;
  26330. _receiveShadows: boolean;
  26331. _facetData: _FacetDataStorage;
  26332. _visibility: number;
  26333. _skeleton: Nullable<Skeleton>;
  26334. _layerMask: number;
  26335. _computeBonesUsingShaders: boolean;
  26336. _isActive: boolean;
  26337. _onlyForInstances: boolean;
  26338. _isActiveIntermediate: boolean;
  26339. _onlyForInstancesIntermediate: boolean;
  26340. }
  26341. /**
  26342. * Class used to store all common mesh properties
  26343. */
  26344. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26345. /** No occlusion */
  26346. static OCCLUSION_TYPE_NONE: number;
  26347. /** Occlusion set to optimisitic */
  26348. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26349. /** Occlusion set to strict */
  26350. static OCCLUSION_TYPE_STRICT: number;
  26351. /** Use an accurante occlusion algorithm */
  26352. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26353. /** Use a conservative occlusion algorithm */
  26354. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26355. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26356. * Test order :
  26357. * Is the bounding sphere outside the frustum ?
  26358. * If not, are the bounding box vertices outside the frustum ?
  26359. * It not, then the cullable object is in the frustum.
  26360. */
  26361. static readonly CULLINGSTRATEGY_STANDARD: number;
  26362. /** Culling strategy : Bounding Sphere Only.
  26363. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26364. * It's also less accurate than the standard because some not visible objects can still be selected.
  26365. * Test : is the bounding sphere outside the frustum ?
  26366. * If not, then the cullable object is in the frustum.
  26367. */
  26368. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26369. /** Culling strategy : Optimistic Inclusion.
  26370. * This in an inclusion test first, then the standard exclusion test.
  26371. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26372. * 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.
  26373. * Anyway, it's as accurate as the standard strategy.
  26374. * Test :
  26375. * Is the cullable object bounding sphere center in the frustum ?
  26376. * If not, apply the default culling strategy.
  26377. */
  26378. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26379. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26380. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26381. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26382. * 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.
  26383. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26384. * Test :
  26385. * Is the cullable object bounding sphere center in the frustum ?
  26386. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26387. */
  26388. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26389. /**
  26390. * No billboard
  26391. */
  26392. static readonly BILLBOARDMODE_NONE: number;
  26393. /** Billboard on X axis */
  26394. static readonly BILLBOARDMODE_X: number;
  26395. /** Billboard on Y axis */
  26396. static readonly BILLBOARDMODE_Y: number;
  26397. /** Billboard on Z axis */
  26398. static readonly BILLBOARDMODE_Z: number;
  26399. /** Billboard on all axes */
  26400. static readonly BILLBOARDMODE_ALL: number;
  26401. /** Billboard on using position instead of orientation */
  26402. static readonly BILLBOARDMODE_USE_POSITION: number;
  26403. /** @hidden */
  26404. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26405. /**
  26406. * The culling strategy to use to check whether the mesh must be rendered or not.
  26407. * This value can be changed at any time and will be used on the next render mesh selection.
  26408. * The possible values are :
  26409. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26410. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26411. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26412. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26413. * Please read each static variable documentation to get details about the culling process.
  26414. * */
  26415. cullingStrategy: number;
  26416. /**
  26417. * Gets the number of facets in the mesh
  26418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26419. */
  26420. readonly facetNb: number;
  26421. /**
  26422. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26424. */
  26425. partitioningSubdivisions: number;
  26426. /**
  26427. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26428. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26430. */
  26431. partitioningBBoxRatio: number;
  26432. /**
  26433. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26434. * Works only for updatable meshes.
  26435. * Doesn't work with multi-materials
  26436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26437. */
  26438. mustDepthSortFacets: boolean;
  26439. /**
  26440. * The location (Vector3) where the facet depth sort must be computed from.
  26441. * By default, the active camera position.
  26442. * Used only when facet depth sort is enabled
  26443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26444. */
  26445. facetDepthSortFrom: Vector3;
  26446. /**
  26447. * gets a boolean indicating if facetData is enabled
  26448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26449. */
  26450. readonly isFacetDataEnabled: boolean;
  26451. /** @hidden */
  26452. _updateNonUniformScalingState(value: boolean): boolean;
  26453. /**
  26454. * An event triggered when this mesh collides with another one
  26455. */
  26456. onCollideObservable: Observable<AbstractMesh>;
  26457. /** Set a function to call when this mesh collides with another one */
  26458. onCollide: () => void;
  26459. /**
  26460. * An event triggered when the collision's position changes
  26461. */
  26462. onCollisionPositionChangeObservable: Observable<Vector3>;
  26463. /** Set a function to call when the collision's position changes */
  26464. onCollisionPositionChange: () => void;
  26465. /**
  26466. * An event triggered when material is changed
  26467. */
  26468. onMaterialChangedObservable: Observable<AbstractMesh>;
  26469. /**
  26470. * Gets or sets the orientation for POV movement & rotation
  26471. */
  26472. definedFacingForward: boolean;
  26473. /** @hidden */
  26474. _occlusionQuery: Nullable<WebGLQuery>;
  26475. /** @hidden */
  26476. _renderingGroup: Nullable<RenderingGroup>;
  26477. /**
  26478. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26479. */
  26480. /**
  26481. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26482. */
  26483. visibility: number;
  26484. /** Gets or sets the alpha index used to sort transparent meshes
  26485. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26486. */
  26487. alphaIndex: number;
  26488. /**
  26489. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26490. */
  26491. isVisible: boolean;
  26492. /**
  26493. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26494. */
  26495. isPickable: boolean;
  26496. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26497. showSubMeshesBoundingBox: boolean;
  26498. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26499. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26500. */
  26501. isBlocker: boolean;
  26502. /**
  26503. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26504. */
  26505. enablePointerMoveEvents: boolean;
  26506. /**
  26507. * Specifies the rendering group id for this mesh (0 by default)
  26508. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26509. */
  26510. renderingGroupId: number;
  26511. private _material;
  26512. /** Gets or sets current material */
  26513. material: Nullable<Material>;
  26514. /**
  26515. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26516. * @see http://doc.babylonjs.com/babylon101/shadows
  26517. */
  26518. receiveShadows: boolean;
  26519. /** Defines color to use when rendering outline */
  26520. outlineColor: Color3;
  26521. /** Define width to use when rendering outline */
  26522. outlineWidth: number;
  26523. /** Defines color to use when rendering overlay */
  26524. overlayColor: Color3;
  26525. /** Defines alpha to use when rendering overlay */
  26526. overlayAlpha: number;
  26527. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26528. hasVertexAlpha: boolean;
  26529. /** 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) */
  26530. useVertexColors: boolean;
  26531. /**
  26532. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26533. */
  26534. computeBonesUsingShaders: boolean;
  26535. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26536. numBoneInfluencers: number;
  26537. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26538. applyFog: boolean;
  26539. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26540. useOctreeForRenderingSelection: boolean;
  26541. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26542. useOctreeForPicking: boolean;
  26543. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26544. useOctreeForCollisions: boolean;
  26545. /**
  26546. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26547. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26548. */
  26549. layerMask: number;
  26550. /**
  26551. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26552. */
  26553. alwaysSelectAsActiveMesh: boolean;
  26554. /**
  26555. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26556. */
  26557. doNotSyncBoundingInfo: boolean;
  26558. /**
  26559. * Gets or sets the current action manager
  26560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26561. */
  26562. actionManager: Nullable<AbstractActionManager>;
  26563. private _meshCollisionData;
  26564. /**
  26565. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26567. */
  26568. ellipsoid: Vector3;
  26569. /**
  26570. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26572. */
  26573. ellipsoidOffset: Vector3;
  26574. /**
  26575. * Gets or sets a collision mask used to mask collisions (default is -1).
  26576. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26577. */
  26578. collisionMask: number;
  26579. /**
  26580. * Gets or sets the current collision group mask (-1 by default).
  26581. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26582. */
  26583. collisionGroup: number;
  26584. /**
  26585. * Defines edge width used when edgesRenderer is enabled
  26586. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26587. */
  26588. edgesWidth: number;
  26589. /**
  26590. * Defines edge color used when edgesRenderer is enabled
  26591. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26592. */
  26593. edgesColor: Color4;
  26594. /** @hidden */
  26595. _edgesRenderer: Nullable<IEdgesRenderer>;
  26596. /** @hidden */
  26597. _masterMesh: Nullable<AbstractMesh>;
  26598. /** @hidden */
  26599. _boundingInfo: Nullable<BoundingInfo>;
  26600. /** @hidden */
  26601. _renderId: number;
  26602. /**
  26603. * Gets or sets the list of subMeshes
  26604. * @see http://doc.babylonjs.com/how_to/multi_materials
  26605. */
  26606. subMeshes: SubMesh[];
  26607. /** @hidden */
  26608. _intersectionsInProgress: AbstractMesh[];
  26609. /** @hidden */
  26610. _unIndexed: boolean;
  26611. /** @hidden */
  26612. _lightSources: Light[];
  26613. /** Gets the list of lights affecting that mesh */
  26614. readonly lightSources: Light[];
  26615. /** @hidden */
  26616. readonly _positions: Nullable<Vector3[]>;
  26617. /** @hidden */
  26618. _waitingData: {
  26619. lods: Nullable<any>;
  26620. actions: Nullable<any>;
  26621. freezeWorldMatrix: Nullable<boolean>;
  26622. };
  26623. /** @hidden */
  26624. _bonesTransformMatrices: Nullable<Float32Array>;
  26625. /** @hidden */
  26626. _transformMatrixTexture: Nullable<RawTexture>;
  26627. /**
  26628. * Gets or sets a skeleton to apply skining transformations
  26629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26630. */
  26631. skeleton: Nullable<Skeleton>;
  26632. /**
  26633. * An event triggered when the mesh is rebuilt.
  26634. */
  26635. onRebuildObservable: Observable<AbstractMesh>;
  26636. /**
  26637. * Creates a new AbstractMesh
  26638. * @param name defines the name of the mesh
  26639. * @param scene defines the hosting scene
  26640. */
  26641. constructor(name: string, scene?: Nullable<Scene>);
  26642. /**
  26643. * Returns the string "AbstractMesh"
  26644. * @returns "AbstractMesh"
  26645. */
  26646. getClassName(): string;
  26647. /**
  26648. * Gets a string representation of the current mesh
  26649. * @param fullDetails defines a boolean indicating if full details must be included
  26650. * @returns a string representation of the current mesh
  26651. */
  26652. toString(fullDetails?: boolean): string;
  26653. /**
  26654. * @hidden
  26655. */
  26656. protected _getEffectiveParent(): Nullable<Node>;
  26657. /** @hidden */
  26658. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26659. /** @hidden */
  26660. _rebuild(): void;
  26661. /** @hidden */
  26662. _resyncLightSources(): void;
  26663. /** @hidden */
  26664. _resyncLighSource(light: Light): void;
  26665. /** @hidden */
  26666. _unBindEffect(): void;
  26667. /** @hidden */
  26668. _removeLightSource(light: Light, dispose: boolean): void;
  26669. private _markSubMeshesAsDirty;
  26670. /** @hidden */
  26671. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26672. /** @hidden */
  26673. _markSubMeshesAsAttributesDirty(): void;
  26674. /** @hidden */
  26675. _markSubMeshesAsMiscDirty(): void;
  26676. /**
  26677. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26678. */
  26679. scaling: Vector3;
  26680. /**
  26681. * Returns true if the mesh is blocked. Implemented by child classes
  26682. */
  26683. readonly isBlocked: boolean;
  26684. /**
  26685. * Returns the mesh itself by default. Implemented by child classes
  26686. * @param camera defines the camera to use to pick the right LOD level
  26687. * @returns the currentAbstractMesh
  26688. */
  26689. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26690. /**
  26691. * Returns 0 by default. Implemented by child classes
  26692. * @returns an integer
  26693. */
  26694. getTotalVertices(): number;
  26695. /**
  26696. * Returns a positive integer : the total number of indices in this mesh geometry.
  26697. * @returns the numner of indices or zero if the mesh has no geometry.
  26698. */
  26699. getTotalIndices(): number;
  26700. /**
  26701. * Returns null by default. Implemented by child classes
  26702. * @returns null
  26703. */
  26704. getIndices(): Nullable<IndicesArray>;
  26705. /**
  26706. * Returns the array of the requested vertex data kind. Implemented by child classes
  26707. * @param kind defines the vertex data kind to use
  26708. * @returns null
  26709. */
  26710. getVerticesData(kind: string): Nullable<FloatArray>;
  26711. /**
  26712. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26713. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26714. * Note that a new underlying VertexBuffer object is created each call.
  26715. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26716. * @param kind defines vertex data kind:
  26717. * * VertexBuffer.PositionKind
  26718. * * VertexBuffer.UVKind
  26719. * * VertexBuffer.UV2Kind
  26720. * * VertexBuffer.UV3Kind
  26721. * * VertexBuffer.UV4Kind
  26722. * * VertexBuffer.UV5Kind
  26723. * * VertexBuffer.UV6Kind
  26724. * * VertexBuffer.ColorKind
  26725. * * VertexBuffer.MatricesIndicesKind
  26726. * * VertexBuffer.MatricesIndicesExtraKind
  26727. * * VertexBuffer.MatricesWeightsKind
  26728. * * VertexBuffer.MatricesWeightsExtraKind
  26729. * @param data defines the data source
  26730. * @param updatable defines if the data must be flagged as updatable (or static)
  26731. * @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
  26732. * @returns the current mesh
  26733. */
  26734. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26735. /**
  26736. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26737. * If the mesh has no geometry, it is simply returned as it is.
  26738. * @param kind defines vertex data kind:
  26739. * * VertexBuffer.PositionKind
  26740. * * VertexBuffer.UVKind
  26741. * * VertexBuffer.UV2Kind
  26742. * * VertexBuffer.UV3Kind
  26743. * * VertexBuffer.UV4Kind
  26744. * * VertexBuffer.UV5Kind
  26745. * * VertexBuffer.UV6Kind
  26746. * * VertexBuffer.ColorKind
  26747. * * VertexBuffer.MatricesIndicesKind
  26748. * * VertexBuffer.MatricesIndicesExtraKind
  26749. * * VertexBuffer.MatricesWeightsKind
  26750. * * VertexBuffer.MatricesWeightsExtraKind
  26751. * @param data defines the data source
  26752. * @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
  26753. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26754. * @returns the current mesh
  26755. */
  26756. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26757. /**
  26758. * Sets the mesh indices,
  26759. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26760. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26761. * @param totalVertices Defines the total number of vertices
  26762. * @returns the current mesh
  26763. */
  26764. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26765. /**
  26766. * Gets a boolean indicating if specific vertex data is present
  26767. * @param kind defines the vertex data kind to use
  26768. * @returns true is data kind is present
  26769. */
  26770. isVerticesDataPresent(kind: string): boolean;
  26771. /**
  26772. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26773. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26774. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26775. * @returns a BoundingInfo
  26776. */
  26777. getBoundingInfo(): BoundingInfo;
  26778. /**
  26779. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26780. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26781. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26782. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26783. * @returns the current mesh
  26784. */
  26785. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26786. /**
  26787. * Overwrite the current bounding info
  26788. * @param boundingInfo defines the new bounding info
  26789. * @returns the current mesh
  26790. */
  26791. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26792. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26793. readonly useBones: boolean;
  26794. /** @hidden */
  26795. _preActivate(): void;
  26796. /** @hidden */
  26797. _preActivateForIntermediateRendering(renderId: number): void;
  26798. /** @hidden */
  26799. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26800. /** @hidden */
  26801. _postActivate(): void;
  26802. /** @hidden */
  26803. _freeze(): void;
  26804. /** @hidden */
  26805. _unFreeze(): void;
  26806. /**
  26807. * Gets the current world matrix
  26808. * @returns a Matrix
  26809. */
  26810. getWorldMatrix(): Matrix;
  26811. /** @hidden */
  26812. _getWorldMatrixDeterminant(): number;
  26813. /**
  26814. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26815. */
  26816. readonly isAnInstance: boolean;
  26817. /**
  26818. * Gets a boolean indicating if this mesh has instances
  26819. */
  26820. readonly hasInstances: boolean;
  26821. /**
  26822. * Perform relative position change from the point of view of behind the front of the mesh.
  26823. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26824. * Supports definition of mesh facing forward or backward
  26825. * @param amountRight defines the distance on the right axis
  26826. * @param amountUp defines the distance on the up axis
  26827. * @param amountForward defines the distance on the forward axis
  26828. * @returns the current mesh
  26829. */
  26830. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26831. /**
  26832. * Calculate relative position change from the point of view of behind the front of the mesh.
  26833. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26834. * Supports definition of mesh facing forward or backward
  26835. * @param amountRight defines the distance on the right axis
  26836. * @param amountUp defines the distance on the up axis
  26837. * @param amountForward defines the distance on the forward axis
  26838. * @returns the new displacement vector
  26839. */
  26840. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26841. /**
  26842. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26843. * Supports definition of mesh facing forward or backward
  26844. * @param flipBack defines the flip
  26845. * @param twirlClockwise defines the twirl
  26846. * @param tiltRight defines the tilt
  26847. * @returns the current mesh
  26848. */
  26849. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26850. /**
  26851. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26852. * Supports definition of mesh facing forward or backward.
  26853. * @param flipBack defines the flip
  26854. * @param twirlClockwise defines the twirl
  26855. * @param tiltRight defines the tilt
  26856. * @returns the new rotation vector
  26857. */
  26858. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26859. /**
  26860. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26861. * This means the mesh underlying bounding box and sphere are recomputed.
  26862. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26863. * @returns the current mesh
  26864. */
  26865. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26866. /** @hidden */
  26867. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26868. /** @hidden */
  26869. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26870. /** @hidden */
  26871. _updateBoundingInfo(): AbstractMesh;
  26872. /** @hidden */
  26873. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26874. /** @hidden */
  26875. protected _afterComputeWorldMatrix(): void;
  26876. /** @hidden */
  26877. readonly _effectiveMesh: AbstractMesh;
  26878. /**
  26879. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26880. * A mesh is in the frustum if its bounding box intersects the frustum
  26881. * @param frustumPlanes defines the frustum to test
  26882. * @returns true if the mesh is in the frustum planes
  26883. */
  26884. isInFrustum(frustumPlanes: Plane[]): boolean;
  26885. /**
  26886. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26887. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26888. * @param frustumPlanes defines the frustum to test
  26889. * @returns true if the mesh is completely in the frustum planes
  26890. */
  26891. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26892. /**
  26893. * True if the mesh intersects another mesh or a SolidParticle object
  26894. * @param mesh defines a target mesh or SolidParticle to test
  26895. * @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)
  26896. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26897. * @returns true if there is an intersection
  26898. */
  26899. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26900. /**
  26901. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26902. * @param point defines the point to test
  26903. * @returns true if there is an intersection
  26904. */
  26905. intersectsPoint(point: Vector3): boolean;
  26906. /**
  26907. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26909. */
  26910. checkCollisions: boolean;
  26911. /**
  26912. * Gets Collider object used to compute collisions (not physics)
  26913. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26914. */
  26915. readonly collider: Nullable<Collider>;
  26916. /**
  26917. * Move the mesh using collision engine
  26918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26919. * @param displacement defines the requested displacement vector
  26920. * @returns the current mesh
  26921. */
  26922. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26923. private _onCollisionPositionChange;
  26924. /** @hidden */
  26925. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26926. /** @hidden */
  26927. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26928. /** @hidden */
  26929. _checkCollision(collider: Collider): AbstractMesh;
  26930. /** @hidden */
  26931. _generatePointsArray(): boolean;
  26932. /**
  26933. * Checks if the passed Ray intersects with the mesh
  26934. * @param ray defines the ray to use
  26935. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26936. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26937. * @returns the picking info
  26938. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26939. */
  26940. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26941. /**
  26942. * Clones the current mesh
  26943. * @param name defines the mesh name
  26944. * @param newParent defines the new mesh parent
  26945. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26946. * @returns the new mesh
  26947. */
  26948. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26949. /**
  26950. * Disposes all the submeshes of the current meshnp
  26951. * @returns the current mesh
  26952. */
  26953. releaseSubMeshes(): AbstractMesh;
  26954. /**
  26955. * Releases resources associated with this abstract mesh.
  26956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26958. */
  26959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26960. /**
  26961. * Adds the passed mesh as a child to the current mesh
  26962. * @param mesh defines the child mesh
  26963. * @returns the current mesh
  26964. */
  26965. addChild(mesh: AbstractMesh): AbstractMesh;
  26966. /**
  26967. * Removes the passed mesh from the current mesh children list
  26968. * @param mesh defines the child mesh
  26969. * @returns the current mesh
  26970. */
  26971. removeChild(mesh: AbstractMesh): AbstractMesh;
  26972. /** @hidden */
  26973. private _initFacetData;
  26974. /**
  26975. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26976. * This method can be called within the render loop.
  26977. * 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
  26978. * @returns the current mesh
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26980. */
  26981. updateFacetData(): AbstractMesh;
  26982. /**
  26983. * Returns the facetLocalNormals array.
  26984. * The normals are expressed in the mesh local spac
  26985. * @returns an array of Vector3
  26986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26987. */
  26988. getFacetLocalNormals(): Vector3[];
  26989. /**
  26990. * Returns the facetLocalPositions array.
  26991. * The facet positions are expressed in the mesh local space
  26992. * @returns an array of Vector3
  26993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26994. */
  26995. getFacetLocalPositions(): Vector3[];
  26996. /**
  26997. * Returns the facetLocalPartioning array
  26998. * @returns an array of array of numbers
  26999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27000. */
  27001. getFacetLocalPartitioning(): number[][];
  27002. /**
  27003. * Returns the i-th facet position in the world system.
  27004. * This method allocates a new Vector3 per call
  27005. * @param i defines the facet index
  27006. * @returns a new Vector3
  27007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27008. */
  27009. getFacetPosition(i: number): Vector3;
  27010. /**
  27011. * Sets the reference Vector3 with the i-th facet position in the world system
  27012. * @param i defines the facet index
  27013. * @param ref defines the target vector
  27014. * @returns the current mesh
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27016. */
  27017. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27018. /**
  27019. * Returns the i-th facet normal in the world system.
  27020. * This method allocates a new Vector3 per call
  27021. * @param i defines the facet index
  27022. * @returns a new Vector3
  27023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27024. */
  27025. getFacetNormal(i: number): Vector3;
  27026. /**
  27027. * Sets the reference Vector3 with the i-th facet normal in the world system
  27028. * @param i defines the facet index
  27029. * @param ref defines the target vector
  27030. * @returns the current mesh
  27031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27032. */
  27033. getFacetNormalToRef(i: number, ref: Vector3): this;
  27034. /**
  27035. * 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)
  27036. * @param x defines x coordinate
  27037. * @param y defines y coordinate
  27038. * @param z defines z coordinate
  27039. * @returns the array of facet indexes
  27040. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27041. */
  27042. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27043. /**
  27044. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27045. * @param projected sets as the (x,y,z) world projection on the facet
  27046. * @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
  27047. * @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
  27048. * @param x defines x coordinate
  27049. * @param y defines y coordinate
  27050. * @param z defines z coordinate
  27051. * @returns the face index if found (or null instead)
  27052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27053. */
  27054. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27055. /**
  27056. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27057. * @param projected sets as the (x,y,z) local projection on the facet
  27058. * @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
  27059. * @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
  27060. * @param x defines x coordinate
  27061. * @param y defines y coordinate
  27062. * @param z defines z coordinate
  27063. * @returns the face index if found (or null instead)
  27064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27065. */
  27066. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27067. /**
  27068. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27069. * @returns the parameters
  27070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27071. */
  27072. getFacetDataParameters(): any;
  27073. /**
  27074. * Disables the feature FacetData and frees the related memory
  27075. * @returns the current mesh
  27076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27077. */
  27078. disableFacetData(): AbstractMesh;
  27079. /**
  27080. * Updates the AbstractMesh indices array
  27081. * @param indices defines the data source
  27082. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27083. * @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)
  27084. * @returns the current mesh
  27085. */
  27086. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27087. /**
  27088. * Creates new normals data for the mesh
  27089. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27090. * @returns the current mesh
  27091. */
  27092. createNormals(updatable: boolean): AbstractMesh;
  27093. /**
  27094. * Align the mesh with a normal
  27095. * @param normal defines the normal to use
  27096. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27097. * @returns the current mesh
  27098. */
  27099. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27100. /** @hidden */
  27101. _checkOcclusionQuery(): boolean;
  27102. /**
  27103. * Disables the mesh edge rendering mode
  27104. * @returns the currentAbstractMesh
  27105. */
  27106. disableEdgesRendering(): AbstractMesh;
  27107. /**
  27108. * Enables the edge rendering mode on the mesh.
  27109. * This mode makes the mesh edges visible
  27110. * @param epsilon defines the maximal distance between two angles to detect a face
  27111. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27112. * @returns the currentAbstractMesh
  27113. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27114. */
  27115. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27116. }
  27117. }
  27118. declare module "babylonjs/Actions/actionEvent" {
  27119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27120. import { Nullable } from "babylonjs/types";
  27121. import { Sprite } from "babylonjs/Sprites/sprite";
  27122. import { Scene } from "babylonjs/scene";
  27123. import { Vector2 } from "babylonjs/Maths/math.vector";
  27124. /**
  27125. * Interface used to define ActionEvent
  27126. */
  27127. export interface IActionEvent {
  27128. /** The mesh or sprite that triggered the action */
  27129. source: any;
  27130. /** The X mouse cursor position at the time of the event */
  27131. pointerX: number;
  27132. /** The Y mouse cursor position at the time of the event */
  27133. pointerY: number;
  27134. /** The mesh that is currently pointed at (can be null) */
  27135. meshUnderPointer: Nullable<AbstractMesh>;
  27136. /** the original (browser) event that triggered the ActionEvent */
  27137. sourceEvent?: any;
  27138. /** additional data for the event */
  27139. additionalData?: any;
  27140. }
  27141. /**
  27142. * ActionEvent is the event being sent when an action is triggered.
  27143. */
  27144. export class ActionEvent implements IActionEvent {
  27145. /** The mesh or sprite that triggered the action */
  27146. source: any;
  27147. /** The X mouse cursor position at the time of the event */
  27148. pointerX: number;
  27149. /** The Y mouse cursor position at the time of the event */
  27150. pointerY: number;
  27151. /** The mesh that is currently pointed at (can be null) */
  27152. meshUnderPointer: Nullable<AbstractMesh>;
  27153. /** the original (browser) event that triggered the ActionEvent */
  27154. sourceEvent?: any;
  27155. /** additional data for the event */
  27156. additionalData?: any;
  27157. /**
  27158. * Creates a new ActionEvent
  27159. * @param source The mesh or sprite that triggered the action
  27160. * @param pointerX The X mouse cursor position at the time of the event
  27161. * @param pointerY The Y mouse cursor position at the time of the event
  27162. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27163. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27164. * @param additionalData additional data for the event
  27165. */
  27166. constructor(
  27167. /** The mesh or sprite that triggered the action */
  27168. source: any,
  27169. /** The X mouse cursor position at the time of the event */
  27170. pointerX: number,
  27171. /** The Y mouse cursor position at the time of the event */
  27172. pointerY: number,
  27173. /** The mesh that is currently pointed at (can be null) */
  27174. meshUnderPointer: Nullable<AbstractMesh>,
  27175. /** the original (browser) event that triggered the ActionEvent */
  27176. sourceEvent?: any,
  27177. /** additional data for the event */
  27178. additionalData?: any);
  27179. /**
  27180. * Helper function to auto-create an ActionEvent from a source mesh.
  27181. * @param source The source mesh that triggered the event
  27182. * @param evt The original (browser) event
  27183. * @param additionalData additional data for the event
  27184. * @returns the new ActionEvent
  27185. */
  27186. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27187. /**
  27188. * Helper function to auto-create an ActionEvent from a source sprite
  27189. * @param source The source sprite that triggered the event
  27190. * @param scene Scene associated with the sprite
  27191. * @param evt The original (browser) event
  27192. * @param additionalData additional data for the event
  27193. * @returns the new ActionEvent
  27194. */
  27195. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27196. /**
  27197. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27198. * @param scene the scene where the event occurred
  27199. * @param evt The original (browser) event
  27200. * @returns the new ActionEvent
  27201. */
  27202. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27203. /**
  27204. * Helper function to auto-create an ActionEvent from a primitive
  27205. * @param prim defines the target primitive
  27206. * @param pointerPos defines the pointer position
  27207. * @param evt The original (browser) event
  27208. * @param additionalData additional data for the event
  27209. * @returns the new ActionEvent
  27210. */
  27211. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27212. }
  27213. }
  27214. declare module "babylonjs/Actions/abstractActionManager" {
  27215. import { IDisposable } from "babylonjs/scene";
  27216. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27217. import { IAction } from "babylonjs/Actions/action";
  27218. import { Nullable } from "babylonjs/types";
  27219. /**
  27220. * Abstract class used to decouple action Manager from scene and meshes.
  27221. * Do not instantiate.
  27222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27223. */
  27224. export abstract class AbstractActionManager implements IDisposable {
  27225. /** Gets the list of active triggers */
  27226. static Triggers: {
  27227. [key: string]: number;
  27228. };
  27229. /** Gets the cursor to use when hovering items */
  27230. hoverCursor: string;
  27231. /** Gets the list of actions */
  27232. actions: IAction[];
  27233. /**
  27234. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27235. */
  27236. isRecursive: boolean;
  27237. /**
  27238. * Releases all associated resources
  27239. */
  27240. abstract dispose(): void;
  27241. /**
  27242. * Does this action manager has pointer triggers
  27243. */
  27244. abstract readonly hasPointerTriggers: boolean;
  27245. /**
  27246. * Does this action manager has pick triggers
  27247. */
  27248. abstract readonly hasPickTriggers: boolean;
  27249. /**
  27250. * Process a specific trigger
  27251. * @param trigger defines the trigger to process
  27252. * @param evt defines the event details to be processed
  27253. */
  27254. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27255. /**
  27256. * Does this action manager handles actions of any of the given triggers
  27257. * @param triggers defines the triggers to be tested
  27258. * @return a boolean indicating whether one (or more) of the triggers is handled
  27259. */
  27260. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27261. /**
  27262. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27263. * speed.
  27264. * @param triggerA defines the trigger to be tested
  27265. * @param triggerB defines the trigger to be tested
  27266. * @return a boolean indicating whether one (or more) of the triggers is handled
  27267. */
  27268. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27269. /**
  27270. * Does this action manager handles actions of a given trigger
  27271. * @param trigger defines the trigger to be tested
  27272. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27273. * @return whether the trigger is handled
  27274. */
  27275. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27276. /**
  27277. * Serialize this manager to a JSON object
  27278. * @param name defines the property name to store this manager
  27279. * @returns a JSON representation of this manager
  27280. */
  27281. abstract serialize(name: string): any;
  27282. /**
  27283. * Registers an action to this action manager
  27284. * @param action defines the action to be registered
  27285. * @return the action amended (prepared) after registration
  27286. */
  27287. abstract registerAction(action: IAction): Nullable<IAction>;
  27288. /**
  27289. * Unregisters an action to this action manager
  27290. * @param action defines the action to be unregistered
  27291. * @return a boolean indicating whether the action has been unregistered
  27292. */
  27293. abstract unregisterAction(action: IAction): Boolean;
  27294. /**
  27295. * Does exist one action manager with at least one trigger
  27296. **/
  27297. static readonly HasTriggers: boolean;
  27298. /**
  27299. * Does exist one action manager with at least one pick trigger
  27300. **/
  27301. static readonly HasPickTriggers: boolean;
  27302. /**
  27303. * Does exist one action manager that handles actions of a given trigger
  27304. * @param trigger defines the trigger to be tested
  27305. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27306. **/
  27307. static HasSpecificTrigger(trigger: number): boolean;
  27308. }
  27309. }
  27310. declare module "babylonjs/node" {
  27311. import { Scene } from "babylonjs/scene";
  27312. import { Nullable } from "babylonjs/types";
  27313. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27314. import { Engine } from "babylonjs/Engines/engine";
  27315. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27316. import { Observable } from "babylonjs/Misc/observable";
  27317. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27318. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27319. import { Animatable } from "babylonjs/Animations/animatable";
  27320. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27321. import { Animation } from "babylonjs/Animations/animation";
  27322. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27324. /**
  27325. * Defines how a node can be built from a string name.
  27326. */
  27327. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27328. /**
  27329. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27330. */
  27331. export class Node implements IBehaviorAware<Node> {
  27332. /** @hidden */
  27333. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27334. private static _NodeConstructors;
  27335. /**
  27336. * Add a new node constructor
  27337. * @param type defines the type name of the node to construct
  27338. * @param constructorFunc defines the constructor function
  27339. */
  27340. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27341. /**
  27342. * Returns a node constructor based on type name
  27343. * @param type defines the type name
  27344. * @param name defines the new node name
  27345. * @param scene defines the hosting scene
  27346. * @param options defines optional options to transmit to constructors
  27347. * @returns the new constructor or null
  27348. */
  27349. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27350. /**
  27351. * Gets or sets the name of the node
  27352. */
  27353. name: string;
  27354. /**
  27355. * Gets or sets the id of the node
  27356. */
  27357. id: string;
  27358. /**
  27359. * Gets or sets the unique id of the node
  27360. */
  27361. uniqueId: number;
  27362. /**
  27363. * Gets or sets a string used to store user defined state for the node
  27364. */
  27365. state: string;
  27366. /**
  27367. * Gets or sets an object used to store user defined information for the node
  27368. */
  27369. metadata: any;
  27370. /**
  27371. * For internal use only. Please do not use.
  27372. */
  27373. reservedDataStore: any;
  27374. /**
  27375. * List of inspectable custom properties (used by the Inspector)
  27376. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27377. */
  27378. inspectableCustomProperties: IInspectable[];
  27379. /**
  27380. * Gets or sets a boolean used to define if the node must be serialized
  27381. */
  27382. doNotSerialize: boolean;
  27383. /** @hidden */
  27384. _isDisposed: boolean;
  27385. /**
  27386. * Gets a list of Animations associated with the node
  27387. */
  27388. animations: import("babylonjs/Animations/animation").Animation[];
  27389. protected _ranges: {
  27390. [name: string]: Nullable<AnimationRange>;
  27391. };
  27392. /**
  27393. * Callback raised when the node is ready to be used
  27394. */
  27395. onReady: Nullable<(node: Node) => void>;
  27396. private _isEnabled;
  27397. private _isParentEnabled;
  27398. private _isReady;
  27399. /** @hidden */
  27400. _currentRenderId: number;
  27401. private _parentUpdateId;
  27402. /** @hidden */
  27403. _childUpdateId: number;
  27404. /** @hidden */
  27405. _waitingParentId: Nullable<string>;
  27406. /** @hidden */
  27407. _scene: Scene;
  27408. /** @hidden */
  27409. _cache: any;
  27410. private _parentNode;
  27411. private _children;
  27412. /** @hidden */
  27413. _worldMatrix: Matrix;
  27414. /** @hidden */
  27415. _worldMatrixDeterminant: number;
  27416. /** @hidden */
  27417. _worldMatrixDeterminantIsDirty: boolean;
  27418. /** @hidden */
  27419. private _sceneRootNodesIndex;
  27420. /**
  27421. * Gets a boolean indicating if the node has been disposed
  27422. * @returns true if the node was disposed
  27423. */
  27424. isDisposed(): boolean;
  27425. /**
  27426. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27427. * @see https://doc.babylonjs.com/how_to/parenting
  27428. */
  27429. parent: Nullable<Node>;
  27430. private addToSceneRootNodes;
  27431. private removeFromSceneRootNodes;
  27432. private _animationPropertiesOverride;
  27433. /**
  27434. * Gets or sets the animation properties override
  27435. */
  27436. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27437. /**
  27438. * Gets a string idenfifying the name of the class
  27439. * @returns "Node" string
  27440. */
  27441. getClassName(): string;
  27442. /** @hidden */
  27443. readonly _isNode: boolean;
  27444. /**
  27445. * An event triggered when the mesh is disposed
  27446. */
  27447. onDisposeObservable: Observable<Node>;
  27448. private _onDisposeObserver;
  27449. /**
  27450. * Sets a callback that will be raised when the node will be disposed
  27451. */
  27452. onDispose: () => void;
  27453. /**
  27454. * Creates a new Node
  27455. * @param name the name and id to be given to this node
  27456. * @param scene the scene this node will be added to
  27457. * @param addToRootNodes the node will be added to scene.rootNodes
  27458. */
  27459. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27460. /**
  27461. * Gets the scene of the node
  27462. * @returns a scene
  27463. */
  27464. getScene(): Scene;
  27465. /**
  27466. * Gets the engine of the node
  27467. * @returns a Engine
  27468. */
  27469. getEngine(): Engine;
  27470. private _behaviors;
  27471. /**
  27472. * Attach a behavior to the node
  27473. * @see http://doc.babylonjs.com/features/behaviour
  27474. * @param behavior defines the behavior to attach
  27475. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27476. * @returns the current Node
  27477. */
  27478. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27479. /**
  27480. * Remove an attached behavior
  27481. * @see http://doc.babylonjs.com/features/behaviour
  27482. * @param behavior defines the behavior to attach
  27483. * @returns the current Node
  27484. */
  27485. removeBehavior(behavior: Behavior<Node>): Node;
  27486. /**
  27487. * Gets the list of attached behaviors
  27488. * @see http://doc.babylonjs.com/features/behaviour
  27489. */
  27490. readonly behaviors: Behavior<Node>[];
  27491. /**
  27492. * Gets an attached behavior by name
  27493. * @param name defines the name of the behavior to look for
  27494. * @see http://doc.babylonjs.com/features/behaviour
  27495. * @returns null if behavior was not found else the requested behavior
  27496. */
  27497. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27498. /**
  27499. * Returns the latest update of the World matrix
  27500. * @returns a Matrix
  27501. */
  27502. getWorldMatrix(): Matrix;
  27503. /** @hidden */
  27504. _getWorldMatrixDeterminant(): number;
  27505. /**
  27506. * Returns directly the latest state of the mesh World matrix.
  27507. * A Matrix is returned.
  27508. */
  27509. readonly worldMatrixFromCache: Matrix;
  27510. /** @hidden */
  27511. _initCache(): void;
  27512. /** @hidden */
  27513. updateCache(force?: boolean): void;
  27514. /** @hidden */
  27515. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27516. /** @hidden */
  27517. _updateCache(ignoreParentClass?: boolean): void;
  27518. /** @hidden */
  27519. _isSynchronized(): boolean;
  27520. /** @hidden */
  27521. _markSyncedWithParent(): void;
  27522. /** @hidden */
  27523. isSynchronizedWithParent(): boolean;
  27524. /** @hidden */
  27525. isSynchronized(): boolean;
  27526. /**
  27527. * Is this node ready to be used/rendered
  27528. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27529. * @return true if the node is ready
  27530. */
  27531. isReady(completeCheck?: boolean): boolean;
  27532. /**
  27533. * Is this node enabled?
  27534. * 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
  27535. * @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
  27536. * @return whether this node (and its parent) is enabled
  27537. */
  27538. isEnabled(checkAncestors?: boolean): boolean;
  27539. /** @hidden */
  27540. protected _syncParentEnabledState(): void;
  27541. /**
  27542. * Set the enabled state of this node
  27543. * @param value defines the new enabled state
  27544. */
  27545. setEnabled(value: boolean): void;
  27546. /**
  27547. * Is this node a descendant of the given node?
  27548. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27549. * @param ancestor defines the parent node to inspect
  27550. * @returns a boolean indicating if this node is a descendant of the given node
  27551. */
  27552. isDescendantOf(ancestor: Node): boolean;
  27553. /** @hidden */
  27554. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27555. /**
  27556. * Will return all nodes that have this node as ascendant
  27557. * @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
  27558. * @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
  27559. * @return all children nodes of all types
  27560. */
  27561. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27562. /**
  27563. * Get all child-meshes of this node
  27564. * @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)
  27565. * @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
  27566. * @returns an array of AbstractMesh
  27567. */
  27568. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27569. /**
  27570. * Get all direct children of this node
  27571. * @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
  27572. * @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)
  27573. * @returns an array of Node
  27574. */
  27575. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27576. /** @hidden */
  27577. _setReady(state: boolean): void;
  27578. /**
  27579. * Get an animation by name
  27580. * @param name defines the name of the animation to look for
  27581. * @returns null if not found else the requested animation
  27582. */
  27583. getAnimationByName(name: string): Nullable<Animation>;
  27584. /**
  27585. * Creates an animation range for this node
  27586. * @param name defines the name of the range
  27587. * @param from defines the starting key
  27588. * @param to defines the end key
  27589. */
  27590. createAnimationRange(name: string, from: number, to: number): void;
  27591. /**
  27592. * Delete a specific animation range
  27593. * @param name defines the name of the range to delete
  27594. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27595. */
  27596. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27597. /**
  27598. * Get an animation range by name
  27599. * @param name defines the name of the animation range to look for
  27600. * @returns null if not found else the requested animation range
  27601. */
  27602. getAnimationRange(name: string): Nullable<AnimationRange>;
  27603. /**
  27604. * Gets the list of all animation ranges defined on this node
  27605. * @returns an array
  27606. */
  27607. getAnimationRanges(): Nullable<AnimationRange>[];
  27608. /**
  27609. * Will start the animation sequence
  27610. * @param name defines the range frames for animation sequence
  27611. * @param loop defines if the animation should loop (false by default)
  27612. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27613. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27614. * @returns the object created for this animation. If range does not exist, it will return null
  27615. */
  27616. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27617. /**
  27618. * Serialize animation ranges into a JSON compatible object
  27619. * @returns serialization object
  27620. */
  27621. serializeAnimationRanges(): any;
  27622. /**
  27623. * Computes the world matrix of the node
  27624. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27625. * @returns the world matrix
  27626. */
  27627. computeWorldMatrix(force?: boolean): Matrix;
  27628. /**
  27629. * Releases resources associated with this node.
  27630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27632. */
  27633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27634. /**
  27635. * Parse animation range data from a serialization object and store them into a given node
  27636. * @param node defines where to store the animation ranges
  27637. * @param parsedNode defines the serialization object to read data from
  27638. * @param scene defines the hosting scene
  27639. */
  27640. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27641. /**
  27642. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27643. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27644. * @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
  27645. * @returns the new bounding vectors
  27646. */
  27647. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27648. min: Vector3;
  27649. max: Vector3;
  27650. };
  27651. }
  27652. }
  27653. declare module "babylonjs/Animations/animation" {
  27654. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27655. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27656. import { Color3 } from "babylonjs/Maths/math.color";
  27657. import { Nullable } from "babylonjs/types";
  27658. import { Scene } from "babylonjs/scene";
  27659. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27660. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27661. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27662. import { Node } from "babylonjs/node";
  27663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27664. import { Size } from "babylonjs/Maths/math.size";
  27665. import { Animatable } from "babylonjs/Animations/animatable";
  27666. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27667. /**
  27668. * @hidden
  27669. */
  27670. export class _IAnimationState {
  27671. key: number;
  27672. repeatCount: number;
  27673. workValue?: any;
  27674. loopMode?: number;
  27675. offsetValue?: any;
  27676. highLimitValue?: any;
  27677. }
  27678. /**
  27679. * Class used to store any kind of animation
  27680. */
  27681. export class Animation {
  27682. /**Name of the animation */
  27683. name: string;
  27684. /**Property to animate */
  27685. targetProperty: string;
  27686. /**The frames per second of the animation */
  27687. framePerSecond: number;
  27688. /**The data type of the animation */
  27689. dataType: number;
  27690. /**The loop mode of the animation */
  27691. loopMode?: number | undefined;
  27692. /**Specifies if blending should be enabled */
  27693. enableBlending?: boolean | undefined;
  27694. /**
  27695. * Use matrix interpolation instead of using direct key value when animating matrices
  27696. */
  27697. static AllowMatricesInterpolation: boolean;
  27698. /**
  27699. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27700. */
  27701. static AllowMatrixDecomposeForInterpolation: boolean;
  27702. /**
  27703. * Stores the key frames of the animation
  27704. */
  27705. private _keys;
  27706. /**
  27707. * Stores the easing function of the animation
  27708. */
  27709. private _easingFunction;
  27710. /**
  27711. * @hidden Internal use only
  27712. */
  27713. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27714. /**
  27715. * The set of event that will be linked to this animation
  27716. */
  27717. private _events;
  27718. /**
  27719. * Stores an array of target property paths
  27720. */
  27721. targetPropertyPath: string[];
  27722. /**
  27723. * Stores the blending speed of the animation
  27724. */
  27725. blendingSpeed: number;
  27726. /**
  27727. * Stores the animation ranges for the animation
  27728. */
  27729. private _ranges;
  27730. /**
  27731. * @hidden Internal use
  27732. */
  27733. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27734. /**
  27735. * Sets up an animation
  27736. * @param property The property to animate
  27737. * @param animationType The animation type to apply
  27738. * @param framePerSecond The frames per second of the animation
  27739. * @param easingFunction The easing function used in the animation
  27740. * @returns The created animation
  27741. */
  27742. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27743. /**
  27744. * Create and start an animation on a node
  27745. * @param name defines the name of the global animation that will be run on all nodes
  27746. * @param node defines the root node where the animation will take place
  27747. * @param targetProperty defines property to animate
  27748. * @param framePerSecond defines the number of frame per second yo use
  27749. * @param totalFrame defines the number of frames in total
  27750. * @param from defines the initial value
  27751. * @param to defines the final value
  27752. * @param loopMode defines which loop mode you want to use (off by default)
  27753. * @param easingFunction defines the easing function to use (linear by default)
  27754. * @param onAnimationEnd defines the callback to call when animation end
  27755. * @returns the animatable created for this animation
  27756. */
  27757. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27758. /**
  27759. * Create and start an animation on a node and its descendants
  27760. * @param name defines the name of the global animation that will be run on all nodes
  27761. * @param node defines the root node where the animation will take place
  27762. * @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
  27763. * @param targetProperty defines property to animate
  27764. * @param framePerSecond defines the number of frame per second to use
  27765. * @param totalFrame defines the number of frames in total
  27766. * @param from defines the initial value
  27767. * @param to defines the final value
  27768. * @param loopMode defines which loop mode you want to use (off by default)
  27769. * @param easingFunction defines the easing function to use (linear by default)
  27770. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27771. * @returns the list of animatables created for all nodes
  27772. * @example https://www.babylonjs-playground.com/#MH0VLI
  27773. */
  27774. 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[]>;
  27775. /**
  27776. * Creates a new animation, merges it with the existing animations and starts it
  27777. * @param name Name of the animation
  27778. * @param node Node which contains the scene that begins the animations
  27779. * @param targetProperty Specifies which property to animate
  27780. * @param framePerSecond The frames per second of the animation
  27781. * @param totalFrame The total number of frames
  27782. * @param from The frame at the beginning of the animation
  27783. * @param to The frame at the end of the animation
  27784. * @param loopMode Specifies the loop mode of the animation
  27785. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27786. * @param onAnimationEnd Callback to run once the animation is complete
  27787. * @returns Nullable animation
  27788. */
  27789. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27790. /**
  27791. * Transition property of an host to the target Value
  27792. * @param property The property to transition
  27793. * @param targetValue The target Value of the property
  27794. * @param host The object where the property to animate belongs
  27795. * @param scene Scene used to run the animation
  27796. * @param frameRate Framerate (in frame/s) to use
  27797. * @param transition The transition type we want to use
  27798. * @param duration The duration of the animation, in milliseconds
  27799. * @param onAnimationEnd Callback trigger at the end of the animation
  27800. * @returns Nullable animation
  27801. */
  27802. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27803. /**
  27804. * Return the array of runtime animations currently using this animation
  27805. */
  27806. readonly runtimeAnimations: RuntimeAnimation[];
  27807. /**
  27808. * Specifies if any of the runtime animations are currently running
  27809. */
  27810. readonly hasRunningRuntimeAnimations: boolean;
  27811. /**
  27812. * Initializes the animation
  27813. * @param name Name of the animation
  27814. * @param targetProperty Property to animate
  27815. * @param framePerSecond The frames per second of the animation
  27816. * @param dataType The data type of the animation
  27817. * @param loopMode The loop mode of the animation
  27818. * @param enableBlending Specifies if blending should be enabled
  27819. */
  27820. constructor(
  27821. /**Name of the animation */
  27822. name: string,
  27823. /**Property to animate */
  27824. targetProperty: string,
  27825. /**The frames per second of the animation */
  27826. framePerSecond: number,
  27827. /**The data type of the animation */
  27828. dataType: number,
  27829. /**The loop mode of the animation */
  27830. loopMode?: number | undefined,
  27831. /**Specifies if blending should be enabled */
  27832. enableBlending?: boolean | undefined);
  27833. /**
  27834. * Converts the animation to a string
  27835. * @param fullDetails support for multiple levels of logging within scene loading
  27836. * @returns String form of the animation
  27837. */
  27838. toString(fullDetails?: boolean): string;
  27839. /**
  27840. * Add an event to this animation
  27841. * @param event Event to add
  27842. */
  27843. addEvent(event: AnimationEvent): void;
  27844. /**
  27845. * Remove all events found at the given frame
  27846. * @param frame The frame to remove events from
  27847. */
  27848. removeEvents(frame: number): void;
  27849. /**
  27850. * Retrieves all the events from the animation
  27851. * @returns Events from the animation
  27852. */
  27853. getEvents(): AnimationEvent[];
  27854. /**
  27855. * Creates an animation range
  27856. * @param name Name of the animation range
  27857. * @param from Starting frame of the animation range
  27858. * @param to Ending frame of the animation
  27859. */
  27860. createRange(name: string, from: number, to: number): void;
  27861. /**
  27862. * Deletes an animation range by name
  27863. * @param name Name of the animation range to delete
  27864. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27865. */
  27866. deleteRange(name: string, deleteFrames?: boolean): void;
  27867. /**
  27868. * Gets the animation range by name, or null if not defined
  27869. * @param name Name of the animation range
  27870. * @returns Nullable animation range
  27871. */
  27872. getRange(name: string): Nullable<AnimationRange>;
  27873. /**
  27874. * Gets the key frames from the animation
  27875. * @returns The key frames of the animation
  27876. */
  27877. getKeys(): Array<IAnimationKey>;
  27878. /**
  27879. * Gets the highest frame rate of the animation
  27880. * @returns Highest frame rate of the animation
  27881. */
  27882. getHighestFrame(): number;
  27883. /**
  27884. * Gets the easing function of the animation
  27885. * @returns Easing function of the animation
  27886. */
  27887. getEasingFunction(): IEasingFunction;
  27888. /**
  27889. * Sets the easing function of the animation
  27890. * @param easingFunction A custom mathematical formula for animation
  27891. */
  27892. setEasingFunction(easingFunction: EasingFunction): void;
  27893. /**
  27894. * Interpolates a scalar linearly
  27895. * @param startValue Start value of the animation curve
  27896. * @param endValue End value of the animation curve
  27897. * @param gradient Scalar amount to interpolate
  27898. * @returns Interpolated scalar value
  27899. */
  27900. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27901. /**
  27902. * Interpolates a scalar cubically
  27903. * @param startValue Start value of the animation curve
  27904. * @param outTangent End tangent of the animation
  27905. * @param endValue End value of the animation curve
  27906. * @param inTangent Start tangent of the animation curve
  27907. * @param gradient Scalar amount to interpolate
  27908. * @returns Interpolated scalar value
  27909. */
  27910. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27911. /**
  27912. * Interpolates a quaternion using a spherical linear interpolation
  27913. * @param startValue Start value of the animation curve
  27914. * @param endValue End value of the animation curve
  27915. * @param gradient Scalar amount to interpolate
  27916. * @returns Interpolated quaternion value
  27917. */
  27918. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27919. /**
  27920. * Interpolates a quaternion cubically
  27921. * @param startValue Start value of the animation curve
  27922. * @param outTangent End tangent of the animation curve
  27923. * @param endValue End value of the animation curve
  27924. * @param inTangent Start tangent of the animation curve
  27925. * @param gradient Scalar amount to interpolate
  27926. * @returns Interpolated quaternion value
  27927. */
  27928. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27929. /**
  27930. * Interpolates a Vector3 linearl
  27931. * @param startValue Start value of the animation curve
  27932. * @param endValue End value of the animation curve
  27933. * @param gradient Scalar amount to interpolate
  27934. * @returns Interpolated scalar value
  27935. */
  27936. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27937. /**
  27938. * Interpolates a Vector3 cubically
  27939. * @param startValue Start value of the animation curve
  27940. * @param outTangent End tangent of the animation
  27941. * @param endValue End value of the animation curve
  27942. * @param inTangent Start tangent of the animation curve
  27943. * @param gradient Scalar amount to interpolate
  27944. * @returns InterpolatedVector3 value
  27945. */
  27946. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27947. /**
  27948. * Interpolates a Vector2 linearly
  27949. * @param startValue Start value of the animation curve
  27950. * @param endValue End value of the animation curve
  27951. * @param gradient Scalar amount to interpolate
  27952. * @returns Interpolated Vector2 value
  27953. */
  27954. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27955. /**
  27956. * Interpolates a Vector2 cubically
  27957. * @param startValue Start value of the animation curve
  27958. * @param outTangent End tangent of the animation
  27959. * @param endValue End value of the animation curve
  27960. * @param inTangent Start tangent of the animation curve
  27961. * @param gradient Scalar amount to interpolate
  27962. * @returns Interpolated Vector2 value
  27963. */
  27964. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27965. /**
  27966. * Interpolates a size linearly
  27967. * @param startValue Start value of the animation curve
  27968. * @param endValue End value of the animation curve
  27969. * @param gradient Scalar amount to interpolate
  27970. * @returns Interpolated Size value
  27971. */
  27972. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27973. /**
  27974. * Interpolates a Color3 linearly
  27975. * @param startValue Start value of the animation curve
  27976. * @param endValue End value of the animation curve
  27977. * @param gradient Scalar amount to interpolate
  27978. * @returns Interpolated Color3 value
  27979. */
  27980. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27981. /**
  27982. * @hidden Internal use only
  27983. */
  27984. _getKeyValue(value: any): any;
  27985. /**
  27986. * @hidden Internal use only
  27987. */
  27988. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27989. /**
  27990. * Defines the function to use to interpolate matrices
  27991. * @param startValue defines the start matrix
  27992. * @param endValue defines the end matrix
  27993. * @param gradient defines the gradient between both matrices
  27994. * @param result defines an optional target matrix where to store the interpolation
  27995. * @returns the interpolated matrix
  27996. */
  27997. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27998. /**
  27999. * Makes a copy of the animation
  28000. * @returns Cloned animation
  28001. */
  28002. clone(): Animation;
  28003. /**
  28004. * Sets the key frames of the animation
  28005. * @param values The animation key frames to set
  28006. */
  28007. setKeys(values: Array<IAnimationKey>): void;
  28008. /**
  28009. * Serializes the animation to an object
  28010. * @returns Serialized object
  28011. */
  28012. serialize(): any;
  28013. /**
  28014. * Float animation type
  28015. */
  28016. private static _ANIMATIONTYPE_FLOAT;
  28017. /**
  28018. * Vector3 animation type
  28019. */
  28020. private static _ANIMATIONTYPE_VECTOR3;
  28021. /**
  28022. * Quaternion animation type
  28023. */
  28024. private static _ANIMATIONTYPE_QUATERNION;
  28025. /**
  28026. * Matrix animation type
  28027. */
  28028. private static _ANIMATIONTYPE_MATRIX;
  28029. /**
  28030. * Color3 animation type
  28031. */
  28032. private static _ANIMATIONTYPE_COLOR3;
  28033. /**
  28034. * Vector2 animation type
  28035. */
  28036. private static _ANIMATIONTYPE_VECTOR2;
  28037. /**
  28038. * Size animation type
  28039. */
  28040. private static _ANIMATIONTYPE_SIZE;
  28041. /**
  28042. * Relative Loop Mode
  28043. */
  28044. private static _ANIMATIONLOOPMODE_RELATIVE;
  28045. /**
  28046. * Cycle Loop Mode
  28047. */
  28048. private static _ANIMATIONLOOPMODE_CYCLE;
  28049. /**
  28050. * Constant Loop Mode
  28051. */
  28052. private static _ANIMATIONLOOPMODE_CONSTANT;
  28053. /**
  28054. * Get the float animation type
  28055. */
  28056. static readonly ANIMATIONTYPE_FLOAT: number;
  28057. /**
  28058. * Get the Vector3 animation type
  28059. */
  28060. static readonly ANIMATIONTYPE_VECTOR3: number;
  28061. /**
  28062. * Get the Vector2 animation type
  28063. */
  28064. static readonly ANIMATIONTYPE_VECTOR2: number;
  28065. /**
  28066. * Get the Size animation type
  28067. */
  28068. static readonly ANIMATIONTYPE_SIZE: number;
  28069. /**
  28070. * Get the Quaternion animation type
  28071. */
  28072. static readonly ANIMATIONTYPE_QUATERNION: number;
  28073. /**
  28074. * Get the Matrix animation type
  28075. */
  28076. static readonly ANIMATIONTYPE_MATRIX: number;
  28077. /**
  28078. * Get the Color3 animation type
  28079. */
  28080. static readonly ANIMATIONTYPE_COLOR3: number;
  28081. /**
  28082. * Get the Relative Loop Mode
  28083. */
  28084. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28085. /**
  28086. * Get the Cycle Loop Mode
  28087. */
  28088. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28089. /**
  28090. * Get the Constant Loop Mode
  28091. */
  28092. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28093. /** @hidden */
  28094. static _UniversalLerp(left: any, right: any, amount: number): any;
  28095. /**
  28096. * Parses an animation object and creates an animation
  28097. * @param parsedAnimation Parsed animation object
  28098. * @returns Animation object
  28099. */
  28100. static Parse(parsedAnimation: any): Animation;
  28101. /**
  28102. * Appends the serialized animations from the source animations
  28103. * @param source Source containing the animations
  28104. * @param destination Target to store the animations
  28105. */
  28106. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28107. }
  28108. }
  28109. declare module "babylonjs/Animations/animatable.interface" {
  28110. import { Nullable } from "babylonjs/types";
  28111. import { Animation } from "babylonjs/Animations/animation";
  28112. /**
  28113. * Interface containing an array of animations
  28114. */
  28115. export interface IAnimatable {
  28116. /**
  28117. * Array of animations
  28118. */
  28119. animations: Nullable<Array<Animation>>;
  28120. }
  28121. }
  28122. declare module "babylonjs/Materials/fresnelParameters" {
  28123. import { Color3 } from "babylonjs/Maths/math.color";
  28124. /**
  28125. * This represents all the required information to add a fresnel effect on a material:
  28126. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28127. */
  28128. export class FresnelParameters {
  28129. private _isEnabled;
  28130. /**
  28131. * Define if the fresnel effect is enable or not.
  28132. */
  28133. isEnabled: boolean;
  28134. /**
  28135. * Define the color used on edges (grazing angle)
  28136. */
  28137. leftColor: Color3;
  28138. /**
  28139. * Define the color used on center
  28140. */
  28141. rightColor: Color3;
  28142. /**
  28143. * Define bias applied to computed fresnel term
  28144. */
  28145. bias: number;
  28146. /**
  28147. * Defined the power exponent applied to fresnel term
  28148. */
  28149. power: number;
  28150. /**
  28151. * Clones the current fresnel and its valuues
  28152. * @returns a clone fresnel configuration
  28153. */
  28154. clone(): FresnelParameters;
  28155. /**
  28156. * Serializes the current fresnel parameters to a JSON representation.
  28157. * @return the JSON serialization
  28158. */
  28159. serialize(): any;
  28160. /**
  28161. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28162. * @param parsedFresnelParameters Define the JSON representation
  28163. * @returns the parsed parameters
  28164. */
  28165. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28166. }
  28167. }
  28168. declare module "babylonjs/Misc/decorators" {
  28169. import { Nullable } from "babylonjs/types";
  28170. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28171. import { Scene } from "babylonjs/scene";
  28172. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28173. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28174. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28175. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28176. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28177. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28178. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28179. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28180. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28181. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28182. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28183. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28184. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28185. /**
  28186. * Decorator used to define property that can be serialized as reference to a camera
  28187. * @param sourceName defines the name of the property to decorate
  28188. */
  28189. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28190. /**
  28191. * Class used to help serialization objects
  28192. */
  28193. export class SerializationHelper {
  28194. /** @hidden */
  28195. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28196. /** @hidden */
  28197. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28198. /** @hidden */
  28199. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28200. /** @hidden */
  28201. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28202. /**
  28203. * Appends the serialized animations from the source animations
  28204. * @param source Source containing the animations
  28205. * @param destination Target to store the animations
  28206. */
  28207. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28208. /**
  28209. * Static function used to serialized a specific entity
  28210. * @param entity defines the entity to serialize
  28211. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28212. * @returns a JSON compatible object representing the serialization of the entity
  28213. */
  28214. static Serialize<T>(entity: T, serializationObject?: any): any;
  28215. /**
  28216. * Creates a new entity from a serialization data object
  28217. * @param creationFunction defines a function used to instanciated the new entity
  28218. * @param source defines the source serialization data
  28219. * @param scene defines the hosting scene
  28220. * @param rootUrl defines the root url for resources
  28221. * @returns a new entity
  28222. */
  28223. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28224. /**
  28225. * Clones an object
  28226. * @param creationFunction defines the function used to instanciate the new object
  28227. * @param source defines the source object
  28228. * @returns the cloned object
  28229. */
  28230. static Clone<T>(creationFunction: () => T, source: T): T;
  28231. /**
  28232. * Instanciates a new object based on a source one (some data will be shared between both object)
  28233. * @param creationFunction defines the function used to instanciate the new object
  28234. * @param source defines the source object
  28235. * @returns the new object
  28236. */
  28237. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28238. }
  28239. }
  28240. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28241. import { Nullable } from "babylonjs/types";
  28242. /**
  28243. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28244. */
  28245. export interface CubeMapInfo {
  28246. /**
  28247. * The pixel array for the front face.
  28248. * This is stored in format, left to right, up to down format.
  28249. */
  28250. front: Nullable<ArrayBufferView>;
  28251. /**
  28252. * The pixel array for the back face.
  28253. * This is stored in format, left to right, up to down format.
  28254. */
  28255. back: Nullable<ArrayBufferView>;
  28256. /**
  28257. * The pixel array for the left face.
  28258. * This is stored in format, left to right, up to down format.
  28259. */
  28260. left: Nullable<ArrayBufferView>;
  28261. /**
  28262. * The pixel array for the right face.
  28263. * This is stored in format, left to right, up to down format.
  28264. */
  28265. right: Nullable<ArrayBufferView>;
  28266. /**
  28267. * The pixel array for the up face.
  28268. * This is stored in format, left to right, up to down format.
  28269. */
  28270. up: Nullable<ArrayBufferView>;
  28271. /**
  28272. * The pixel array for the down face.
  28273. * This is stored in format, left to right, up to down format.
  28274. */
  28275. down: Nullable<ArrayBufferView>;
  28276. /**
  28277. * The size of the cubemap stored.
  28278. *
  28279. * Each faces will be size * size pixels.
  28280. */
  28281. size: number;
  28282. /**
  28283. * The format of the texture.
  28284. *
  28285. * RGBA, RGB.
  28286. */
  28287. format: number;
  28288. /**
  28289. * The type of the texture data.
  28290. *
  28291. * UNSIGNED_INT, FLOAT.
  28292. */
  28293. type: number;
  28294. /**
  28295. * Specifies whether the texture is in gamma space.
  28296. */
  28297. gammaSpace: boolean;
  28298. }
  28299. /**
  28300. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28301. */
  28302. export class PanoramaToCubeMapTools {
  28303. private static FACE_FRONT;
  28304. private static FACE_BACK;
  28305. private static FACE_RIGHT;
  28306. private static FACE_LEFT;
  28307. private static FACE_DOWN;
  28308. private static FACE_UP;
  28309. /**
  28310. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28311. *
  28312. * @param float32Array The source data.
  28313. * @param inputWidth The width of the input panorama.
  28314. * @param inputHeight The height of the input panorama.
  28315. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28316. * @return The cubemap data
  28317. */
  28318. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28319. private static CreateCubemapTexture;
  28320. private static CalcProjectionSpherical;
  28321. }
  28322. }
  28323. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28324. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28326. import { Nullable } from "babylonjs/types";
  28327. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28328. /**
  28329. * Helper class dealing with the extraction of spherical polynomial dataArray
  28330. * from a cube map.
  28331. */
  28332. export class CubeMapToSphericalPolynomialTools {
  28333. private static FileFaces;
  28334. /**
  28335. * Converts a texture to the according Spherical Polynomial data.
  28336. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28337. *
  28338. * @param texture The texture to extract the information from.
  28339. * @return The Spherical Polynomial data.
  28340. */
  28341. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28342. /**
  28343. * Converts a cubemap to the according Spherical Polynomial data.
  28344. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28345. *
  28346. * @param cubeInfo The Cube map to extract the information from.
  28347. * @return The Spherical Polynomial data.
  28348. */
  28349. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28350. }
  28351. }
  28352. declare module "babylonjs/Misc/guid" {
  28353. /**
  28354. * Class used to manipulate GUIDs
  28355. */
  28356. export class GUID {
  28357. /**
  28358. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28359. * Be aware Math.random() could cause collisions, but:
  28360. * "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"
  28361. * @returns a pseudo random id
  28362. */
  28363. static RandomId(): string;
  28364. }
  28365. }
  28366. declare module "babylonjs/Materials/Textures/baseTexture" {
  28367. import { Observable } from "babylonjs/Misc/observable";
  28368. import { Nullable } from "babylonjs/types";
  28369. import { Scene } from "babylonjs/scene";
  28370. import { Matrix } from "babylonjs/Maths/math.vector";
  28371. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28372. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28373. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28374. import { ISize } from "babylonjs/Maths/math.size";
  28375. /**
  28376. * Base class of all the textures in babylon.
  28377. * It groups all the common properties the materials, post process, lights... might need
  28378. * in order to make a correct use of the texture.
  28379. */
  28380. export class BaseTexture implements IAnimatable {
  28381. /**
  28382. * Default anisotropic filtering level for the application.
  28383. * It is set to 4 as a good tradeoff between perf and quality.
  28384. */
  28385. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28386. /**
  28387. * Gets or sets the unique id of the texture
  28388. */
  28389. uniqueId: number;
  28390. /**
  28391. * Define the name of the texture.
  28392. */
  28393. name: string;
  28394. /**
  28395. * Gets or sets an object used to store user defined information.
  28396. */
  28397. metadata: any;
  28398. /**
  28399. * For internal use only. Please do not use.
  28400. */
  28401. reservedDataStore: any;
  28402. private _hasAlpha;
  28403. /**
  28404. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28405. */
  28406. hasAlpha: boolean;
  28407. /**
  28408. * Defines if the alpha value should be determined via the rgb values.
  28409. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28410. */
  28411. getAlphaFromRGB: boolean;
  28412. /**
  28413. * Intensity or strength of the texture.
  28414. * It is commonly used by materials to fine tune the intensity of the texture
  28415. */
  28416. level: number;
  28417. /**
  28418. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28419. * This is part of the texture as textures usually maps to one uv set.
  28420. */
  28421. coordinatesIndex: number;
  28422. private _coordinatesMode;
  28423. /**
  28424. * How a texture is mapped.
  28425. *
  28426. * | Value | Type | Description |
  28427. * | ----- | ----------------------------------- | ----------- |
  28428. * | 0 | EXPLICIT_MODE | |
  28429. * | 1 | SPHERICAL_MODE | |
  28430. * | 2 | PLANAR_MODE | |
  28431. * | 3 | CUBIC_MODE | |
  28432. * | 4 | PROJECTION_MODE | |
  28433. * | 5 | SKYBOX_MODE | |
  28434. * | 6 | INVCUBIC_MODE | |
  28435. * | 7 | EQUIRECTANGULAR_MODE | |
  28436. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28437. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28438. */
  28439. coordinatesMode: number;
  28440. /**
  28441. * | Value | Type | Description |
  28442. * | ----- | ------------------ | ----------- |
  28443. * | 0 | CLAMP_ADDRESSMODE | |
  28444. * | 1 | WRAP_ADDRESSMODE | |
  28445. * | 2 | MIRROR_ADDRESSMODE | |
  28446. */
  28447. wrapU: number;
  28448. /**
  28449. * | Value | Type | Description |
  28450. * | ----- | ------------------ | ----------- |
  28451. * | 0 | CLAMP_ADDRESSMODE | |
  28452. * | 1 | WRAP_ADDRESSMODE | |
  28453. * | 2 | MIRROR_ADDRESSMODE | |
  28454. */
  28455. wrapV: number;
  28456. /**
  28457. * | Value | Type | Description |
  28458. * | ----- | ------------------ | ----------- |
  28459. * | 0 | CLAMP_ADDRESSMODE | |
  28460. * | 1 | WRAP_ADDRESSMODE | |
  28461. * | 2 | MIRROR_ADDRESSMODE | |
  28462. */
  28463. wrapR: number;
  28464. /**
  28465. * With compliant hardware and browser (supporting anisotropic filtering)
  28466. * this defines the level of anisotropic filtering in the texture.
  28467. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28468. */
  28469. anisotropicFilteringLevel: number;
  28470. /**
  28471. * Define if the texture is a cube texture or if false a 2d texture.
  28472. */
  28473. isCube: boolean;
  28474. /**
  28475. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28476. */
  28477. is3D: boolean;
  28478. /**
  28479. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28480. * HDR texture are usually stored in linear space.
  28481. * This only impacts the PBR and Background materials
  28482. */
  28483. gammaSpace: boolean;
  28484. /**
  28485. * Gets whether or not the texture contains RGBD data.
  28486. */
  28487. readonly isRGBD: boolean;
  28488. /**
  28489. * Is Z inverted in the texture (useful in a cube texture).
  28490. */
  28491. invertZ: boolean;
  28492. /**
  28493. * Are mip maps generated for this texture or not.
  28494. */
  28495. readonly noMipmap: boolean;
  28496. /**
  28497. * @hidden
  28498. */
  28499. lodLevelInAlpha: boolean;
  28500. /**
  28501. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28502. */
  28503. lodGenerationOffset: number;
  28504. /**
  28505. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28506. */
  28507. lodGenerationScale: number;
  28508. /**
  28509. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28510. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28511. * average roughness values.
  28512. */
  28513. linearSpecularLOD: boolean;
  28514. /**
  28515. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28516. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28517. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28518. */
  28519. irradianceTexture: Nullable<BaseTexture>;
  28520. /**
  28521. * Define if the texture is a render target.
  28522. */
  28523. isRenderTarget: boolean;
  28524. /**
  28525. * Define the unique id of the texture in the scene.
  28526. */
  28527. readonly uid: string;
  28528. /**
  28529. * Return a string representation of the texture.
  28530. * @returns the texture as a string
  28531. */
  28532. toString(): string;
  28533. /**
  28534. * Get the class name of the texture.
  28535. * @returns "BaseTexture"
  28536. */
  28537. getClassName(): string;
  28538. /**
  28539. * Define the list of animation attached to the texture.
  28540. */
  28541. animations: import("babylonjs/Animations/animation").Animation[];
  28542. /**
  28543. * An event triggered when the texture is disposed.
  28544. */
  28545. onDisposeObservable: Observable<BaseTexture>;
  28546. private _onDisposeObserver;
  28547. /**
  28548. * Callback triggered when the texture has been disposed.
  28549. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28550. */
  28551. onDispose: () => void;
  28552. /**
  28553. * Define the current state of the loading sequence when in delayed load mode.
  28554. */
  28555. delayLoadState: number;
  28556. private _scene;
  28557. /** @hidden */
  28558. _texture: Nullable<InternalTexture>;
  28559. private _uid;
  28560. /**
  28561. * Define if the texture is preventinga material to render or not.
  28562. * If not and the texture is not ready, the engine will use a default black texture instead.
  28563. */
  28564. readonly isBlocking: boolean;
  28565. /**
  28566. * Instantiates a new BaseTexture.
  28567. * Base class of all the textures in babylon.
  28568. * It groups all the common properties the materials, post process, lights... might need
  28569. * in order to make a correct use of the texture.
  28570. * @param scene Define the scene the texture blongs to
  28571. */
  28572. constructor(scene: Nullable<Scene>);
  28573. /**
  28574. * Get the scene the texture belongs to.
  28575. * @returns the scene or null if undefined
  28576. */
  28577. getScene(): Nullable<Scene>;
  28578. /**
  28579. * Get the texture transform matrix used to offset tile the texture for istance.
  28580. * @returns the transformation matrix
  28581. */
  28582. getTextureMatrix(): Matrix;
  28583. /**
  28584. * Get the texture reflection matrix used to rotate/transform the reflection.
  28585. * @returns the reflection matrix
  28586. */
  28587. getReflectionTextureMatrix(): Matrix;
  28588. /**
  28589. * Get the underlying lower level texture from Babylon.
  28590. * @returns the insternal texture
  28591. */
  28592. getInternalTexture(): Nullable<InternalTexture>;
  28593. /**
  28594. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28595. * @returns true if ready or not blocking
  28596. */
  28597. isReadyOrNotBlocking(): boolean;
  28598. /**
  28599. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28600. * @returns true if fully ready
  28601. */
  28602. isReady(): boolean;
  28603. private _cachedSize;
  28604. /**
  28605. * Get the size of the texture.
  28606. * @returns the texture size.
  28607. */
  28608. getSize(): ISize;
  28609. /**
  28610. * Get the base size of the texture.
  28611. * It can be different from the size if the texture has been resized for POT for instance
  28612. * @returns the base size
  28613. */
  28614. getBaseSize(): ISize;
  28615. /**
  28616. * Update the sampling mode of the texture.
  28617. * Default is Trilinear mode.
  28618. *
  28619. * | Value | Type | Description |
  28620. * | ----- | ------------------ | ----------- |
  28621. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28622. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28623. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28624. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28625. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28626. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28627. * | 7 | NEAREST_LINEAR | |
  28628. * | 8 | NEAREST_NEAREST | |
  28629. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28630. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28631. * | 11 | LINEAR_LINEAR | |
  28632. * | 12 | LINEAR_NEAREST | |
  28633. *
  28634. * > _mag_: magnification filter (close to the viewer)
  28635. * > _min_: minification filter (far from the viewer)
  28636. * > _mip_: filter used between mip map levels
  28637. *@param samplingMode Define the new sampling mode of the texture
  28638. */
  28639. updateSamplingMode(samplingMode: number): void;
  28640. /**
  28641. * Scales the texture if is `canRescale()`
  28642. * @param ratio the resize factor we want to use to rescale
  28643. */
  28644. scale(ratio: number): void;
  28645. /**
  28646. * Get if the texture can rescale.
  28647. */
  28648. readonly canRescale: boolean;
  28649. /** @hidden */
  28650. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28651. /** @hidden */
  28652. _rebuild(): void;
  28653. /**
  28654. * Triggers the load sequence in delayed load mode.
  28655. */
  28656. delayLoad(): void;
  28657. /**
  28658. * Clones the texture.
  28659. * @returns the cloned texture
  28660. */
  28661. clone(): Nullable<BaseTexture>;
  28662. /**
  28663. * Get the texture underlying type (INT, FLOAT...)
  28664. */
  28665. readonly textureType: number;
  28666. /**
  28667. * Get the texture underlying format (RGB, RGBA...)
  28668. */
  28669. readonly textureFormat: number;
  28670. /**
  28671. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28672. * This will returns an RGBA array buffer containing either in values (0-255) or
  28673. * float values (0-1) depending of the underlying buffer type.
  28674. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28675. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28676. * @param buffer defines a user defined buffer to fill with data (can be null)
  28677. * @returns The Array buffer containing the pixels data.
  28678. */
  28679. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28680. /**
  28681. * Release and destroy the underlying lower level texture aka internalTexture.
  28682. */
  28683. releaseInternalTexture(): void;
  28684. /**
  28685. * Get the polynomial representation of the texture data.
  28686. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28687. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28688. */
  28689. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28690. /** @hidden */
  28691. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28692. /** @hidden */
  28693. readonly _lodTextureMid: Nullable<BaseTexture>;
  28694. /** @hidden */
  28695. readonly _lodTextureLow: Nullable<BaseTexture>;
  28696. /**
  28697. * Dispose the texture and release its associated resources.
  28698. */
  28699. dispose(): void;
  28700. /**
  28701. * Serialize the texture into a JSON representation that can be parsed later on.
  28702. * @returns the JSON representation of the texture
  28703. */
  28704. serialize(): any;
  28705. /**
  28706. * Helper function to be called back once a list of texture contains only ready textures.
  28707. * @param textures Define the list of textures to wait for
  28708. * @param callback Define the callback triggered once the entire list will be ready
  28709. */
  28710. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28711. }
  28712. }
  28713. declare module "babylonjs/Materials/Textures/internalTexture" {
  28714. import { Observable } from "babylonjs/Misc/observable";
  28715. import { Nullable, int } from "babylonjs/types";
  28716. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28717. import { Engine } from "babylonjs/Engines/engine";
  28718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28719. /**
  28720. * Class used to store data associated with WebGL texture data for the engine
  28721. * This class should not be used directly
  28722. */
  28723. export class InternalTexture {
  28724. /** @hidden */
  28725. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28726. /**
  28727. * The source of the texture data is unknown
  28728. */
  28729. static DATASOURCE_UNKNOWN: number;
  28730. /**
  28731. * Texture data comes from an URL
  28732. */
  28733. static DATASOURCE_URL: number;
  28734. /**
  28735. * Texture data is only used for temporary storage
  28736. */
  28737. static DATASOURCE_TEMP: number;
  28738. /**
  28739. * Texture data comes from raw data (ArrayBuffer)
  28740. */
  28741. static DATASOURCE_RAW: number;
  28742. /**
  28743. * Texture content is dynamic (video or dynamic texture)
  28744. */
  28745. static DATASOURCE_DYNAMIC: number;
  28746. /**
  28747. * Texture content is generated by rendering to it
  28748. */
  28749. static DATASOURCE_RENDERTARGET: number;
  28750. /**
  28751. * Texture content is part of a multi render target process
  28752. */
  28753. static DATASOURCE_MULTIRENDERTARGET: number;
  28754. /**
  28755. * Texture data comes from a cube data file
  28756. */
  28757. static DATASOURCE_CUBE: number;
  28758. /**
  28759. * Texture data comes from a raw cube data
  28760. */
  28761. static DATASOURCE_CUBERAW: number;
  28762. /**
  28763. * Texture data come from a prefiltered cube data file
  28764. */
  28765. static DATASOURCE_CUBEPREFILTERED: number;
  28766. /**
  28767. * Texture content is raw 3D data
  28768. */
  28769. static DATASOURCE_RAW3D: number;
  28770. /**
  28771. * Texture content is a depth texture
  28772. */
  28773. static DATASOURCE_DEPTHTEXTURE: number;
  28774. /**
  28775. * Texture data comes from a raw cube data encoded with RGBD
  28776. */
  28777. static DATASOURCE_CUBERAW_RGBD: number;
  28778. /**
  28779. * Defines if the texture is ready
  28780. */
  28781. isReady: boolean;
  28782. /**
  28783. * Defines if the texture is a cube texture
  28784. */
  28785. isCube: boolean;
  28786. /**
  28787. * Defines if the texture contains 3D data
  28788. */
  28789. is3D: boolean;
  28790. /**
  28791. * Defines if the texture contains multiview data
  28792. */
  28793. isMultiview: boolean;
  28794. /**
  28795. * Gets the URL used to load this texture
  28796. */
  28797. url: string;
  28798. /**
  28799. * Gets the sampling mode of the texture
  28800. */
  28801. samplingMode: number;
  28802. /**
  28803. * Gets a boolean indicating if the texture needs mipmaps generation
  28804. */
  28805. generateMipMaps: boolean;
  28806. /**
  28807. * Gets the number of samples used by the texture (WebGL2+ only)
  28808. */
  28809. samples: number;
  28810. /**
  28811. * Gets the type of the texture (int, float...)
  28812. */
  28813. type: number;
  28814. /**
  28815. * Gets the format of the texture (RGB, RGBA...)
  28816. */
  28817. format: number;
  28818. /**
  28819. * Observable called when the texture is loaded
  28820. */
  28821. onLoadedObservable: Observable<InternalTexture>;
  28822. /**
  28823. * Gets the width of the texture
  28824. */
  28825. width: number;
  28826. /**
  28827. * Gets the height of the texture
  28828. */
  28829. height: number;
  28830. /**
  28831. * Gets the depth of the texture
  28832. */
  28833. depth: number;
  28834. /**
  28835. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28836. */
  28837. baseWidth: number;
  28838. /**
  28839. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28840. */
  28841. baseHeight: number;
  28842. /**
  28843. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28844. */
  28845. baseDepth: number;
  28846. /**
  28847. * Gets a boolean indicating if the texture is inverted on Y axis
  28848. */
  28849. invertY: boolean;
  28850. /** @hidden */
  28851. _invertVScale: boolean;
  28852. /** @hidden */
  28853. _associatedChannel: number;
  28854. /** @hidden */
  28855. _dataSource: number;
  28856. /** @hidden */
  28857. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28858. /** @hidden */
  28859. _bufferView: Nullable<ArrayBufferView>;
  28860. /** @hidden */
  28861. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28862. /** @hidden */
  28863. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28864. /** @hidden */
  28865. _size: number;
  28866. /** @hidden */
  28867. _extension: string;
  28868. /** @hidden */
  28869. _files: Nullable<string[]>;
  28870. /** @hidden */
  28871. _workingCanvas: Nullable<HTMLCanvasElement>;
  28872. /** @hidden */
  28873. _workingContext: Nullable<CanvasRenderingContext2D>;
  28874. /** @hidden */
  28875. _framebuffer: Nullable<WebGLFramebuffer>;
  28876. /** @hidden */
  28877. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28878. /** @hidden */
  28879. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28880. /** @hidden */
  28881. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28882. /** @hidden */
  28883. _attachments: Nullable<number[]>;
  28884. /** @hidden */
  28885. _cachedCoordinatesMode: Nullable<number>;
  28886. /** @hidden */
  28887. _cachedWrapU: Nullable<number>;
  28888. /** @hidden */
  28889. _cachedWrapV: Nullable<number>;
  28890. /** @hidden */
  28891. _cachedWrapR: Nullable<number>;
  28892. /** @hidden */
  28893. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28894. /** @hidden */
  28895. _isDisabled: boolean;
  28896. /** @hidden */
  28897. _compression: Nullable<string>;
  28898. /** @hidden */
  28899. _generateStencilBuffer: boolean;
  28900. /** @hidden */
  28901. _generateDepthBuffer: boolean;
  28902. /** @hidden */
  28903. _comparisonFunction: number;
  28904. /** @hidden */
  28905. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28906. /** @hidden */
  28907. _lodGenerationScale: number;
  28908. /** @hidden */
  28909. _lodGenerationOffset: number;
  28910. /** @hidden */
  28911. _colorTextureArray: Nullable<WebGLTexture>;
  28912. /** @hidden */
  28913. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28914. /** @hidden */
  28915. _lodTextureHigh: Nullable<BaseTexture>;
  28916. /** @hidden */
  28917. _lodTextureMid: Nullable<BaseTexture>;
  28918. /** @hidden */
  28919. _lodTextureLow: Nullable<BaseTexture>;
  28920. /** @hidden */
  28921. _isRGBD: boolean;
  28922. /** @hidden */
  28923. _linearSpecularLOD: boolean;
  28924. /** @hidden */
  28925. _irradianceTexture: Nullable<BaseTexture>;
  28926. /** @hidden */
  28927. _webGLTexture: Nullable<WebGLTexture>;
  28928. /** @hidden */
  28929. _references: number;
  28930. private _engine;
  28931. /**
  28932. * Gets the Engine the texture belongs to.
  28933. * @returns The babylon engine
  28934. */
  28935. getEngine(): Engine;
  28936. /**
  28937. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28938. */
  28939. readonly dataSource: number;
  28940. /**
  28941. * Creates a new InternalTexture
  28942. * @param engine defines the engine to use
  28943. * @param dataSource defines the type of data that will be used
  28944. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28945. */
  28946. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28947. /**
  28948. * Increments the number of references (ie. the number of Texture that point to it)
  28949. */
  28950. incrementReferences(): void;
  28951. /**
  28952. * Change the size of the texture (not the size of the content)
  28953. * @param width defines the new width
  28954. * @param height defines the new height
  28955. * @param depth defines the new depth (1 by default)
  28956. */
  28957. updateSize(width: int, height: int, depth?: int): void;
  28958. /** @hidden */
  28959. _rebuild(): void;
  28960. /** @hidden */
  28961. _swapAndDie(target: InternalTexture): void;
  28962. /**
  28963. * Dispose the current allocated resources
  28964. */
  28965. dispose(): void;
  28966. }
  28967. }
  28968. declare module "babylonjs/Materials/effect" {
  28969. import { Observable } from "babylonjs/Misc/observable";
  28970. import { Nullable } from "babylonjs/types";
  28971. import { IDisposable } from "babylonjs/scene";
  28972. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28973. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28974. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28975. import { Engine } from "babylonjs/Engines/engine";
  28976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28979. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28981. /**
  28982. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28983. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28984. */
  28985. export class EffectFallbacks {
  28986. private _defines;
  28987. private _currentRank;
  28988. private _maxRank;
  28989. private _mesh;
  28990. /**
  28991. * Removes the fallback from the bound mesh.
  28992. */
  28993. unBindMesh(): void;
  28994. /**
  28995. * Adds a fallback on the specified property.
  28996. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28997. * @param define The name of the define in the shader
  28998. */
  28999. addFallback(rank: number, define: string): void;
  29000. /**
  29001. * Sets the mesh to use CPU skinning when needing to fallback.
  29002. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29003. * @param mesh The mesh to use the fallbacks.
  29004. */
  29005. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29006. /**
  29007. * Checks to see if more fallbacks are still availible.
  29008. */
  29009. readonly hasMoreFallbacks: boolean;
  29010. /**
  29011. * Removes the defines that should be removed when falling back.
  29012. * @param currentDefines defines the current define statements for the shader.
  29013. * @param effect defines the current effect we try to compile
  29014. * @returns The resulting defines with defines of the current rank removed.
  29015. */
  29016. reduce(currentDefines: string, effect: Effect): string;
  29017. }
  29018. /**
  29019. * Options to be used when creating an effect.
  29020. */
  29021. export class EffectCreationOptions {
  29022. /**
  29023. * Atrributes that will be used in the shader.
  29024. */
  29025. attributes: string[];
  29026. /**
  29027. * Uniform varible names that will be set in the shader.
  29028. */
  29029. uniformsNames: string[];
  29030. /**
  29031. * Uniform buffer varible names that will be set in the shader.
  29032. */
  29033. uniformBuffersNames: string[];
  29034. /**
  29035. * Sampler texture variable names that will be set in the shader.
  29036. */
  29037. samplers: string[];
  29038. /**
  29039. * Define statements that will be set in the shader.
  29040. */
  29041. defines: any;
  29042. /**
  29043. * Possible fallbacks for this effect to improve performance when needed.
  29044. */
  29045. fallbacks: Nullable<EffectFallbacks>;
  29046. /**
  29047. * Callback that will be called when the shader is compiled.
  29048. */
  29049. onCompiled: Nullable<(effect: Effect) => void>;
  29050. /**
  29051. * Callback that will be called if an error occurs during shader compilation.
  29052. */
  29053. onError: Nullable<(effect: Effect, errors: string) => void>;
  29054. /**
  29055. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29056. */
  29057. indexParameters: any;
  29058. /**
  29059. * Max number of lights that can be used in the shader.
  29060. */
  29061. maxSimultaneousLights: number;
  29062. /**
  29063. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29064. */
  29065. transformFeedbackVaryings: Nullable<string[]>;
  29066. }
  29067. /**
  29068. * Effect containing vertex and fragment shader that can be executed on an object.
  29069. */
  29070. export class Effect implements IDisposable {
  29071. /**
  29072. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29073. */
  29074. static ShadersRepository: string;
  29075. /**
  29076. * Name of the effect.
  29077. */
  29078. name: any;
  29079. /**
  29080. * String container all the define statements that should be set on the shader.
  29081. */
  29082. defines: string;
  29083. /**
  29084. * Callback that will be called when the shader is compiled.
  29085. */
  29086. onCompiled: Nullable<(effect: Effect) => void>;
  29087. /**
  29088. * Callback that will be called if an error occurs during shader compilation.
  29089. */
  29090. onError: Nullable<(effect: Effect, errors: string) => void>;
  29091. /**
  29092. * Callback that will be called when effect is bound.
  29093. */
  29094. onBind: Nullable<(effect: Effect) => void>;
  29095. /**
  29096. * Unique ID of the effect.
  29097. */
  29098. uniqueId: number;
  29099. /**
  29100. * Observable that will be called when the shader is compiled.
  29101. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29102. */
  29103. onCompileObservable: Observable<Effect>;
  29104. /**
  29105. * Observable that will be called if an error occurs during shader compilation.
  29106. */
  29107. onErrorObservable: Observable<Effect>;
  29108. /** @hidden */
  29109. _onBindObservable: Nullable<Observable<Effect>>;
  29110. /**
  29111. * Observable that will be called when effect is bound.
  29112. */
  29113. readonly onBindObservable: Observable<Effect>;
  29114. /** @hidden */
  29115. _bonesComputationForcedToCPU: boolean;
  29116. private static _uniqueIdSeed;
  29117. private _engine;
  29118. private _uniformBuffersNames;
  29119. private _uniformsNames;
  29120. private _samplerList;
  29121. private _samplers;
  29122. private _isReady;
  29123. private _compilationError;
  29124. private _attributesNames;
  29125. private _attributes;
  29126. private _uniforms;
  29127. /**
  29128. * Key for the effect.
  29129. * @hidden
  29130. */
  29131. _key: string;
  29132. private _indexParameters;
  29133. private _fallbacks;
  29134. private _vertexSourceCode;
  29135. private _fragmentSourceCode;
  29136. private _vertexSourceCodeOverride;
  29137. private _fragmentSourceCodeOverride;
  29138. private _transformFeedbackVaryings;
  29139. /**
  29140. * Compiled shader to webGL program.
  29141. * @hidden
  29142. */
  29143. _pipelineContext: Nullable<IPipelineContext>;
  29144. private _valueCache;
  29145. private static _baseCache;
  29146. /**
  29147. * Instantiates an effect.
  29148. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29149. * @param baseName Name of the effect.
  29150. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29151. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29152. * @param samplers List of sampler variables that will be passed to the shader.
  29153. * @param engine Engine to be used to render the effect
  29154. * @param defines Define statements to be added to the shader.
  29155. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29156. * @param onCompiled Callback that will be called when the shader is compiled.
  29157. * @param onError Callback that will be called if an error occurs during shader compilation.
  29158. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29159. */
  29160. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29161. private _useFinalCode;
  29162. /**
  29163. * Unique key for this effect
  29164. */
  29165. readonly key: string;
  29166. /**
  29167. * If the effect has been compiled and prepared.
  29168. * @returns if the effect is compiled and prepared.
  29169. */
  29170. isReady(): boolean;
  29171. private _isReadyInternal;
  29172. /**
  29173. * The engine the effect was initialized with.
  29174. * @returns the engine.
  29175. */
  29176. getEngine(): Engine;
  29177. /**
  29178. * The pipeline context for this effect
  29179. * @returns the associated pipeline context
  29180. */
  29181. getPipelineContext(): Nullable<IPipelineContext>;
  29182. /**
  29183. * The set of names of attribute variables for the shader.
  29184. * @returns An array of attribute names.
  29185. */
  29186. getAttributesNames(): string[];
  29187. /**
  29188. * Returns the attribute at the given index.
  29189. * @param index The index of the attribute.
  29190. * @returns The location of the attribute.
  29191. */
  29192. getAttributeLocation(index: number): number;
  29193. /**
  29194. * Returns the attribute based on the name of the variable.
  29195. * @param name of the attribute to look up.
  29196. * @returns the attribute location.
  29197. */
  29198. getAttributeLocationByName(name: string): number;
  29199. /**
  29200. * The number of attributes.
  29201. * @returns the numnber of attributes.
  29202. */
  29203. getAttributesCount(): number;
  29204. /**
  29205. * Gets the index of a uniform variable.
  29206. * @param uniformName of the uniform to look up.
  29207. * @returns the index.
  29208. */
  29209. getUniformIndex(uniformName: string): number;
  29210. /**
  29211. * Returns the attribute based on the name of the variable.
  29212. * @param uniformName of the uniform to look up.
  29213. * @returns the location of the uniform.
  29214. */
  29215. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29216. /**
  29217. * Returns an array of sampler variable names
  29218. * @returns The array of sampler variable neames.
  29219. */
  29220. getSamplers(): string[];
  29221. /**
  29222. * The error from the last compilation.
  29223. * @returns the error string.
  29224. */
  29225. getCompilationError(): string;
  29226. /**
  29227. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29228. * @param func The callback to be used.
  29229. */
  29230. executeWhenCompiled(func: (effect: Effect) => void): void;
  29231. private _checkIsReady;
  29232. /** @hidden */
  29233. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29234. /** @hidden */
  29235. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29236. /** @hidden */
  29237. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29238. /**
  29239. * Recompiles the webGL program
  29240. * @param vertexSourceCode The source code for the vertex shader.
  29241. * @param fragmentSourceCode The source code for the fragment shader.
  29242. * @param onCompiled Callback called when completed.
  29243. * @param onError Callback called on error.
  29244. * @hidden
  29245. */
  29246. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29247. /**
  29248. * Prepares the effect
  29249. * @hidden
  29250. */
  29251. _prepareEffect(): void;
  29252. private _processCompilationErrors;
  29253. /**
  29254. * Checks if the effect is supported. (Must be called after compilation)
  29255. */
  29256. readonly isSupported: boolean;
  29257. /**
  29258. * Binds a texture to the engine to be used as output of the shader.
  29259. * @param channel Name of the output variable.
  29260. * @param texture Texture to bind.
  29261. * @hidden
  29262. */
  29263. _bindTexture(channel: string, texture: InternalTexture): void;
  29264. /**
  29265. * Sets a texture on the engine to be used in the shader.
  29266. * @param channel Name of the sampler variable.
  29267. * @param texture Texture to set.
  29268. */
  29269. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29270. /**
  29271. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29272. * @param channel Name of the sampler variable.
  29273. * @param texture Texture to set.
  29274. */
  29275. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29276. /**
  29277. * Sets an array of textures on the engine to be used in the shader.
  29278. * @param channel Name of the variable.
  29279. * @param textures Textures to set.
  29280. */
  29281. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29282. /**
  29283. * 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)
  29284. * @param channel Name of the sampler variable.
  29285. * @param postProcess Post process to get the input texture from.
  29286. */
  29287. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29288. /**
  29289. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29290. * 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)
  29291. * @param channel Name of the sampler variable.
  29292. * @param postProcess Post process to get the output texture from.
  29293. */
  29294. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29295. /** @hidden */
  29296. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29297. /** @hidden */
  29298. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29299. /** @hidden */
  29300. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29301. /** @hidden */
  29302. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29303. /**
  29304. * Binds a buffer to a uniform.
  29305. * @param buffer Buffer to bind.
  29306. * @param name Name of the uniform variable to bind to.
  29307. */
  29308. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29309. /**
  29310. * Binds block to a uniform.
  29311. * @param blockName Name of the block to bind.
  29312. * @param index Index to bind.
  29313. */
  29314. bindUniformBlock(blockName: string, index: number): void;
  29315. /**
  29316. * Sets an interger value on a uniform variable.
  29317. * @param uniformName Name of the variable.
  29318. * @param value Value to be set.
  29319. * @returns this effect.
  29320. */
  29321. setInt(uniformName: string, value: number): Effect;
  29322. /**
  29323. * Sets an int array on a uniform variable.
  29324. * @param uniformName Name of the variable.
  29325. * @param array array to be set.
  29326. * @returns this effect.
  29327. */
  29328. setIntArray(uniformName: string, array: Int32Array): Effect;
  29329. /**
  29330. * 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)
  29331. * @param uniformName Name of the variable.
  29332. * @param array array to be set.
  29333. * @returns this effect.
  29334. */
  29335. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29343. /**
  29344. * 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)
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29350. /**
  29351. * Sets an float array on a uniform variable.
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param array array to be set.
  29361. * @returns this effect.
  29362. */
  29363. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29364. /**
  29365. * 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)
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29378. /**
  29379. * Sets an array on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setArray(uniformName: string, array: number[]): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setArray2(uniformName: string, array: number[]): Effect;
  29392. /**
  29393. * 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)
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setArray3(uniformName: string, array: number[]): Effect;
  29399. /**
  29400. * 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)
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setArray4(uniformName: string, array: number[]): Effect;
  29406. /**
  29407. * Sets matrices on a uniform variable.
  29408. * @param uniformName Name of the variable.
  29409. * @param matrices matrices to be set.
  29410. * @returns this effect.
  29411. */
  29412. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29413. /**
  29414. * Sets matrix on a uniform variable.
  29415. * @param uniformName Name of the variable.
  29416. * @param matrix matrix to be set.
  29417. * @returns this effect.
  29418. */
  29419. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29420. /**
  29421. * 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)
  29422. * @param uniformName Name of the variable.
  29423. * @param matrix matrix to be set.
  29424. * @returns this effect.
  29425. */
  29426. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29427. /**
  29428. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29429. * @param uniformName Name of the variable.
  29430. * @param matrix matrix to be set.
  29431. * @returns this effect.
  29432. */
  29433. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29434. /**
  29435. * Sets a float on a uniform variable.
  29436. * @param uniformName Name of the variable.
  29437. * @param value value to be set.
  29438. * @returns this effect.
  29439. */
  29440. setFloat(uniformName: string, value: number): Effect;
  29441. /**
  29442. * Sets a boolean on a uniform variable.
  29443. * @param uniformName Name of the variable.
  29444. * @param bool value to be set.
  29445. * @returns this effect.
  29446. */
  29447. setBool(uniformName: string, bool: boolean): Effect;
  29448. /**
  29449. * Sets a Vector2 on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param vector2 vector2 to be set.
  29452. * @returns this effect.
  29453. */
  29454. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29455. /**
  29456. * Sets a float2 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param x First float in float2.
  29459. * @param y Second float in float2.
  29460. * @returns this effect.
  29461. */
  29462. setFloat2(uniformName: string, x: number, y: number): Effect;
  29463. /**
  29464. * Sets a Vector3 on a uniform variable.
  29465. * @param uniformName Name of the variable.
  29466. * @param vector3 Value to be set.
  29467. * @returns this effect.
  29468. */
  29469. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29470. /**
  29471. * Sets a float3 on a uniform variable.
  29472. * @param uniformName Name of the variable.
  29473. * @param x First float in float3.
  29474. * @param y Second float in float3.
  29475. * @param z Third float in float3.
  29476. * @returns this effect.
  29477. */
  29478. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29479. /**
  29480. * Sets a Vector4 on a uniform variable.
  29481. * @param uniformName Name of the variable.
  29482. * @param vector4 Value to be set.
  29483. * @returns this effect.
  29484. */
  29485. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29486. /**
  29487. * Sets a float4 on a uniform variable.
  29488. * @param uniformName Name of the variable.
  29489. * @param x First float in float4.
  29490. * @param y Second float in float4.
  29491. * @param z Third float in float4.
  29492. * @param w Fourth float in float4.
  29493. * @returns this effect.
  29494. */
  29495. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29496. /**
  29497. * Sets a Color3 on a uniform variable.
  29498. * @param uniformName Name of the variable.
  29499. * @param color3 Value to be set.
  29500. * @returns this effect.
  29501. */
  29502. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29503. /**
  29504. * Sets a Color4 on a uniform variable.
  29505. * @param uniformName Name of the variable.
  29506. * @param color3 Value to be set.
  29507. * @param alpha Alpha value to be set.
  29508. * @returns this effect.
  29509. */
  29510. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29511. /**
  29512. * Sets a Color4 on a uniform variable
  29513. * @param uniformName defines the name of the variable
  29514. * @param color4 defines the value to be set
  29515. * @returns this effect.
  29516. */
  29517. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29518. /** Release all associated resources */
  29519. dispose(): void;
  29520. /**
  29521. * This function will add a new shader to the shader store
  29522. * @param name the name of the shader
  29523. * @param pixelShader optional pixel shader content
  29524. * @param vertexShader optional vertex shader content
  29525. */
  29526. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29527. /**
  29528. * Store of each shader (The can be looked up using effect.key)
  29529. */
  29530. static ShadersStore: {
  29531. [key: string]: string;
  29532. };
  29533. /**
  29534. * Store of each included file for a shader (The can be looked up using effect.key)
  29535. */
  29536. static IncludesShadersStore: {
  29537. [key: string]: string;
  29538. };
  29539. /**
  29540. * Resets the cache of effects.
  29541. */
  29542. static ResetCache(): void;
  29543. }
  29544. }
  29545. declare module "babylonjs/Materials/uniformBuffer" {
  29546. import { Nullable, FloatArray } from "babylonjs/types";
  29547. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29548. import { Engine } from "babylonjs/Engines/engine";
  29549. import { Effect } from "babylonjs/Materials/effect";
  29550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29551. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29552. import { Color3 } from "babylonjs/Maths/math.color";
  29553. /**
  29554. * Uniform buffer objects.
  29555. *
  29556. * Handles blocks of uniform on the GPU.
  29557. *
  29558. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29559. *
  29560. * For more information, please refer to :
  29561. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29562. */
  29563. export class UniformBuffer {
  29564. private _engine;
  29565. private _buffer;
  29566. private _data;
  29567. private _bufferData;
  29568. private _dynamic?;
  29569. private _uniformLocations;
  29570. private _uniformSizes;
  29571. private _uniformLocationPointer;
  29572. private _needSync;
  29573. private _noUBO;
  29574. private _currentEffect;
  29575. private static _MAX_UNIFORM_SIZE;
  29576. private static _tempBuffer;
  29577. /**
  29578. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29579. * This is dynamic to allow compat with webgl 1 and 2.
  29580. * You will need to pass the name of the uniform as well as the value.
  29581. */
  29582. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29583. /**
  29584. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29585. * This is dynamic to allow compat with webgl 1 and 2.
  29586. * You will need to pass the name of the uniform as well as the value.
  29587. */
  29588. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29589. /**
  29590. * Lambda to Update a single float in a uniform buffer.
  29591. * This is dynamic to allow compat with webgl 1 and 2.
  29592. * You will need to pass the name of the uniform as well as the value.
  29593. */
  29594. updateFloat: (name: string, x: number) => void;
  29595. /**
  29596. * Lambda to Update a vec2 of float in a uniform buffer.
  29597. * This is dynamic to allow compat with webgl 1 and 2.
  29598. * You will need to pass the name of the uniform as well as the value.
  29599. */
  29600. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29601. /**
  29602. * Lambda to Update a vec3 of float in a uniform buffer.
  29603. * This is dynamic to allow compat with webgl 1 and 2.
  29604. * You will need to pass the name of the uniform as well as the value.
  29605. */
  29606. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29607. /**
  29608. * Lambda to Update a vec4 of float in a uniform buffer.
  29609. * This is dynamic to allow compat with webgl 1 and 2.
  29610. * You will need to pass the name of the uniform as well as the value.
  29611. */
  29612. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29613. /**
  29614. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29615. * This is dynamic to allow compat with webgl 1 and 2.
  29616. * You will need to pass the name of the uniform as well as the value.
  29617. */
  29618. updateMatrix: (name: string, mat: Matrix) => void;
  29619. /**
  29620. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29621. * This is dynamic to allow compat with webgl 1 and 2.
  29622. * You will need to pass the name of the uniform as well as the value.
  29623. */
  29624. updateVector3: (name: string, vector: Vector3) => void;
  29625. /**
  29626. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29627. * This is dynamic to allow compat with webgl 1 and 2.
  29628. * You will need to pass the name of the uniform as well as the value.
  29629. */
  29630. updateVector4: (name: string, vector: Vector4) => void;
  29631. /**
  29632. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29633. * This is dynamic to allow compat with webgl 1 and 2.
  29634. * You will need to pass the name of the uniform as well as the value.
  29635. */
  29636. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29637. /**
  29638. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29639. * This is dynamic to allow compat with webgl 1 and 2.
  29640. * You will need to pass the name of the uniform as well as the value.
  29641. */
  29642. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29643. /**
  29644. * Instantiates a new Uniform buffer objects.
  29645. *
  29646. * Handles blocks of uniform on the GPU.
  29647. *
  29648. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29649. *
  29650. * For more information, please refer to :
  29651. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29652. * @param engine Define the engine the buffer is associated with
  29653. * @param data Define the data contained in the buffer
  29654. * @param dynamic Define if the buffer is updatable
  29655. */
  29656. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29657. /**
  29658. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29659. * or just falling back on setUniformXXX calls.
  29660. */
  29661. readonly useUbo: boolean;
  29662. /**
  29663. * Indicates if the WebGL underlying uniform buffer is in sync
  29664. * with the javascript cache data.
  29665. */
  29666. readonly isSync: boolean;
  29667. /**
  29668. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29669. * Also, a dynamic UniformBuffer will disable cache verification and always
  29670. * update the underlying WebGL uniform buffer to the GPU.
  29671. * @returns if Dynamic, otherwise false
  29672. */
  29673. isDynamic(): boolean;
  29674. /**
  29675. * The data cache on JS side.
  29676. * @returns the underlying data as a float array
  29677. */
  29678. getData(): Float32Array;
  29679. /**
  29680. * The underlying WebGL Uniform buffer.
  29681. * @returns the webgl buffer
  29682. */
  29683. getBuffer(): Nullable<DataBuffer>;
  29684. /**
  29685. * std140 layout specifies how to align data within an UBO structure.
  29686. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29687. * for specs.
  29688. */
  29689. private _fillAlignment;
  29690. /**
  29691. * Adds an uniform in the buffer.
  29692. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29693. * for the layout to be correct !
  29694. * @param name Name of the uniform, as used in the uniform block in the shader.
  29695. * @param size Data size, or data directly.
  29696. */
  29697. addUniform(name: string, size: number | number[]): void;
  29698. /**
  29699. * Adds a Matrix 4x4 to the uniform buffer.
  29700. * @param name Name of the uniform, as used in the uniform block in the shader.
  29701. * @param mat A 4x4 matrix.
  29702. */
  29703. addMatrix(name: string, mat: Matrix): void;
  29704. /**
  29705. * Adds a vec2 to the uniform buffer.
  29706. * @param name Name of the uniform, as used in the uniform block in the shader.
  29707. * @param x Define the x component value of the vec2
  29708. * @param y Define the y component value of the vec2
  29709. */
  29710. addFloat2(name: string, x: number, y: number): void;
  29711. /**
  29712. * Adds a vec3 to the uniform buffer.
  29713. * @param name Name of the uniform, as used in the uniform block in the shader.
  29714. * @param x Define the x component value of the vec3
  29715. * @param y Define the y component value of the vec3
  29716. * @param z Define the z component value of the vec3
  29717. */
  29718. addFloat3(name: string, x: number, y: number, z: number): void;
  29719. /**
  29720. * Adds a vec3 to the uniform buffer.
  29721. * @param name Name of the uniform, as used in the uniform block in the shader.
  29722. * @param color Define the vec3 from a Color
  29723. */
  29724. addColor3(name: string, color: Color3): void;
  29725. /**
  29726. * Adds a vec4 to the uniform buffer.
  29727. * @param name Name of the uniform, as used in the uniform block in the shader.
  29728. * @param color Define the rgb components from a Color
  29729. * @param alpha Define the a component of the vec4
  29730. */
  29731. addColor4(name: string, color: Color3, alpha: number): void;
  29732. /**
  29733. * Adds a vec3 to the uniform buffer.
  29734. * @param name Name of the uniform, as used in the uniform block in the shader.
  29735. * @param vector Define the vec3 components from a Vector
  29736. */
  29737. addVector3(name: string, vector: Vector3): void;
  29738. /**
  29739. * Adds a Matrix 3x3 to the uniform buffer.
  29740. * @param name Name of the uniform, as used in the uniform block in the shader.
  29741. */
  29742. addMatrix3x3(name: string): void;
  29743. /**
  29744. * Adds a Matrix 2x2 to the uniform buffer.
  29745. * @param name Name of the uniform, as used in the uniform block in the shader.
  29746. */
  29747. addMatrix2x2(name: string): void;
  29748. /**
  29749. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29750. */
  29751. create(): void;
  29752. /** @hidden */
  29753. _rebuild(): void;
  29754. /**
  29755. * Updates the WebGL Uniform Buffer on the GPU.
  29756. * If the `dynamic` flag is set to true, no cache comparison is done.
  29757. * Otherwise, the buffer will be updated only if the cache differs.
  29758. */
  29759. update(): void;
  29760. /**
  29761. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29762. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29763. * @param data Define the flattened data
  29764. * @param size Define the size of the data.
  29765. */
  29766. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29767. private _valueCache;
  29768. private _cacheMatrix;
  29769. private _updateMatrix3x3ForUniform;
  29770. private _updateMatrix3x3ForEffect;
  29771. private _updateMatrix2x2ForEffect;
  29772. private _updateMatrix2x2ForUniform;
  29773. private _updateFloatForEffect;
  29774. private _updateFloatForUniform;
  29775. private _updateFloat2ForEffect;
  29776. private _updateFloat2ForUniform;
  29777. private _updateFloat3ForEffect;
  29778. private _updateFloat3ForUniform;
  29779. private _updateFloat4ForEffect;
  29780. private _updateFloat4ForUniform;
  29781. private _updateMatrixForEffect;
  29782. private _updateMatrixForUniform;
  29783. private _updateVector3ForEffect;
  29784. private _updateVector3ForUniform;
  29785. private _updateVector4ForEffect;
  29786. private _updateVector4ForUniform;
  29787. private _updateColor3ForEffect;
  29788. private _updateColor3ForUniform;
  29789. private _updateColor4ForEffect;
  29790. private _updateColor4ForUniform;
  29791. /**
  29792. * Sets a sampler uniform on the effect.
  29793. * @param name Define the name of the sampler.
  29794. * @param texture Define the texture to set in the sampler
  29795. */
  29796. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29797. /**
  29798. * Directly updates the value of the uniform in the cache AND on the GPU.
  29799. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29800. * @param data Define the flattened data
  29801. */
  29802. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29803. /**
  29804. * Binds this uniform buffer to an effect.
  29805. * @param effect Define the effect to bind the buffer to
  29806. * @param name Name of the uniform block in the shader.
  29807. */
  29808. bindToEffect(effect: Effect, name: string): void;
  29809. /**
  29810. * Disposes the uniform buffer.
  29811. */
  29812. dispose(): void;
  29813. }
  29814. }
  29815. declare module "babylonjs/Audio/analyser" {
  29816. import { Scene } from "babylonjs/scene";
  29817. /**
  29818. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29820. */
  29821. export class Analyser {
  29822. /**
  29823. * Gets or sets the smoothing
  29824. * @ignorenaming
  29825. */
  29826. SMOOTHING: number;
  29827. /**
  29828. * Gets or sets the FFT table size
  29829. * @ignorenaming
  29830. */
  29831. FFT_SIZE: number;
  29832. /**
  29833. * Gets or sets the bar graph amplitude
  29834. * @ignorenaming
  29835. */
  29836. BARGRAPHAMPLITUDE: number;
  29837. /**
  29838. * Gets or sets the position of the debug canvas
  29839. * @ignorenaming
  29840. */
  29841. DEBUGCANVASPOS: {
  29842. x: number;
  29843. y: number;
  29844. };
  29845. /**
  29846. * Gets or sets the debug canvas size
  29847. * @ignorenaming
  29848. */
  29849. DEBUGCANVASSIZE: {
  29850. width: number;
  29851. height: number;
  29852. };
  29853. private _byteFreqs;
  29854. private _byteTime;
  29855. private _floatFreqs;
  29856. private _webAudioAnalyser;
  29857. private _debugCanvas;
  29858. private _debugCanvasContext;
  29859. private _scene;
  29860. private _registerFunc;
  29861. private _audioEngine;
  29862. /**
  29863. * Creates a new analyser
  29864. * @param scene defines hosting scene
  29865. */
  29866. constructor(scene: Scene);
  29867. /**
  29868. * Get the number of data values you will have to play with for the visualization
  29869. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29870. * @returns a number
  29871. */
  29872. getFrequencyBinCount(): number;
  29873. /**
  29874. * Gets the current frequency data as a byte array
  29875. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29876. * @returns a Uint8Array
  29877. */
  29878. getByteFrequencyData(): Uint8Array;
  29879. /**
  29880. * Gets the current waveform as a byte array
  29881. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29882. * @returns a Uint8Array
  29883. */
  29884. getByteTimeDomainData(): Uint8Array;
  29885. /**
  29886. * Gets the current frequency data as a float array
  29887. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29888. * @returns a Float32Array
  29889. */
  29890. getFloatFrequencyData(): Float32Array;
  29891. /**
  29892. * Renders the debug canvas
  29893. */
  29894. drawDebugCanvas(): void;
  29895. /**
  29896. * Stops rendering the debug canvas and removes it
  29897. */
  29898. stopDebugCanvas(): void;
  29899. /**
  29900. * Connects two audio nodes
  29901. * @param inputAudioNode defines first node to connect
  29902. * @param outputAudioNode defines second node to connect
  29903. */
  29904. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29905. /**
  29906. * Releases all associated resources
  29907. */
  29908. dispose(): void;
  29909. }
  29910. }
  29911. declare module "babylonjs/Audio/audioEngine" {
  29912. import { IDisposable } from "babylonjs/scene";
  29913. import { Analyser } from "babylonjs/Audio/analyser";
  29914. import { Nullable } from "babylonjs/types";
  29915. import { Observable } from "babylonjs/Misc/observable";
  29916. /**
  29917. * This represents an audio engine and it is responsible
  29918. * to play, synchronize and analyse sounds throughout the application.
  29919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29920. */
  29921. export interface IAudioEngine extends IDisposable {
  29922. /**
  29923. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29924. */
  29925. readonly canUseWebAudio: boolean;
  29926. /**
  29927. * Gets the current AudioContext if available.
  29928. */
  29929. readonly audioContext: Nullable<AudioContext>;
  29930. /**
  29931. * The master gain node defines the global audio volume of your audio engine.
  29932. */
  29933. readonly masterGain: GainNode;
  29934. /**
  29935. * Gets whether or not mp3 are supported by your browser.
  29936. */
  29937. readonly isMP3supported: boolean;
  29938. /**
  29939. * Gets whether or not ogg are supported by your browser.
  29940. */
  29941. readonly isOGGsupported: boolean;
  29942. /**
  29943. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29944. * @ignoreNaming
  29945. */
  29946. WarnedWebAudioUnsupported: boolean;
  29947. /**
  29948. * Defines if the audio engine relies on a custom unlocked button.
  29949. * In this case, the embedded button will not be displayed.
  29950. */
  29951. useCustomUnlockedButton: boolean;
  29952. /**
  29953. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29954. */
  29955. readonly unlocked: boolean;
  29956. /**
  29957. * Event raised when audio has been unlocked on the browser.
  29958. */
  29959. onAudioUnlockedObservable: Observable<AudioEngine>;
  29960. /**
  29961. * Event raised when audio has been locked on the browser.
  29962. */
  29963. onAudioLockedObservable: Observable<AudioEngine>;
  29964. /**
  29965. * Flags the audio engine in Locked state.
  29966. * This happens due to new browser policies preventing audio to autoplay.
  29967. */
  29968. lock(): void;
  29969. /**
  29970. * Unlocks the audio engine once a user action has been done on the dom.
  29971. * This is helpful to resume play once browser policies have been satisfied.
  29972. */
  29973. unlock(): void;
  29974. }
  29975. /**
  29976. * This represents the default audio engine used in babylon.
  29977. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29979. */
  29980. export class AudioEngine implements IAudioEngine {
  29981. private _audioContext;
  29982. private _audioContextInitialized;
  29983. private _muteButton;
  29984. private _hostElement;
  29985. /**
  29986. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29987. */
  29988. canUseWebAudio: boolean;
  29989. /**
  29990. * The master gain node defines the global audio volume of your audio engine.
  29991. */
  29992. masterGain: GainNode;
  29993. /**
  29994. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29995. * @ignoreNaming
  29996. */
  29997. WarnedWebAudioUnsupported: boolean;
  29998. /**
  29999. * Gets whether or not mp3 are supported by your browser.
  30000. */
  30001. isMP3supported: boolean;
  30002. /**
  30003. * Gets whether or not ogg are supported by your browser.
  30004. */
  30005. isOGGsupported: boolean;
  30006. /**
  30007. * Gets whether audio has been unlocked on the device.
  30008. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30009. * a user interaction has happened.
  30010. */
  30011. unlocked: boolean;
  30012. /**
  30013. * Defines if the audio engine relies on a custom unlocked button.
  30014. * In this case, the embedded button will not be displayed.
  30015. */
  30016. useCustomUnlockedButton: boolean;
  30017. /**
  30018. * Event raised when audio has been unlocked on the browser.
  30019. */
  30020. onAudioUnlockedObservable: Observable<AudioEngine>;
  30021. /**
  30022. * Event raised when audio has been locked on the browser.
  30023. */
  30024. onAudioLockedObservable: Observable<AudioEngine>;
  30025. /**
  30026. * Gets the current AudioContext if available.
  30027. */
  30028. readonly audioContext: Nullable<AudioContext>;
  30029. private _connectedAnalyser;
  30030. /**
  30031. * Instantiates a new audio engine.
  30032. *
  30033. * There should be only one per page as some browsers restrict the number
  30034. * of audio contexts you can create.
  30035. * @param hostElement defines the host element where to display the mute icon if necessary
  30036. */
  30037. constructor(hostElement?: Nullable<HTMLElement>);
  30038. /**
  30039. * Flags the audio engine in Locked state.
  30040. * This happens due to new browser policies preventing audio to autoplay.
  30041. */
  30042. lock(): void;
  30043. /**
  30044. * Unlocks the audio engine once a user action has been done on the dom.
  30045. * This is helpful to resume play once browser policies have been satisfied.
  30046. */
  30047. unlock(): void;
  30048. private _resumeAudioContext;
  30049. private _initializeAudioContext;
  30050. private _tryToRun;
  30051. private _triggerRunningState;
  30052. private _triggerSuspendedState;
  30053. private _displayMuteButton;
  30054. private _moveButtonToTopLeft;
  30055. private _onResize;
  30056. private _hideMuteButton;
  30057. /**
  30058. * Destroy and release the resources associated with the audio ccontext.
  30059. */
  30060. dispose(): void;
  30061. /**
  30062. * Gets the global volume sets on the master gain.
  30063. * @returns the global volume if set or -1 otherwise
  30064. */
  30065. getGlobalVolume(): number;
  30066. /**
  30067. * Sets the global volume of your experience (sets on the master gain).
  30068. * @param newVolume Defines the new global volume of the application
  30069. */
  30070. setGlobalVolume(newVolume: number): void;
  30071. /**
  30072. * Connect the audio engine to an audio analyser allowing some amazing
  30073. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30075. * @param analyser The analyser to connect to the engine
  30076. */
  30077. connectToAnalyser(analyser: Analyser): void;
  30078. }
  30079. }
  30080. declare module "babylonjs/Loading/loadingScreen" {
  30081. /**
  30082. * Interface used to present a loading screen while loading a scene
  30083. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30084. */
  30085. export interface ILoadingScreen {
  30086. /**
  30087. * Function called to display the loading screen
  30088. */
  30089. displayLoadingUI: () => void;
  30090. /**
  30091. * Function called to hide the loading screen
  30092. */
  30093. hideLoadingUI: () => void;
  30094. /**
  30095. * Gets or sets the color to use for the background
  30096. */
  30097. loadingUIBackgroundColor: string;
  30098. /**
  30099. * Gets or sets the text to display while loading
  30100. */
  30101. loadingUIText: string;
  30102. }
  30103. /**
  30104. * Class used for the default loading screen
  30105. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30106. */
  30107. export class DefaultLoadingScreen implements ILoadingScreen {
  30108. private _renderingCanvas;
  30109. private _loadingText;
  30110. private _loadingDivBackgroundColor;
  30111. private _loadingDiv;
  30112. private _loadingTextDiv;
  30113. /** Gets or sets the logo url to use for the default loading screen */
  30114. static DefaultLogoUrl: string;
  30115. /** Gets or sets the spinner url to use for the default loading screen */
  30116. static DefaultSpinnerUrl: string;
  30117. /**
  30118. * Creates a new default loading screen
  30119. * @param _renderingCanvas defines the canvas used to render the scene
  30120. * @param _loadingText defines the default text to display
  30121. * @param _loadingDivBackgroundColor defines the default background color
  30122. */
  30123. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30124. /**
  30125. * Function called to display the loading screen
  30126. */
  30127. displayLoadingUI(): void;
  30128. /**
  30129. * Function called to hide the loading screen
  30130. */
  30131. hideLoadingUI(): void;
  30132. /**
  30133. * Gets or sets the text to display while loading
  30134. */
  30135. loadingUIText: string;
  30136. /**
  30137. * Gets or sets the color to use for the background
  30138. */
  30139. loadingUIBackgroundColor: string;
  30140. private _resizeLoadingUI;
  30141. }
  30142. }
  30143. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30144. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30145. import { Engine } from "babylonjs/Engines/engine";
  30146. import { Nullable } from "babylonjs/types";
  30147. /** @hidden */
  30148. export class WebGLPipelineContext implements IPipelineContext {
  30149. engine: Engine;
  30150. program: Nullable<WebGLProgram>;
  30151. context?: WebGLRenderingContext;
  30152. vertexShader?: WebGLShader;
  30153. fragmentShader?: WebGLShader;
  30154. isParallelCompiled: boolean;
  30155. onCompiled?: () => void;
  30156. transformFeedback?: WebGLTransformFeedback | null;
  30157. readonly isAsync: boolean;
  30158. readonly isReady: boolean;
  30159. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30160. }
  30161. }
  30162. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30163. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30164. /** @hidden */
  30165. export class WebGLDataBuffer extends DataBuffer {
  30166. private _buffer;
  30167. constructor(resource: WebGLBuffer);
  30168. readonly underlyingResource: any;
  30169. }
  30170. }
  30171. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30172. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30173. /** @hidden */
  30174. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30175. attributeProcessor(attribute: string): string;
  30176. varyingProcessor(varying: string, isFragment: boolean): string;
  30177. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30178. }
  30179. }
  30180. declare module "babylonjs/Misc/perfCounter" {
  30181. /**
  30182. * This class is used to track a performance counter which is number based.
  30183. * The user has access to many properties which give statistics of different nature.
  30184. *
  30185. * The implementer can track two kinds of Performance Counter: time and count.
  30186. * 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.
  30187. * 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.
  30188. */
  30189. export class PerfCounter {
  30190. /**
  30191. * Gets or sets a global boolean to turn on and off all the counters
  30192. */
  30193. static Enabled: boolean;
  30194. /**
  30195. * Returns the smallest value ever
  30196. */
  30197. readonly min: number;
  30198. /**
  30199. * Returns the biggest value ever
  30200. */
  30201. readonly max: number;
  30202. /**
  30203. * Returns the average value since the performance counter is running
  30204. */
  30205. readonly average: number;
  30206. /**
  30207. * Returns the average value of the last second the counter was monitored
  30208. */
  30209. readonly lastSecAverage: number;
  30210. /**
  30211. * Returns the current value
  30212. */
  30213. readonly current: number;
  30214. /**
  30215. * Gets the accumulated total
  30216. */
  30217. readonly total: number;
  30218. /**
  30219. * Gets the total value count
  30220. */
  30221. readonly count: number;
  30222. /**
  30223. * Creates a new counter
  30224. */
  30225. constructor();
  30226. /**
  30227. * Call this method to start monitoring a new frame.
  30228. * 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.
  30229. */
  30230. fetchNewFrame(): void;
  30231. /**
  30232. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30233. * @param newCount the count value to add to the monitored count
  30234. * @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.
  30235. */
  30236. addCount(newCount: number, fetchResult: boolean): void;
  30237. /**
  30238. * Start monitoring this performance counter
  30239. */
  30240. beginMonitoring(): void;
  30241. /**
  30242. * Compute the time lapsed since the previous beginMonitoring() call.
  30243. * @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
  30244. */
  30245. endMonitoring(newFrame?: boolean): void;
  30246. private _fetchResult;
  30247. private _startMonitoringTime;
  30248. private _min;
  30249. private _max;
  30250. private _average;
  30251. private _current;
  30252. private _totalValueCount;
  30253. private _totalAccumulated;
  30254. private _lastSecAverage;
  30255. private _lastSecAccumulated;
  30256. private _lastSecTime;
  30257. private _lastSecValueCount;
  30258. }
  30259. }
  30260. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30261. /**
  30262. * Interface for any object that can request an animation frame
  30263. */
  30264. export interface ICustomAnimationFrameRequester {
  30265. /**
  30266. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30267. */
  30268. renderFunction?: Function;
  30269. /**
  30270. * Called to request the next frame to render to
  30271. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30272. */
  30273. requestAnimationFrame: Function;
  30274. /**
  30275. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30276. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30277. */
  30278. requestID?: number;
  30279. }
  30280. }
  30281. declare module "babylonjs/Materials/Textures/videoTexture" {
  30282. import { Observable } from "babylonjs/Misc/observable";
  30283. import { Nullable } from "babylonjs/types";
  30284. import { Scene } from "babylonjs/scene";
  30285. import { Texture } from "babylonjs/Materials/Textures/texture";
  30286. /**
  30287. * Settings for finer control over video usage
  30288. */
  30289. export interface VideoTextureSettings {
  30290. /**
  30291. * Applies `autoplay` to video, if specified
  30292. */
  30293. autoPlay?: boolean;
  30294. /**
  30295. * Applies `loop` to video, if specified
  30296. */
  30297. loop?: boolean;
  30298. /**
  30299. * Automatically updates internal texture from video at every frame in the render loop
  30300. */
  30301. autoUpdateTexture: boolean;
  30302. /**
  30303. * Image src displayed during the video loading or until the user interacts with the video.
  30304. */
  30305. poster?: string;
  30306. }
  30307. /**
  30308. * If you want to display a video in your scene, this is the special texture for that.
  30309. * This special texture works similar to other textures, with the exception of a few parameters.
  30310. * @see https://doc.babylonjs.com/how_to/video_texture
  30311. */
  30312. export class VideoTexture extends Texture {
  30313. /**
  30314. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30315. */
  30316. readonly autoUpdateTexture: boolean;
  30317. /**
  30318. * The video instance used by the texture internally
  30319. */
  30320. readonly video: HTMLVideoElement;
  30321. private _onUserActionRequestedObservable;
  30322. /**
  30323. * Event triggerd when a dom action is required by the user to play the video.
  30324. * This happens due to recent changes in browser policies preventing video to auto start.
  30325. */
  30326. readonly onUserActionRequestedObservable: Observable<Texture>;
  30327. private _generateMipMaps;
  30328. private _engine;
  30329. private _stillImageCaptured;
  30330. private _displayingPosterTexture;
  30331. private _settings;
  30332. private _createInternalTextureOnEvent;
  30333. private _frameId;
  30334. /**
  30335. * Creates a video texture.
  30336. * If you want to display a video in your scene, this is the special texture for that.
  30337. * This special texture works similar to other textures, with the exception of a few parameters.
  30338. * @see https://doc.babylonjs.com/how_to/video_texture
  30339. * @param name optional name, will detect from video source, if not defined
  30340. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30341. * @param scene is obviously the current scene.
  30342. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30343. * @param invertY is false by default but can be used to invert video on Y axis
  30344. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30345. * @param settings allows finer control over video usage
  30346. */
  30347. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30348. private _getName;
  30349. private _getVideo;
  30350. private _createInternalTexture;
  30351. private reset;
  30352. /**
  30353. * @hidden Internal method to initiate `update`.
  30354. */
  30355. _rebuild(): void;
  30356. /**
  30357. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30358. */
  30359. update(): void;
  30360. /**
  30361. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30362. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30363. */
  30364. updateTexture(isVisible: boolean): void;
  30365. protected _updateInternalTexture: () => void;
  30366. /**
  30367. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30368. * @param url New url.
  30369. */
  30370. updateURL(url: string): void;
  30371. /**
  30372. * Dispose the texture and release its associated resources.
  30373. */
  30374. dispose(): void;
  30375. /**
  30376. * Creates a video texture straight from a stream.
  30377. * @param scene Define the scene the texture should be created in
  30378. * @param stream Define the stream the texture should be created from
  30379. * @returns The created video texture as a promise
  30380. */
  30381. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30382. /**
  30383. * Creates a video texture straight from your WebCam video feed.
  30384. * @param scene Define the scene the texture should be created in
  30385. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30386. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30387. * @returns The created video texture as a promise
  30388. */
  30389. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30390. minWidth: number;
  30391. maxWidth: number;
  30392. minHeight: number;
  30393. maxHeight: number;
  30394. deviceId: string;
  30395. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30396. /**
  30397. * Creates a video texture straight from your WebCam video feed.
  30398. * @param scene Define the scene the texture should be created in
  30399. * @param onReady Define a callback to triggered once the texture will be ready
  30400. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30401. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30402. */
  30403. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30404. minWidth: number;
  30405. maxWidth: number;
  30406. minHeight: number;
  30407. maxHeight: number;
  30408. deviceId: string;
  30409. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30410. }
  30411. }
  30412. declare module "babylonjs/Engines/engine" {
  30413. import { Observable } from "babylonjs/Misc/observable";
  30414. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30415. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30416. import { Scene } from "babylonjs/scene";
  30417. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30418. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30419. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30420. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30421. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30423. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30424. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30425. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30426. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30427. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30428. import { WebRequest } from "babylonjs/Misc/webRequest";
  30429. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30430. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30431. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30432. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30433. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30434. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30435. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30436. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30437. import { Material } from "babylonjs/Materials/material";
  30438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30439. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30440. /**
  30441. * Defines the interface used by objects containing a viewport (like a camera)
  30442. */
  30443. interface IViewportOwnerLike {
  30444. /**
  30445. * Gets or sets the viewport
  30446. */
  30447. viewport: IViewportLike;
  30448. }
  30449. /**
  30450. * Interface for attribute information associated with buffer instanciation
  30451. */
  30452. export class InstancingAttributeInfo {
  30453. /**
  30454. * Index/offset of the attribute in the vertex shader
  30455. */
  30456. index: number;
  30457. /**
  30458. * size of the attribute, 1, 2, 3 or 4
  30459. */
  30460. attributeSize: number;
  30461. /**
  30462. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30463. * default is FLOAT
  30464. */
  30465. attribyteType: number;
  30466. /**
  30467. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30468. */
  30469. normalized: boolean;
  30470. /**
  30471. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30472. */
  30473. offset: number;
  30474. /**
  30475. * Name of the GLSL attribute, for debugging purpose only
  30476. */
  30477. attributeName: string;
  30478. }
  30479. /**
  30480. * Define options used to create a depth texture
  30481. */
  30482. export class DepthTextureCreationOptions {
  30483. /** Specifies whether or not a stencil should be allocated in the texture */
  30484. generateStencil?: boolean;
  30485. /** Specifies whether or not bilinear filtering is enable on the texture */
  30486. bilinearFiltering?: boolean;
  30487. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30488. comparisonFunction?: number;
  30489. /** Specifies if the created texture is a cube texture */
  30490. isCube?: boolean;
  30491. }
  30492. /**
  30493. * Class used to describe the capabilities of the engine relatively to the current browser
  30494. */
  30495. export class EngineCapabilities {
  30496. /** Maximum textures units per fragment shader */
  30497. maxTexturesImageUnits: number;
  30498. /** Maximum texture units per vertex shader */
  30499. maxVertexTextureImageUnits: number;
  30500. /** Maximum textures units in the entire pipeline */
  30501. maxCombinedTexturesImageUnits: number;
  30502. /** Maximum texture size */
  30503. maxTextureSize: number;
  30504. /** Maximum cube texture size */
  30505. maxCubemapTextureSize: number;
  30506. /** Maximum render texture size */
  30507. maxRenderTextureSize: number;
  30508. /** Maximum number of vertex attributes */
  30509. maxVertexAttribs: number;
  30510. /** Maximum number of varyings */
  30511. maxVaryingVectors: number;
  30512. /** Maximum number of uniforms per vertex shader */
  30513. maxVertexUniformVectors: number;
  30514. /** Maximum number of uniforms per fragment shader */
  30515. maxFragmentUniformVectors: number;
  30516. /** Defines if standard derivates (dx/dy) are supported */
  30517. standardDerivatives: boolean;
  30518. /** Defines if s3tc texture compression is supported */
  30519. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30520. /** Defines if pvrtc texture compression is supported */
  30521. pvrtc: any;
  30522. /** Defines if etc1 texture compression is supported */
  30523. etc1: any;
  30524. /** Defines if etc2 texture compression is supported */
  30525. etc2: any;
  30526. /** Defines if astc texture compression is supported */
  30527. astc: any;
  30528. /** Defines if float textures are supported */
  30529. textureFloat: boolean;
  30530. /** Defines if vertex array objects are supported */
  30531. vertexArrayObject: boolean;
  30532. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30533. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30534. /** Gets the maximum level of anisotropy supported */
  30535. maxAnisotropy: number;
  30536. /** Defines if instancing is supported */
  30537. instancedArrays: boolean;
  30538. /** Defines if 32 bits indices are supported */
  30539. uintIndices: boolean;
  30540. /** Defines if high precision shaders are supported */
  30541. highPrecisionShaderSupported: boolean;
  30542. /** Defines if depth reading in the fragment shader is supported */
  30543. fragmentDepthSupported: boolean;
  30544. /** Defines if float texture linear filtering is supported*/
  30545. textureFloatLinearFiltering: boolean;
  30546. /** Defines if rendering to float textures is supported */
  30547. textureFloatRender: boolean;
  30548. /** Defines if half float textures are supported*/
  30549. textureHalfFloat: boolean;
  30550. /** Defines if half float texture linear filtering is supported*/
  30551. textureHalfFloatLinearFiltering: boolean;
  30552. /** Defines if rendering to half float textures is supported */
  30553. textureHalfFloatRender: boolean;
  30554. /** Defines if textureLOD shader command is supported */
  30555. textureLOD: boolean;
  30556. /** Defines if draw buffers extension is supported */
  30557. drawBuffersExtension: boolean;
  30558. /** Defines if depth textures are supported */
  30559. depthTextureExtension: boolean;
  30560. /** Defines if float color buffer are supported */
  30561. colorBufferFloat: boolean;
  30562. /** Gets disjoint timer query extension (null if not supported) */
  30563. timerQuery: EXT_disjoint_timer_query;
  30564. /** Defines if timestamp can be used with timer query */
  30565. canUseTimestampForTimerQuery: boolean;
  30566. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30567. multiview: any;
  30568. /** Function used to let the system compiles shaders in background */
  30569. parallelShaderCompile: {
  30570. COMPLETION_STATUS_KHR: number;
  30571. };
  30572. /** Max number of texture samples for MSAA */
  30573. maxMSAASamples: number;
  30574. }
  30575. /** Interface defining initialization parameters for Engine class */
  30576. export interface EngineOptions extends WebGLContextAttributes {
  30577. /**
  30578. * Defines if the engine should no exceed a specified device ratio
  30579. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30580. */
  30581. limitDeviceRatio?: number;
  30582. /**
  30583. * Defines if webvr should be enabled automatically
  30584. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30585. */
  30586. autoEnableWebVR?: boolean;
  30587. /**
  30588. * Defines if webgl2 should be turned off even if supported
  30589. * @see http://doc.babylonjs.com/features/webgl2
  30590. */
  30591. disableWebGL2Support?: boolean;
  30592. /**
  30593. * Defines if webaudio should be initialized as well
  30594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30595. */
  30596. audioEngine?: boolean;
  30597. /**
  30598. * Defines if animations should run using a deterministic lock step
  30599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30600. */
  30601. deterministicLockstep?: boolean;
  30602. /** Defines the maximum steps to use with deterministic lock step mode */
  30603. lockstepMaxSteps?: number;
  30604. /**
  30605. * Defines that engine should ignore context lost events
  30606. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30607. */
  30608. doNotHandleContextLost?: boolean;
  30609. /**
  30610. * Defines that engine should ignore modifying touch action attribute and style
  30611. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30612. */
  30613. doNotHandleTouchAction?: boolean;
  30614. /**
  30615. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30616. */
  30617. useHighPrecisionFloats?: boolean;
  30618. }
  30619. /**
  30620. * Defines the interface used by display changed events
  30621. */
  30622. export interface IDisplayChangedEventArgs {
  30623. /** Gets the vrDisplay object (if any) */
  30624. vrDisplay: Nullable<any>;
  30625. /** Gets a boolean indicating if webVR is supported */
  30626. vrSupported: boolean;
  30627. }
  30628. /**
  30629. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30630. */
  30631. export class Engine {
  30632. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30633. static ExceptionList: ({
  30634. key: string;
  30635. capture: string;
  30636. captureConstraint: number;
  30637. targets: string[];
  30638. } | {
  30639. key: string;
  30640. capture: null;
  30641. captureConstraint: null;
  30642. targets: string[];
  30643. })[];
  30644. /** Gets the list of created engines */
  30645. static readonly Instances: Engine[];
  30646. /**
  30647. * Gets the latest created engine
  30648. */
  30649. static readonly LastCreatedEngine: Nullable<Engine>;
  30650. /**
  30651. * Gets the latest created scene
  30652. */
  30653. static readonly LastCreatedScene: Nullable<Scene>;
  30654. /**
  30655. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30656. * @param flag defines which part of the materials must be marked as dirty
  30657. * @param predicate defines a predicate used to filter which materials should be affected
  30658. */
  30659. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30660. /** @hidden */
  30661. static _TextureLoaders: IInternalTextureLoader[];
  30662. /** Defines that alpha blending is disabled */
  30663. static readonly ALPHA_DISABLE: number;
  30664. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30665. static readonly ALPHA_ADD: number;
  30666. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30667. static readonly ALPHA_COMBINE: number;
  30668. /** Defines that alpha blending to DEST - SRC * DEST */
  30669. static readonly ALPHA_SUBTRACT: number;
  30670. /** Defines that alpha blending to SRC * DEST */
  30671. static readonly ALPHA_MULTIPLY: number;
  30672. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30673. static readonly ALPHA_MAXIMIZED: number;
  30674. /** Defines that alpha blending to SRC + DEST */
  30675. static readonly ALPHA_ONEONE: number;
  30676. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30677. static readonly ALPHA_PREMULTIPLIED: number;
  30678. /**
  30679. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30680. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30681. */
  30682. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30683. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30684. static readonly ALPHA_INTERPOLATE: number;
  30685. /**
  30686. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30687. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30688. */
  30689. static readonly ALPHA_SCREENMODE: number;
  30690. /** Defines that the ressource is not delayed*/
  30691. static readonly DELAYLOADSTATE_NONE: number;
  30692. /** Defines that the ressource was successfully delay loaded */
  30693. static readonly DELAYLOADSTATE_LOADED: number;
  30694. /** Defines that the ressource is currently delay loading */
  30695. static readonly DELAYLOADSTATE_LOADING: number;
  30696. /** Defines that the ressource is delayed and has not started loading */
  30697. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30699. static readonly NEVER: number;
  30700. /** 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 */
  30701. static readonly ALWAYS: number;
  30702. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30703. static readonly LESS: number;
  30704. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30705. static readonly EQUAL: number;
  30706. /** 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 */
  30707. static readonly LEQUAL: number;
  30708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30709. static readonly GREATER: number;
  30710. /** 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 */
  30711. static readonly GEQUAL: number;
  30712. /** 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 */
  30713. static readonly NOTEQUAL: number;
  30714. /** Passed to stencilOperation to specify that stencil value must be kept */
  30715. static readonly KEEP: number;
  30716. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30717. static readonly REPLACE: number;
  30718. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30719. static readonly INCR: number;
  30720. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30721. static readonly DECR: number;
  30722. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30723. static readonly INVERT: number;
  30724. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30725. static readonly INCR_WRAP: number;
  30726. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30727. static readonly DECR_WRAP: number;
  30728. /** Texture is not repeating outside of 0..1 UVs */
  30729. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30730. /** Texture is repeating outside of 0..1 UVs */
  30731. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30732. /** Texture is repeating and mirrored */
  30733. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30734. /** ALPHA */
  30735. static readonly TEXTUREFORMAT_ALPHA: number;
  30736. /** LUMINANCE */
  30737. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30738. /** LUMINANCE_ALPHA */
  30739. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30740. /** RGB */
  30741. static readonly TEXTUREFORMAT_RGB: number;
  30742. /** RGBA */
  30743. static readonly TEXTUREFORMAT_RGBA: number;
  30744. /** RED */
  30745. static readonly TEXTUREFORMAT_RED: number;
  30746. /** RED (2nd reference) */
  30747. static readonly TEXTUREFORMAT_R: number;
  30748. /** RG */
  30749. static readonly TEXTUREFORMAT_RG: number;
  30750. /** RED_INTEGER */
  30751. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30752. /** RED_INTEGER (2nd reference) */
  30753. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30754. /** RG_INTEGER */
  30755. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30756. /** RGB_INTEGER */
  30757. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30758. /** RGBA_INTEGER */
  30759. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30760. /** UNSIGNED_BYTE */
  30761. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30762. /** UNSIGNED_BYTE (2nd reference) */
  30763. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30764. /** FLOAT */
  30765. static readonly TEXTURETYPE_FLOAT: number;
  30766. /** HALF_FLOAT */
  30767. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30768. /** BYTE */
  30769. static readonly TEXTURETYPE_BYTE: number;
  30770. /** SHORT */
  30771. static readonly TEXTURETYPE_SHORT: number;
  30772. /** UNSIGNED_SHORT */
  30773. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30774. /** INT */
  30775. static readonly TEXTURETYPE_INT: number;
  30776. /** UNSIGNED_INT */
  30777. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30778. /** UNSIGNED_SHORT_4_4_4_4 */
  30779. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30780. /** UNSIGNED_SHORT_5_5_5_1 */
  30781. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30782. /** UNSIGNED_SHORT_5_6_5 */
  30783. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30784. /** UNSIGNED_INT_2_10_10_10_REV */
  30785. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30786. /** UNSIGNED_INT_24_8 */
  30787. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30788. /** UNSIGNED_INT_10F_11F_11F_REV */
  30789. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30790. /** UNSIGNED_INT_5_9_9_9_REV */
  30791. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30792. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30793. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30794. /** nearest is mag = nearest and min = nearest and mip = linear */
  30795. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30796. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30797. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30798. /** Trilinear is mag = linear and min = linear and mip = linear */
  30799. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30800. /** nearest is mag = nearest and min = nearest and mip = linear */
  30801. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30804. /** Trilinear is mag = linear and min = linear and mip = linear */
  30805. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30806. /** mag = nearest and min = nearest and mip = nearest */
  30807. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30808. /** mag = nearest and min = linear and mip = nearest */
  30809. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30810. /** mag = nearest and min = linear and mip = linear */
  30811. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30812. /** mag = nearest and min = linear and mip = none */
  30813. static readonly TEXTURE_NEAREST_LINEAR: number;
  30814. /** mag = nearest and min = nearest and mip = none */
  30815. static readonly TEXTURE_NEAREST_NEAREST: number;
  30816. /** mag = linear and min = nearest and mip = nearest */
  30817. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30818. /** mag = linear and min = nearest and mip = linear */
  30819. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30820. /** mag = linear and min = linear and mip = none */
  30821. static readonly TEXTURE_LINEAR_LINEAR: number;
  30822. /** mag = linear and min = nearest and mip = none */
  30823. static readonly TEXTURE_LINEAR_NEAREST: number;
  30824. /** Explicit coordinates mode */
  30825. static readonly TEXTURE_EXPLICIT_MODE: number;
  30826. /** Spherical coordinates mode */
  30827. static readonly TEXTURE_SPHERICAL_MODE: number;
  30828. /** Planar coordinates mode */
  30829. static readonly TEXTURE_PLANAR_MODE: number;
  30830. /** Cubic coordinates mode */
  30831. static readonly TEXTURE_CUBIC_MODE: number;
  30832. /** Projection coordinates mode */
  30833. static readonly TEXTURE_PROJECTION_MODE: number;
  30834. /** Skybox coordinates mode */
  30835. static readonly TEXTURE_SKYBOX_MODE: number;
  30836. /** Inverse Cubic coordinates mode */
  30837. static readonly TEXTURE_INVCUBIC_MODE: number;
  30838. /** Equirectangular coordinates mode */
  30839. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30840. /** Equirectangular Fixed coordinates mode */
  30841. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30842. /** Equirectangular Fixed Mirrored coordinates mode */
  30843. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30844. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30845. static readonly SCALEMODE_FLOOR: number;
  30846. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30847. static readonly SCALEMODE_NEAREST: number;
  30848. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30849. static readonly SCALEMODE_CEILING: number;
  30850. /**
  30851. * Returns the current npm package of the sdk
  30852. */
  30853. static readonly NpmPackage: string;
  30854. /**
  30855. * Returns the current version of the framework
  30856. */
  30857. static readonly Version: string;
  30858. /**
  30859. * Returns a string describing the current engine
  30860. */
  30861. readonly description: string;
  30862. /**
  30863. * Gets or sets the epsilon value used by collision engine
  30864. */
  30865. static CollisionsEpsilon: number;
  30866. /**
  30867. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30868. */
  30869. static ShadersRepository: string;
  30870. /**
  30871. * Method called to create the default loading screen.
  30872. * This can be overriden in your own app.
  30873. * @param canvas The rendering canvas element
  30874. * @returns The loading screen
  30875. */
  30876. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30877. /**
  30878. * Method called to create the default rescale post process on each engine.
  30879. */
  30880. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30881. /** @hidden */
  30882. _shaderProcessor: IShaderProcessor;
  30883. /**
  30884. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30885. */
  30886. forcePOTTextures: boolean;
  30887. /**
  30888. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30889. */
  30890. isFullscreen: boolean;
  30891. /**
  30892. * Gets a boolean indicating if the pointer is currently locked
  30893. */
  30894. isPointerLock: boolean;
  30895. /**
  30896. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30897. */
  30898. cullBackFaces: boolean;
  30899. /**
  30900. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30901. */
  30902. renderEvenInBackground: boolean;
  30903. /**
  30904. * Gets or sets a boolean indicating that cache can be kept between frames
  30905. */
  30906. preventCacheWipeBetweenFrames: boolean;
  30907. /**
  30908. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30909. **/
  30910. enableOfflineSupport: boolean;
  30911. /**
  30912. * 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)
  30913. **/
  30914. disableManifestCheck: boolean;
  30915. /**
  30916. * Gets the list of created scenes
  30917. */
  30918. scenes: Scene[];
  30919. /**
  30920. * Event raised when a new scene is created
  30921. */
  30922. onNewSceneAddedObservable: Observable<Scene>;
  30923. /**
  30924. * Gets the list of created postprocesses
  30925. */
  30926. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30927. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30928. validateShaderPrograms: boolean;
  30929. /**
  30930. * Observable event triggered each time the rendering canvas is resized
  30931. */
  30932. onResizeObservable: Observable<Engine>;
  30933. /**
  30934. * Observable event triggered each time the canvas loses focus
  30935. */
  30936. onCanvasBlurObservable: Observable<Engine>;
  30937. /**
  30938. * Observable event triggered each time the canvas gains focus
  30939. */
  30940. onCanvasFocusObservable: Observable<Engine>;
  30941. /**
  30942. * Observable event triggered each time the canvas receives pointerout event
  30943. */
  30944. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30945. /**
  30946. * Observable event triggered before each texture is initialized
  30947. */
  30948. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30949. /**
  30950. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30951. */
  30952. disableUniformBuffers: boolean;
  30953. /** @hidden */
  30954. _uniformBuffers: UniformBuffer[];
  30955. /**
  30956. * Gets a boolean indicating that the engine supports uniform buffers
  30957. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30958. */
  30959. readonly supportsUniformBuffers: boolean;
  30960. /**
  30961. * Observable raised when the engine begins a new frame
  30962. */
  30963. onBeginFrameObservable: Observable<Engine>;
  30964. /**
  30965. * If set, will be used to request the next animation frame for the render loop
  30966. */
  30967. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30968. /**
  30969. * Observable raised when the engine ends the current frame
  30970. */
  30971. onEndFrameObservable: Observable<Engine>;
  30972. /**
  30973. * Observable raised when the engine is about to compile a shader
  30974. */
  30975. onBeforeShaderCompilationObservable: Observable<Engine>;
  30976. /**
  30977. * Observable raised when the engine has jsut compiled a shader
  30978. */
  30979. onAfterShaderCompilationObservable: Observable<Engine>;
  30980. /** @hidden */
  30981. _gl: WebGLRenderingContext;
  30982. private _renderingCanvas;
  30983. private _windowIsBackground;
  30984. private _webGLVersion;
  30985. protected _highPrecisionShadersAllowed: boolean;
  30986. /** @hidden */
  30987. readonly _shouldUseHighPrecisionShader: boolean;
  30988. /**
  30989. * Gets a boolean indicating that only power of 2 textures are supported
  30990. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30991. */
  30992. readonly needPOTTextures: boolean;
  30993. /** @hidden */
  30994. _badOS: boolean;
  30995. /** @hidden */
  30996. _badDesktopOS: boolean;
  30997. /**
  30998. * Gets the audio engine
  30999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31000. * @ignorenaming
  31001. */
  31002. static audioEngine: IAudioEngine;
  31003. /**
  31004. * Default AudioEngine factory responsible of creating the Audio Engine.
  31005. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31006. */
  31007. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31008. /**
  31009. * Default offline support factory responsible of creating a tool used to store data locally.
  31010. * By default, this will create a Database object if the workload has been embedded.
  31011. */
  31012. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31013. private _onFocus;
  31014. private _onBlur;
  31015. private _onCanvasPointerOut;
  31016. private _onCanvasBlur;
  31017. private _onCanvasFocus;
  31018. private _onFullscreenChange;
  31019. private _onPointerLockChange;
  31020. private _hardwareScalingLevel;
  31021. /** @hidden */
  31022. _caps: EngineCapabilities;
  31023. private _pointerLockRequested;
  31024. private _isStencilEnable;
  31025. private _colorWrite;
  31026. private _loadingScreen;
  31027. /** @hidden */
  31028. _drawCalls: PerfCounter;
  31029. private _glVersion;
  31030. private _glRenderer;
  31031. private _glVendor;
  31032. private _videoTextureSupported;
  31033. private _renderingQueueLaunched;
  31034. private _activeRenderLoops;
  31035. private _deterministicLockstep;
  31036. private _lockstepMaxSteps;
  31037. /**
  31038. * Observable signaled when a context lost event is raised
  31039. */
  31040. onContextLostObservable: Observable<Engine>;
  31041. /**
  31042. * Observable signaled when a context restored event is raised
  31043. */
  31044. onContextRestoredObservable: Observable<Engine>;
  31045. private _onContextLost;
  31046. private _onContextRestored;
  31047. private _contextWasLost;
  31048. /** @hidden */
  31049. _doNotHandleContextLost: boolean;
  31050. /**
  31051. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31053. */
  31054. doNotHandleContextLost: boolean;
  31055. private _performanceMonitor;
  31056. private _fps;
  31057. private _deltaTime;
  31058. /**
  31059. * Turn this value on if you want to pause FPS computation when in background
  31060. */
  31061. disablePerformanceMonitorInBackground: boolean;
  31062. /**
  31063. * Gets the performance monitor attached to this engine
  31064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31065. */
  31066. readonly performanceMonitor: PerformanceMonitor;
  31067. /**
  31068. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31069. */
  31070. disableVertexArrayObjects: boolean;
  31071. /** @hidden */
  31072. protected _depthCullingState: _DepthCullingState;
  31073. /** @hidden */
  31074. protected _stencilState: _StencilState;
  31075. /** @hidden */
  31076. protected _alphaState: _AlphaState;
  31077. /** @hidden */
  31078. protected _alphaMode: number;
  31079. /** @hidden */
  31080. _internalTexturesCache: InternalTexture[];
  31081. /** @hidden */
  31082. protected _activeChannel: number;
  31083. private _currentTextureChannel;
  31084. /** @hidden */
  31085. protected _boundTexturesCache: {
  31086. [key: string]: Nullable<InternalTexture>;
  31087. };
  31088. /** @hidden */
  31089. protected _currentEffect: Nullable<Effect>;
  31090. /** @hidden */
  31091. protected _currentProgram: Nullable<WebGLProgram>;
  31092. private _compiledEffects;
  31093. private _vertexAttribArraysEnabled;
  31094. /** @hidden */
  31095. protected _cachedViewport: Nullable<IViewportLike>;
  31096. private _cachedVertexArrayObject;
  31097. /** @hidden */
  31098. protected _cachedVertexBuffers: any;
  31099. /** @hidden */
  31100. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31101. /** @hidden */
  31102. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31103. /** @hidden */
  31104. _currentRenderTarget: Nullable<InternalTexture>;
  31105. private _uintIndicesCurrentlySet;
  31106. private _currentBoundBuffer;
  31107. /** @hidden */
  31108. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31109. private _currentBufferPointers;
  31110. private _currentInstanceLocations;
  31111. private _currentInstanceBuffers;
  31112. private _textureUnits;
  31113. /** @hidden */
  31114. _workingCanvas: Nullable<HTMLCanvasElement>;
  31115. /** @hidden */
  31116. _workingContext: Nullable<CanvasRenderingContext2D>;
  31117. private _rescalePostProcess;
  31118. private _dummyFramebuffer;
  31119. private _externalData;
  31120. /** @hidden */
  31121. _bindedRenderFunction: any;
  31122. private _vaoRecordInProgress;
  31123. private _mustWipeVertexAttributes;
  31124. private _emptyTexture;
  31125. private _emptyCubeTexture;
  31126. private _emptyTexture3D;
  31127. /** @hidden */
  31128. _frameHandler: number;
  31129. private _nextFreeTextureSlots;
  31130. private _maxSimultaneousTextures;
  31131. private _activeRequests;
  31132. private _texturesSupported;
  31133. /** @hidden */
  31134. _textureFormatInUse: Nullable<string>;
  31135. /**
  31136. * Gets the list of texture formats supported
  31137. */
  31138. readonly texturesSupported: Array<string>;
  31139. /**
  31140. * Gets the list of texture formats in use
  31141. */
  31142. readonly textureFormatInUse: Nullable<string>;
  31143. /**
  31144. * Gets the current viewport
  31145. */
  31146. readonly currentViewport: Nullable<IViewportLike>;
  31147. /**
  31148. * Gets the default empty texture
  31149. */
  31150. readonly emptyTexture: InternalTexture;
  31151. /**
  31152. * Gets the default empty 3D texture
  31153. */
  31154. readonly emptyTexture3D: InternalTexture;
  31155. /**
  31156. * Gets the default empty cube texture
  31157. */
  31158. readonly emptyCubeTexture: InternalTexture;
  31159. /**
  31160. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31161. */
  31162. readonly premultipliedAlpha: boolean;
  31163. /**
  31164. * Creates a new engine
  31165. * @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
  31166. * @param antialias defines enable antialiasing (default: false)
  31167. * @param options defines further options to be sent to the getContext() function
  31168. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31169. */
  31170. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31171. /**
  31172. * Initializes a webVR display and starts listening to display change events
  31173. * The onVRDisplayChangedObservable will be notified upon these changes
  31174. * @returns The onVRDisplayChangedObservable
  31175. */
  31176. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31177. /** @hidden */
  31178. _prepareVRComponent(): void;
  31179. /** @hidden */
  31180. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31181. /** @hidden */
  31182. _submitVRFrame(): void;
  31183. /**
  31184. * Call this function to leave webVR mode
  31185. * Will do nothing if webVR is not supported or if there is no webVR device
  31186. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31187. */
  31188. disableVR(): void;
  31189. /**
  31190. * Gets a boolean indicating that the system is in VR mode and is presenting
  31191. * @returns true if VR mode is engaged
  31192. */
  31193. isVRPresenting(): boolean;
  31194. /** @hidden */
  31195. _requestVRFrame(): void;
  31196. private _disableTouchAction;
  31197. private _rebuildInternalTextures;
  31198. private _rebuildEffects;
  31199. /**
  31200. * Gets a boolean indicating if all created effects are ready
  31201. * @returns true if all effects are ready
  31202. */
  31203. areAllEffectsReady(): boolean;
  31204. private _rebuildBuffers;
  31205. private _initGLContext;
  31206. /**
  31207. * Gets version of the current webGL context
  31208. */
  31209. readonly webGLVersion: number;
  31210. /**
  31211. * Gets a string idenfifying the name of the class
  31212. * @returns "Engine" string
  31213. */
  31214. getClassName(): string;
  31215. /**
  31216. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31217. */
  31218. readonly isStencilEnable: boolean;
  31219. /** @hidden */
  31220. _prepareWorkingCanvas(): void;
  31221. /**
  31222. * Reset the texture cache to empty state
  31223. */
  31224. resetTextureCache(): void;
  31225. /**
  31226. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31228. * @returns true if engine is in deterministic lock step mode
  31229. */
  31230. isDeterministicLockStep(): boolean;
  31231. /**
  31232. * Gets the max steps when engine is running in deterministic lock step
  31233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31234. * @returns the max steps
  31235. */
  31236. getLockstepMaxSteps(): number;
  31237. /**
  31238. * Gets an object containing information about the current webGL context
  31239. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31240. */
  31241. getGlInfo(): {
  31242. vendor: string;
  31243. renderer: string;
  31244. version: string;
  31245. };
  31246. /**
  31247. * Gets current aspect ratio
  31248. * @param viewportOwner defines the camera to use to get the aspect ratio
  31249. * @param useScreen defines if screen size must be used (or the current render target if any)
  31250. * @returns a number defining the aspect ratio
  31251. */
  31252. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31253. /**
  31254. * Gets current screen aspect ratio
  31255. * @returns a number defining the aspect ratio
  31256. */
  31257. getScreenAspectRatio(): number;
  31258. /**
  31259. * Gets the current render width
  31260. * @param useScreen defines if screen size must be used (or the current render target if any)
  31261. * @returns a number defining the current render width
  31262. */
  31263. getRenderWidth(useScreen?: boolean): number;
  31264. /**
  31265. * Gets the current render height
  31266. * @param useScreen defines if screen size must be used (or the current render target if any)
  31267. * @returns a number defining the current render height
  31268. */
  31269. getRenderHeight(useScreen?: boolean): number;
  31270. /**
  31271. * Gets the HTML canvas attached with the current webGL context
  31272. * @returns a HTML canvas
  31273. */
  31274. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31275. /**
  31276. * Gets host window
  31277. * @returns the host window object
  31278. */
  31279. getHostWindow(): Window;
  31280. /**
  31281. * Gets host document
  31282. * @returns the host document object
  31283. */
  31284. getHostDocument(): Document;
  31285. /**
  31286. * Gets the client rect of the HTML canvas attached with the current webGL context
  31287. * @returns a client rectanglee
  31288. */
  31289. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31290. /**
  31291. * Defines the hardware scaling level.
  31292. * By default the hardware scaling level is computed from the window device ratio.
  31293. * 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.
  31294. * @param level defines the level to use
  31295. */
  31296. setHardwareScalingLevel(level: number): void;
  31297. /**
  31298. * Gets the current hardware scaling level.
  31299. * By default the hardware scaling level is computed from the window device ratio.
  31300. * 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.
  31301. * @returns a number indicating the current hardware scaling level
  31302. */
  31303. getHardwareScalingLevel(): number;
  31304. /**
  31305. * Gets the list of loaded textures
  31306. * @returns an array containing all loaded textures
  31307. */
  31308. getLoadedTexturesCache(): InternalTexture[];
  31309. /**
  31310. * Gets the object containing all engine capabilities
  31311. * @returns the EngineCapabilities object
  31312. */
  31313. getCaps(): EngineCapabilities;
  31314. /**
  31315. * Gets the current depth function
  31316. * @returns a number defining the depth function
  31317. */
  31318. getDepthFunction(): Nullable<number>;
  31319. /**
  31320. * Sets the current depth function
  31321. * @param depthFunc defines the function to use
  31322. */
  31323. setDepthFunction(depthFunc: number): void;
  31324. /**
  31325. * Sets the current depth function to GREATER
  31326. */
  31327. setDepthFunctionToGreater(): void;
  31328. /**
  31329. * Sets the current depth function to GEQUAL
  31330. */
  31331. setDepthFunctionToGreaterOrEqual(): void;
  31332. /**
  31333. * Sets the current depth function to LESS
  31334. */
  31335. setDepthFunctionToLess(): void;
  31336. private _cachedStencilBuffer;
  31337. private _cachedStencilFunction;
  31338. private _cachedStencilMask;
  31339. private _cachedStencilOperationPass;
  31340. private _cachedStencilOperationFail;
  31341. private _cachedStencilOperationDepthFail;
  31342. private _cachedStencilReference;
  31343. /**
  31344. * Caches the the state of the stencil buffer
  31345. */
  31346. cacheStencilState(): void;
  31347. /**
  31348. * Restores the state of the stencil buffer
  31349. */
  31350. restoreStencilState(): void;
  31351. /**
  31352. * Sets the current depth function to LEQUAL
  31353. */
  31354. setDepthFunctionToLessOrEqual(): void;
  31355. /**
  31356. * Gets a boolean indicating if stencil buffer is enabled
  31357. * @returns the current stencil buffer state
  31358. */
  31359. getStencilBuffer(): boolean;
  31360. /**
  31361. * Enable or disable the stencil buffer
  31362. * @param enable defines if the stencil buffer must be enabled or disabled
  31363. */
  31364. setStencilBuffer(enable: boolean): void;
  31365. /**
  31366. * Gets the current stencil mask
  31367. * @returns a number defining the new stencil mask to use
  31368. */
  31369. getStencilMask(): number;
  31370. /**
  31371. * Sets the current stencil mask
  31372. * @param mask defines the new stencil mask to use
  31373. */
  31374. setStencilMask(mask: number): void;
  31375. /**
  31376. * Gets the current stencil function
  31377. * @returns a number defining the stencil function to use
  31378. */
  31379. getStencilFunction(): number;
  31380. /**
  31381. * Gets the current stencil reference value
  31382. * @returns a number defining the stencil reference value to use
  31383. */
  31384. getStencilFunctionReference(): number;
  31385. /**
  31386. * Gets the current stencil mask
  31387. * @returns a number defining the stencil mask to use
  31388. */
  31389. getStencilFunctionMask(): number;
  31390. /**
  31391. * Sets the current stencil function
  31392. * @param stencilFunc defines the new stencil function to use
  31393. */
  31394. setStencilFunction(stencilFunc: number): void;
  31395. /**
  31396. * Sets the current stencil reference
  31397. * @param reference defines the new stencil reference to use
  31398. */
  31399. setStencilFunctionReference(reference: number): void;
  31400. /**
  31401. * Sets the current stencil mask
  31402. * @param mask defines the new stencil mask to use
  31403. */
  31404. setStencilFunctionMask(mask: number): void;
  31405. /**
  31406. * Gets the current stencil operation when stencil fails
  31407. * @returns a number defining stencil operation to use when stencil fails
  31408. */
  31409. getStencilOperationFail(): number;
  31410. /**
  31411. * Gets the current stencil operation when depth fails
  31412. * @returns a number defining stencil operation to use when depth fails
  31413. */
  31414. getStencilOperationDepthFail(): number;
  31415. /**
  31416. * Gets the current stencil operation when stencil passes
  31417. * @returns a number defining stencil operation to use when stencil passes
  31418. */
  31419. getStencilOperationPass(): number;
  31420. /**
  31421. * Sets the stencil operation to use when stencil fails
  31422. * @param operation defines the stencil operation to use when stencil fails
  31423. */
  31424. setStencilOperationFail(operation: number): void;
  31425. /**
  31426. * Sets the stencil operation to use when depth fails
  31427. * @param operation defines the stencil operation to use when depth fails
  31428. */
  31429. setStencilOperationDepthFail(operation: number): void;
  31430. /**
  31431. * Sets the stencil operation to use when stencil passes
  31432. * @param operation defines the stencil operation to use when stencil passes
  31433. */
  31434. setStencilOperationPass(operation: number): void;
  31435. /**
  31436. * Sets a boolean indicating if the dithering state is enabled or disabled
  31437. * @param value defines the dithering state
  31438. */
  31439. setDitheringState(value: boolean): void;
  31440. /**
  31441. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31442. * @param value defines the rasterizer state
  31443. */
  31444. setRasterizerState(value: boolean): void;
  31445. /**
  31446. * stop executing a render loop function and remove it from the execution array
  31447. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31448. */
  31449. stopRenderLoop(renderFunction?: () => void): void;
  31450. /** @hidden */
  31451. _renderLoop(): void;
  31452. /**
  31453. * Register and execute a render loop. The engine can have more than one render function
  31454. * @param renderFunction defines the function to continuously execute
  31455. */
  31456. runRenderLoop(renderFunction: () => void): void;
  31457. /**
  31458. * Toggle full screen mode
  31459. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31460. */
  31461. switchFullscreen(requestPointerLock: boolean): void;
  31462. /**
  31463. * Enters full screen mode
  31464. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31465. */
  31466. enterFullscreen(requestPointerLock: boolean): void;
  31467. /**
  31468. * Exits full screen mode
  31469. */
  31470. exitFullscreen(): void;
  31471. /**
  31472. * Enters Pointerlock mode
  31473. */
  31474. enterPointerlock(): void;
  31475. /**
  31476. * Exits Pointerlock mode
  31477. */
  31478. exitPointerlock(): void;
  31479. /**
  31480. * Clear the current render buffer or the current render target (if any is set up)
  31481. * @param color defines the color to use
  31482. * @param backBuffer defines if the back buffer must be cleared
  31483. * @param depth defines if the depth buffer must be cleared
  31484. * @param stencil defines if the stencil buffer must be cleared
  31485. */
  31486. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31487. /**
  31488. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31489. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31490. * @param y defines the y-coordinate of the corner of the clear rectangle
  31491. * @param width defines the width of the clear rectangle
  31492. * @param height defines the height of the clear rectangle
  31493. * @param clearColor defines the clear color
  31494. */
  31495. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31496. /**
  31497. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31498. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31499. * @param y defines the y-coordinate of the corner of the clear rectangle
  31500. * @param width defines the width of the clear rectangle
  31501. * @param height defines the height of the clear rectangle
  31502. */
  31503. enableScissor(x: number, y: number, width: number, height: number): void;
  31504. /**
  31505. * Disable previously set scissor test rectangle
  31506. */
  31507. disableScissor(): void;
  31508. private _viewportCached;
  31509. /** @hidden */
  31510. _viewport(x: number, y: number, width: number, height: number): void;
  31511. /**
  31512. * Set the WebGL's viewport
  31513. * @param viewport defines the viewport element to be used
  31514. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31515. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31516. */
  31517. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31518. /**
  31519. * Directly set the WebGL Viewport
  31520. * @param x defines the x coordinate of the viewport (in screen space)
  31521. * @param y defines the y coordinate of the viewport (in screen space)
  31522. * @param width defines the width of the viewport (in screen space)
  31523. * @param height defines the height of the viewport (in screen space)
  31524. * @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
  31525. */
  31526. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31527. /**
  31528. * Begin a new frame
  31529. */
  31530. beginFrame(): void;
  31531. /**
  31532. * Enf the current frame
  31533. */
  31534. endFrame(): void;
  31535. /**
  31536. * Resize the view according to the canvas' size
  31537. */
  31538. resize(): void;
  31539. /**
  31540. * Force a specific size of the canvas
  31541. * @param width defines the new canvas' width
  31542. * @param height defines the new canvas' height
  31543. */
  31544. setSize(width: number, height: number): void;
  31545. /**
  31546. * Binds the frame buffer to the specified texture.
  31547. * @param texture The texture to render to or null for the default canvas
  31548. * @param faceIndex The face of the texture to render to in case of cube texture
  31549. * @param requiredWidth The width of the target to render to
  31550. * @param requiredHeight The height of the target to render to
  31551. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31552. * @param depthStencilTexture The depth stencil texture to use to render
  31553. * @param lodLevel defines le lod level to bind to the frame buffer
  31554. */
  31555. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31556. /** @hidden */
  31557. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31558. /**
  31559. * Unbind the current render target texture from the webGL context
  31560. * @param texture defines the render target texture to unbind
  31561. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31562. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31563. */
  31564. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31565. /**
  31566. * Force the mipmap generation for the given render target texture
  31567. * @param texture defines the render target texture to use
  31568. */
  31569. generateMipMapsForCubemap(texture: InternalTexture): void;
  31570. /**
  31571. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31572. */
  31573. flushFramebuffer(): void;
  31574. /**
  31575. * Unbind the current render target and bind the default framebuffer
  31576. */
  31577. restoreDefaultFramebuffer(): void;
  31578. /**
  31579. * Create an uniform buffer
  31580. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31581. * @param elements defines the content of the uniform buffer
  31582. * @returns the webGL uniform buffer
  31583. */
  31584. createUniformBuffer(elements: FloatArray): DataBuffer;
  31585. /**
  31586. * Create a dynamic uniform buffer
  31587. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31588. * @param elements defines the content of the uniform buffer
  31589. * @returns the webGL uniform buffer
  31590. */
  31591. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31592. /**
  31593. * Update an existing uniform buffer
  31594. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31595. * @param uniformBuffer defines the target uniform buffer
  31596. * @param elements defines the content to update
  31597. * @param offset defines the offset in the uniform buffer where update should start
  31598. * @param count defines the size of the data to update
  31599. */
  31600. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31601. private _resetVertexBufferBinding;
  31602. /**
  31603. * Creates a vertex buffer
  31604. * @param data the data for the vertex buffer
  31605. * @returns the new WebGL static buffer
  31606. */
  31607. createVertexBuffer(data: DataArray): DataBuffer;
  31608. /**
  31609. * Creates a dynamic vertex buffer
  31610. * @param data the data for the dynamic vertex buffer
  31611. * @returns the new WebGL dynamic buffer
  31612. */
  31613. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31614. /**
  31615. * Update a dynamic index buffer
  31616. * @param indexBuffer defines the target index buffer
  31617. * @param indices defines the data to update
  31618. * @param offset defines the offset in the target index buffer where update should start
  31619. */
  31620. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31621. /**
  31622. * Updates a dynamic vertex buffer.
  31623. * @param vertexBuffer the vertex buffer to update
  31624. * @param data the data used to update the vertex buffer
  31625. * @param byteOffset the byte offset of the data
  31626. * @param byteLength the byte length of the data
  31627. */
  31628. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31629. private _resetIndexBufferBinding;
  31630. /**
  31631. * Creates a new index buffer
  31632. * @param indices defines the content of the index buffer
  31633. * @param updatable defines if the index buffer must be updatable
  31634. * @returns a new webGL buffer
  31635. */
  31636. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31637. /**
  31638. * Bind a webGL buffer to the webGL context
  31639. * @param buffer defines the buffer to bind
  31640. */
  31641. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31642. /**
  31643. * Bind an uniform buffer to the current webGL context
  31644. * @param buffer defines the buffer to bind
  31645. */
  31646. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31647. /**
  31648. * Bind a buffer to the current webGL context at a given location
  31649. * @param buffer defines the buffer to bind
  31650. * @param location defines the index where to bind the buffer
  31651. */
  31652. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31653. /**
  31654. * Bind a specific block at a given index in a specific shader program
  31655. * @param pipelineContext defines the pipeline context to use
  31656. * @param blockName defines the block name
  31657. * @param index defines the index where to bind the block
  31658. */
  31659. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31660. private bindIndexBuffer;
  31661. private bindBuffer;
  31662. /**
  31663. * update the bound buffer with the given data
  31664. * @param data defines the data to update
  31665. */
  31666. updateArrayBuffer(data: Float32Array): void;
  31667. private _vertexAttribPointer;
  31668. private _bindIndexBufferWithCache;
  31669. private _bindVertexBuffersAttributes;
  31670. /**
  31671. * Records a vertex array object
  31672. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31673. * @param vertexBuffers defines the list of vertex buffers to store
  31674. * @param indexBuffer defines the index buffer to store
  31675. * @param effect defines the effect to store
  31676. * @returns the new vertex array object
  31677. */
  31678. recordVertexArrayObject(vertexBuffers: {
  31679. [key: string]: VertexBuffer;
  31680. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31681. /**
  31682. * Bind a specific vertex array object
  31683. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31684. * @param vertexArrayObject defines the vertex array object to bind
  31685. * @param indexBuffer defines the index buffer to bind
  31686. */
  31687. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31688. /**
  31689. * Bind webGl buffers directly to the webGL context
  31690. * @param vertexBuffer defines the vertex buffer to bind
  31691. * @param indexBuffer defines the index buffer to bind
  31692. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31693. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31694. * @param effect defines the effect associated with the vertex buffer
  31695. */
  31696. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31697. private _unbindVertexArrayObject;
  31698. /**
  31699. * Bind a list of vertex buffers to the webGL context
  31700. * @param vertexBuffers defines the list of vertex buffers to bind
  31701. * @param indexBuffer defines the index buffer to bind
  31702. * @param effect defines the effect associated with the vertex buffers
  31703. */
  31704. bindBuffers(vertexBuffers: {
  31705. [key: string]: Nullable<VertexBuffer>;
  31706. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31707. /**
  31708. * Unbind all instance attributes
  31709. */
  31710. unbindInstanceAttributes(): void;
  31711. /**
  31712. * Release and free the memory of a vertex array object
  31713. * @param vao defines the vertex array object to delete
  31714. */
  31715. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31716. /** @hidden */
  31717. _releaseBuffer(buffer: DataBuffer): boolean;
  31718. /**
  31719. * Creates a webGL buffer to use with instanciation
  31720. * @param capacity defines the size of the buffer
  31721. * @returns the webGL buffer
  31722. */
  31723. createInstancesBuffer(capacity: number): DataBuffer;
  31724. /**
  31725. * Delete a webGL buffer used with instanciation
  31726. * @param buffer defines the webGL buffer to delete
  31727. */
  31728. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31729. /**
  31730. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31731. * @param instancesBuffer defines the webGL buffer to update and bind
  31732. * @param data defines the data to store in the buffer
  31733. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31734. */
  31735. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31736. /**
  31737. * Apply all cached states (depth, culling, stencil and alpha)
  31738. */
  31739. applyStates(): void;
  31740. /**
  31741. * Send a draw order
  31742. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31743. * @param indexStart defines the starting index
  31744. * @param indexCount defines the number of index to draw
  31745. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31746. */
  31747. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31748. /**
  31749. * Draw a list of points
  31750. * @param verticesStart defines the index of first vertex to draw
  31751. * @param verticesCount defines the count of vertices to draw
  31752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31753. */
  31754. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31755. /**
  31756. * Draw a list of unindexed primitives
  31757. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31758. * @param verticesStart defines the index of first vertex to draw
  31759. * @param verticesCount defines the count of vertices to draw
  31760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31761. */
  31762. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31763. /**
  31764. * Draw a list of indexed primitives
  31765. * @param fillMode defines the primitive to use
  31766. * @param indexStart defines the starting index
  31767. * @param indexCount defines the number of index to draw
  31768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31769. */
  31770. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31771. /**
  31772. * Draw a list of unindexed primitives
  31773. * @param fillMode defines the primitive to use
  31774. * @param verticesStart defines the index of first vertex to draw
  31775. * @param verticesCount defines the count of vertices to draw
  31776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31777. */
  31778. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31779. private _drawMode;
  31780. /** @hidden */
  31781. _releaseEffect(effect: Effect): void;
  31782. /** @hidden */
  31783. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31784. /**
  31785. * Create a new effect (used to store vertex/fragment shaders)
  31786. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31787. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31788. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31789. * @param samplers defines an array of string used to represent textures
  31790. * @param defines defines the string containing the defines to use to compile the shaders
  31791. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31792. * @param onCompiled defines a function to call when the effect creation is successful
  31793. * @param onError defines a function to call when the effect creation has failed
  31794. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31795. * @returns the new Effect
  31796. */
  31797. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31798. private _compileShader;
  31799. private _compileRawShader;
  31800. /**
  31801. * Directly creates a webGL program
  31802. * @param pipelineContext defines the pipeline context to attach to
  31803. * @param vertexCode defines the vertex shader code to use
  31804. * @param fragmentCode defines the fragment shader code to use
  31805. * @param context defines the webGL context to use (if not set, the current one will be used)
  31806. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31807. * @returns the new webGL program
  31808. */
  31809. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31810. /**
  31811. * Creates a webGL program
  31812. * @param pipelineContext defines the pipeline context to attach to
  31813. * @param vertexCode defines the vertex shader code to use
  31814. * @param fragmentCode defines the fragment shader code to use
  31815. * @param defines defines the string containing the defines to use to compile the shaders
  31816. * @param context defines the webGL context to use (if not set, the current one will be used)
  31817. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31818. * @returns the new webGL program
  31819. */
  31820. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31821. /**
  31822. * Creates a new pipeline context
  31823. * @returns the new pipeline
  31824. */
  31825. createPipelineContext(): WebGLPipelineContext;
  31826. private _createShaderProgram;
  31827. private _finalizePipelineContext;
  31828. /** @hidden */
  31829. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31830. /** @hidden */
  31831. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31832. /** @hidden */
  31833. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31834. /**
  31835. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31836. * @param pipelineContext defines the pipeline context to use
  31837. * @param uniformsNames defines the list of uniform names
  31838. * @returns an array of webGL uniform locations
  31839. */
  31840. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31841. /**
  31842. * Gets the lsit of active attributes for a given webGL program
  31843. * @param pipelineContext defines the pipeline context to use
  31844. * @param attributesNames defines the list of attribute names to get
  31845. * @returns an array of indices indicating the offset of each attribute
  31846. */
  31847. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31848. /**
  31849. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31850. * @param effect defines the effect to activate
  31851. */
  31852. enableEffect(effect: Nullable<Effect>): void;
  31853. /**
  31854. * Set the value of an uniform to an array of int32
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param array defines the array of int32 to store
  31857. */
  31858. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31859. /**
  31860. * Set the value of an uniform to an array of int32 (stored as vec2)
  31861. * @param uniform defines the webGL uniform location where to store the value
  31862. * @param array defines the array of int32 to store
  31863. */
  31864. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31865. /**
  31866. * Set the value of an uniform to an array of int32 (stored as vec3)
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param array defines the array of int32 to store
  31869. */
  31870. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31871. /**
  31872. * Set the value of an uniform to an array of int32 (stored as vec4)
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param array defines the array of int32 to store
  31875. */
  31876. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31877. /**
  31878. * Set the value of an uniform to an array of float32
  31879. * @param uniform defines the webGL uniform location where to store the value
  31880. * @param array defines the array of float32 to store
  31881. */
  31882. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31883. /**
  31884. * Set the value of an uniform to an array of float32 (stored as vec2)
  31885. * @param uniform defines the webGL uniform location where to store the value
  31886. * @param array defines the array of float32 to store
  31887. */
  31888. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31889. /**
  31890. * Set the value of an uniform to an array of float32 (stored as vec3)
  31891. * @param uniform defines the webGL uniform location where to store the value
  31892. * @param array defines the array of float32 to store
  31893. */
  31894. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31895. /**
  31896. * Set the value of an uniform to an array of float32 (stored as vec4)
  31897. * @param uniform defines the webGL uniform location where to store the value
  31898. * @param array defines the array of float32 to store
  31899. */
  31900. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31901. /**
  31902. * Set the value of an uniform to an array of number
  31903. * @param uniform defines the webGL uniform location where to store the value
  31904. * @param array defines the array of number to store
  31905. */
  31906. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31907. /**
  31908. * Set the value of an uniform to an array of number (stored as vec2)
  31909. * @param uniform defines the webGL uniform location where to store the value
  31910. * @param array defines the array of number to store
  31911. */
  31912. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31913. /**
  31914. * Set the value of an uniform to an array of number (stored as vec3)
  31915. * @param uniform defines the webGL uniform location where to store the value
  31916. * @param array defines the array of number to store
  31917. */
  31918. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31919. /**
  31920. * Set the value of an uniform to an array of number (stored as vec4)
  31921. * @param uniform defines the webGL uniform location where to store the value
  31922. * @param array defines the array of number to store
  31923. */
  31924. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31925. /**
  31926. * Set the value of an uniform to an array of float32 (stored as matrices)
  31927. * @param uniform defines the webGL uniform location where to store the value
  31928. * @param matrices defines the array of float32 to store
  31929. */
  31930. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31931. /**
  31932. * Set the value of an uniform to a matrix (3x3)
  31933. * @param uniform defines the webGL uniform location where to store the value
  31934. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31935. */
  31936. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31937. /**
  31938. * Set the value of an uniform to a matrix (2x2)
  31939. * @param uniform defines the webGL uniform location where to store the value
  31940. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31941. */
  31942. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31943. /**
  31944. * Set the value of an uniform to a number (int)
  31945. * @param uniform defines the webGL uniform location where to store the value
  31946. * @param value defines the int number to store
  31947. */
  31948. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31949. /**
  31950. * Set the value of an uniform to a number (float)
  31951. * @param uniform defines the webGL uniform location where to store the value
  31952. * @param value defines the float number to store
  31953. */
  31954. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31955. /**
  31956. * Set the value of an uniform to a vec2
  31957. * @param uniform defines the webGL uniform location where to store the value
  31958. * @param x defines the 1st component of the value
  31959. * @param y defines the 2nd component of the value
  31960. */
  31961. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31962. /**
  31963. * Set the value of an uniform to a vec3
  31964. * @param uniform defines the webGL uniform location where to store the value
  31965. * @param x defines the 1st component of the value
  31966. * @param y defines the 2nd component of the value
  31967. * @param z defines the 3rd component of the value
  31968. */
  31969. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31970. /**
  31971. * Set the value of an uniform to a boolean
  31972. * @param uniform defines the webGL uniform location where to store the value
  31973. * @param bool defines the boolean to store
  31974. */
  31975. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31976. /**
  31977. * Set the value of an uniform to a vec4
  31978. * @param uniform defines the webGL uniform location where to store the value
  31979. * @param x defines the 1st component of the value
  31980. * @param y defines the 2nd component of the value
  31981. * @param z defines the 3rd component of the value
  31982. * @param w defines the 4th component of the value
  31983. */
  31984. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31985. /**
  31986. * Sets a Color4 on a uniform variable
  31987. * @param uniform defines the uniform location
  31988. * @param color4 defines the value to be set
  31989. */
  31990. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31991. /**
  31992. * Set various states to the webGL context
  31993. * @param culling defines backface culling state
  31994. * @param zOffset defines the value to apply to zOffset (0 by default)
  31995. * @param force defines if states must be applied even if cache is up to date
  31996. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31997. */
  31998. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31999. /**
  32000. * Set the z offset to apply to current rendering
  32001. * @param value defines the offset to apply
  32002. */
  32003. setZOffset(value: number): void;
  32004. /**
  32005. * Gets the current value of the zOffset
  32006. * @returns the current zOffset state
  32007. */
  32008. getZOffset(): number;
  32009. /**
  32010. * Enable or disable depth buffering
  32011. * @param enable defines the state to set
  32012. */
  32013. setDepthBuffer(enable: boolean): void;
  32014. /**
  32015. * Gets a boolean indicating if depth writing is enabled
  32016. * @returns the current depth writing state
  32017. */
  32018. getDepthWrite(): boolean;
  32019. /**
  32020. * Enable or disable depth writing
  32021. * @param enable defines the state to set
  32022. */
  32023. setDepthWrite(enable: boolean): void;
  32024. /**
  32025. * Enable or disable color writing
  32026. * @param enable defines the state to set
  32027. */
  32028. setColorWrite(enable: boolean): void;
  32029. /**
  32030. * Gets a boolean indicating if color writing is enabled
  32031. * @returns the current color writing state
  32032. */
  32033. getColorWrite(): boolean;
  32034. /**
  32035. * Sets alpha constants used by some alpha blending modes
  32036. * @param r defines the red component
  32037. * @param g defines the green component
  32038. * @param b defines the blue component
  32039. * @param a defines the alpha component
  32040. */
  32041. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32042. /**
  32043. * Sets the current alpha mode
  32044. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32045. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32046. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32047. */
  32048. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32049. /**
  32050. * Gets the current alpha mode
  32051. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32052. * @returns the current alpha mode
  32053. */
  32054. getAlphaMode(): number;
  32055. /**
  32056. * Clears the list of texture accessible through engine.
  32057. * This can help preventing texture load conflict due to name collision.
  32058. */
  32059. clearInternalTexturesCache(): void;
  32060. /**
  32061. * Force the entire cache to be cleared
  32062. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32063. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32064. */
  32065. wipeCaches(bruteForce?: boolean): void;
  32066. /**
  32067. * Set the compressed texture format to use, based on the formats you have, and the formats
  32068. * supported by the hardware / browser.
  32069. *
  32070. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32071. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32072. * to API arguments needed to compressed textures. This puts the burden on the container
  32073. * generator to house the arcane code for determining these for current & future formats.
  32074. *
  32075. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32076. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32077. *
  32078. * Note: The result of this call is not taken into account when a texture is base64.
  32079. *
  32080. * @param formatsAvailable defines the list of those format families you have created
  32081. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32082. *
  32083. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32084. * @returns The extension selected.
  32085. */
  32086. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32087. /** @hidden */
  32088. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32089. min: number;
  32090. mag: number;
  32091. };
  32092. /** @hidden */
  32093. _createTexture(): WebGLTexture;
  32094. /**
  32095. * Usually called from Texture.ts.
  32096. * Passed information to create a WebGLTexture
  32097. * @param urlArg defines a value which contains one of the following:
  32098. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32099. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32100. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32101. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32102. * @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)
  32103. * @param scene needed for loading to the correct scene
  32104. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32105. * @param onLoad optional callback to be called upon successful completion
  32106. * @param onError optional callback to be called upon failure
  32107. * @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
  32108. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32109. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32110. * @param forcedExtension defines the extension to use to pick the right loader
  32111. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32112. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32113. */
  32114. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32115. /**
  32116. * @hidden
  32117. * Rescales a texture
  32118. * @param source input texutre
  32119. * @param destination destination texture
  32120. * @param scene scene to use to render the resize
  32121. * @param internalFormat format to use when resizing
  32122. * @param onComplete callback to be called when resize has completed
  32123. */
  32124. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32125. private _unpackFlipYCached;
  32126. /**
  32127. * In case you are sharing the context with other applications, it might
  32128. * be interested to not cache the unpack flip y state to ensure a consistent
  32129. * value would be set.
  32130. */
  32131. enableUnpackFlipYCached: boolean;
  32132. /** @hidden */
  32133. _unpackFlipY(value: boolean): void;
  32134. /** @hidden */
  32135. _getUnpackAlignement(): number;
  32136. /**
  32137. * Creates a dynamic texture
  32138. * @param width defines the width of the texture
  32139. * @param height defines the height of the texture
  32140. * @param generateMipMaps defines if the engine should generate the mip levels
  32141. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32142. * @returns the dynamic texture inside an InternalTexture
  32143. */
  32144. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32145. /**
  32146. * Update the sampling mode of a given texture
  32147. * @param samplingMode defines the required sampling mode
  32148. * @param texture defines the texture to update
  32149. */
  32150. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32151. /**
  32152. * Update the content of a dynamic texture
  32153. * @param texture defines the texture to update
  32154. * @param canvas defines the canvas containing the source
  32155. * @param invertY defines if data must be stored with Y axis inverted
  32156. * @param premulAlpha defines if alpha is stored as premultiplied
  32157. * @param format defines the format of the data
  32158. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32159. */
  32160. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32161. /**
  32162. * Update a video texture
  32163. * @param texture defines the texture to update
  32164. * @param video defines the video element to use
  32165. * @param invertY defines if data must be stored with Y axis inverted
  32166. */
  32167. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32168. /**
  32169. * Updates a depth texture Comparison Mode and Function.
  32170. * If the comparison Function is equal to 0, the mode will be set to none.
  32171. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32172. * @param texture The texture to set the comparison function for
  32173. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32174. */
  32175. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32176. /** @hidden */
  32177. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32178. width: number;
  32179. height: number;
  32180. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32181. /**
  32182. * Creates a depth stencil texture.
  32183. * This is only available in WebGL 2 or with the depth texture extension available.
  32184. * @param size The size of face edge in the texture.
  32185. * @param options The options defining the texture.
  32186. * @returns The texture
  32187. */
  32188. createDepthStencilTexture(size: number | {
  32189. width: number;
  32190. height: number;
  32191. }, options: DepthTextureCreationOptions): InternalTexture;
  32192. /**
  32193. * Creates a depth stencil texture.
  32194. * This is only available in WebGL 2 or with the depth texture extension available.
  32195. * @param size The size of face edge in the texture.
  32196. * @param options The options defining the texture.
  32197. * @returns The texture
  32198. */
  32199. private _createDepthStencilTexture;
  32200. /**
  32201. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32202. * @param renderTarget The render target to set the frame buffer for
  32203. */
  32204. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32205. /**
  32206. * Creates a new render target texture
  32207. * @param size defines the size of the texture
  32208. * @param options defines the options used to create the texture
  32209. * @returns a new render target texture stored in an InternalTexture
  32210. */
  32211. createRenderTargetTexture(size: number | {
  32212. width: number;
  32213. height: number;
  32214. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32215. /** @hidden */
  32216. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32217. /**
  32218. * Updates the sample count of a render target texture
  32219. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32220. * @param texture defines the texture to update
  32221. * @param samples defines the sample count to set
  32222. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32223. */
  32224. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32225. /** @hidden */
  32226. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32227. /** @hidden */
  32228. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32229. /** @hidden */
  32230. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32231. /** @hidden */
  32232. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32233. /**
  32234. * @hidden
  32235. */
  32236. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32237. private _prepareWebGLTextureContinuation;
  32238. private _prepareWebGLTexture;
  32239. /** @hidden */
  32240. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32241. /** @hidden */
  32242. _releaseFramebufferObjects(texture: InternalTexture): void;
  32243. /** @hidden */
  32244. _releaseTexture(texture: InternalTexture): void;
  32245. private setProgram;
  32246. private _boundUniforms;
  32247. /**
  32248. * Binds an effect to the webGL context
  32249. * @param effect defines the effect to bind
  32250. */
  32251. bindSamplers(effect: Effect): void;
  32252. private _activateCurrentTexture;
  32253. /** @hidden */
  32254. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32255. /** @hidden */
  32256. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32257. /**
  32258. * Sets a texture to the webGL context from a postprocess
  32259. * @param channel defines the channel to use
  32260. * @param postProcess defines the source postprocess
  32261. */
  32262. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32263. /**
  32264. * Binds the output of the passed in post process to the texture channel specified
  32265. * @param channel The channel the texture should be bound to
  32266. * @param postProcess The post process which's output should be bound
  32267. */
  32268. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32269. /**
  32270. * Unbind all textures from the webGL context
  32271. */
  32272. unbindAllTextures(): void;
  32273. /**
  32274. * Sets a texture to the according uniform.
  32275. * @param channel The texture channel
  32276. * @param uniform The uniform to set
  32277. * @param texture The texture to apply
  32278. */
  32279. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32280. /**
  32281. * Sets a depth stencil texture from a render target to the according uniform.
  32282. * @param channel The texture channel
  32283. * @param uniform The uniform to set
  32284. * @param texture The render target texture containing the depth stencil texture to apply
  32285. */
  32286. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32287. private _bindSamplerUniformToChannel;
  32288. private _getTextureWrapMode;
  32289. private _setTexture;
  32290. /**
  32291. * Sets an array of texture to the webGL context
  32292. * @param channel defines the channel where the texture array must be set
  32293. * @param uniform defines the associated uniform location
  32294. * @param textures defines the array of textures to bind
  32295. */
  32296. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32297. /** @hidden */
  32298. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32299. private _setTextureParameterFloat;
  32300. private _setTextureParameterInteger;
  32301. /**
  32302. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32303. * @param x defines the x coordinate of the rectangle where pixels must be read
  32304. * @param y defines the y coordinate of the rectangle where pixels must be read
  32305. * @param width defines the width of the rectangle where pixels must be read
  32306. * @param height defines the height of the rectangle where pixels must be read
  32307. * @returns a Uint8Array containing RGBA colors
  32308. */
  32309. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32310. /**
  32311. * Add an externaly attached data from its key.
  32312. * This method call will fail and return false, if such key already exists.
  32313. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32314. * @param key the unique key that identifies the data
  32315. * @param data the data object to associate to the key for this Engine instance
  32316. * @return true if no such key were already present and the data was added successfully, false otherwise
  32317. */
  32318. addExternalData<T>(key: string, data: T): boolean;
  32319. /**
  32320. * Get an externaly attached data from its key
  32321. * @param key the unique key that identifies the data
  32322. * @return the associated data, if present (can be null), or undefined if not present
  32323. */
  32324. getExternalData<T>(key: string): T;
  32325. /**
  32326. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32327. * @param key the unique key that identifies the data
  32328. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32329. * @return the associated data, can be null if the factory returned null.
  32330. */
  32331. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32332. /**
  32333. * Remove an externaly attached data from the Engine instance
  32334. * @param key the unique key that identifies the data
  32335. * @return true if the data was successfully removed, false if it doesn't exist
  32336. */
  32337. removeExternalData(key: string): boolean;
  32338. /**
  32339. * Unbind all vertex attributes from the webGL context
  32340. */
  32341. unbindAllAttributes(): void;
  32342. /**
  32343. * 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
  32344. */
  32345. releaseEffects(): void;
  32346. /**
  32347. * Dispose and release all associated resources
  32348. */
  32349. dispose(): void;
  32350. /**
  32351. * Display the loading screen
  32352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32353. */
  32354. displayLoadingUI(): void;
  32355. /**
  32356. * Hide the loading screen
  32357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32358. */
  32359. hideLoadingUI(): void;
  32360. /**
  32361. * Gets the current loading screen object
  32362. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32363. */
  32364. /**
  32365. * Sets the current loading screen object
  32366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32367. */
  32368. loadingScreen: ILoadingScreen;
  32369. /**
  32370. * Sets the current loading screen text
  32371. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32372. */
  32373. loadingUIText: string;
  32374. /**
  32375. * Sets the current loading screen background color
  32376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32377. */
  32378. loadingUIBackgroundColor: string;
  32379. /**
  32380. * Attach a new callback raised when context lost event is fired
  32381. * @param callback defines the callback to call
  32382. */
  32383. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32384. /**
  32385. * Attach a new callback raised when context restored event is fired
  32386. * @param callback defines the callback to call
  32387. */
  32388. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32389. /**
  32390. * Gets the source code of the vertex shader associated with a specific webGL program
  32391. * @param program defines the program to use
  32392. * @returns a string containing the source code of the vertex shader associated with the program
  32393. */
  32394. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32395. /**
  32396. * Gets the source code of the fragment shader associated with a specific webGL program
  32397. * @param program defines the program to use
  32398. * @returns a string containing the source code of the fragment shader associated with the program
  32399. */
  32400. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32401. /**
  32402. * Get the current error code of the webGL context
  32403. * @returns the error code
  32404. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32405. */
  32406. getError(): number;
  32407. /**
  32408. * Gets the current framerate
  32409. * @returns a number representing the framerate
  32410. */
  32411. getFps(): number;
  32412. /**
  32413. * Gets the time spent between current and previous frame
  32414. * @returns a number representing the delta time in ms
  32415. */
  32416. getDeltaTime(): number;
  32417. private _measureFps;
  32418. /** @hidden */
  32419. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32420. private _canRenderToFloatFramebuffer;
  32421. private _canRenderToHalfFloatFramebuffer;
  32422. private _canRenderToFramebuffer;
  32423. /** @hidden */
  32424. _getWebGLTextureType(type: number): number;
  32425. /** @hidden */
  32426. _getInternalFormat(format: number): number;
  32427. /** @hidden */
  32428. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32429. /** @hidden */
  32430. _getRGBAMultiSampleBufferFormat(type: number): number;
  32431. /** @hidden */
  32432. _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;
  32433. /** @hidden */
  32434. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32435. /**
  32436. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32437. * @returns true if the engine can be created
  32438. * @ignorenaming
  32439. */
  32440. static isSupported(): boolean;
  32441. /**
  32442. * Find the next highest power of two.
  32443. * @param x Number to start search from.
  32444. * @return Next highest power of two.
  32445. */
  32446. static CeilingPOT(x: number): number;
  32447. /**
  32448. * Find the next lowest power of two.
  32449. * @param x Number to start search from.
  32450. * @return Next lowest power of two.
  32451. */
  32452. static FloorPOT(x: number): number;
  32453. /**
  32454. * Find the nearest power of two.
  32455. * @param x Number to start search from.
  32456. * @return Next nearest power of two.
  32457. */
  32458. static NearestPOT(x: number): number;
  32459. /**
  32460. * Get the closest exponent of two
  32461. * @param value defines the value to approximate
  32462. * @param max defines the maximum value to return
  32463. * @param mode defines how to define the closest value
  32464. * @returns closest exponent of two of the given value
  32465. */
  32466. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32467. /**
  32468. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32469. * @param func - the function to be called
  32470. * @param requester - the object that will request the next frame. Falls back to window.
  32471. * @returns frame number
  32472. */
  32473. static QueueNewFrame(func: () => void, requester?: any): number;
  32474. /**
  32475. * Ask the browser to promote the current element to pointerlock mode
  32476. * @param element defines the DOM element to promote
  32477. */
  32478. static _RequestPointerlock(element: HTMLElement): void;
  32479. /**
  32480. * Asks the browser to exit pointerlock mode
  32481. */
  32482. static _ExitPointerlock(): void;
  32483. /**
  32484. * Ask the browser to promote the current element to fullscreen rendering mode
  32485. * @param element defines the DOM element to promote
  32486. */
  32487. static _RequestFullscreen(element: HTMLElement): void;
  32488. /**
  32489. * Asks the browser to exit fullscreen mode
  32490. */
  32491. static _ExitFullscreen(): void;
  32492. }
  32493. }
  32494. declare module "babylonjs/Engines/engineStore" {
  32495. import { Nullable } from "babylonjs/types";
  32496. import { Engine } from "babylonjs/Engines/engine";
  32497. import { Scene } from "babylonjs/scene";
  32498. /**
  32499. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32500. * during the life time of the application.
  32501. */
  32502. export class EngineStore {
  32503. /** Gets the list of created engines */
  32504. static Instances: import("babylonjs/Engines/engine").Engine[];
  32505. /** @hidden */
  32506. static _LastCreatedScene: Nullable<Scene>;
  32507. /**
  32508. * Gets the latest created engine
  32509. */
  32510. static readonly LastCreatedEngine: Nullable<Engine>;
  32511. /**
  32512. * Gets the latest created scene
  32513. */
  32514. static readonly LastCreatedScene: Nullable<Scene>;
  32515. /**
  32516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32517. * @ignorenaming
  32518. */
  32519. static UseFallbackTexture: boolean;
  32520. /**
  32521. * Texture content used if a texture cannot loaded
  32522. * @ignorenaming
  32523. */
  32524. static FallbackTexture: string;
  32525. }
  32526. }
  32527. declare module "babylonjs/Misc/promise" {
  32528. /**
  32529. * Helper class that provides a small promise polyfill
  32530. */
  32531. export class PromisePolyfill {
  32532. /**
  32533. * Static function used to check if the polyfill is required
  32534. * If this is the case then the function will inject the polyfill to window.Promise
  32535. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32536. */
  32537. static Apply(force?: boolean): void;
  32538. }
  32539. }
  32540. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32541. /**
  32542. * Interface for screenshot methods with describe argument called `size` as object with options
  32543. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32544. */
  32545. export interface IScreenshotSize {
  32546. /**
  32547. * number in pixels for canvas height
  32548. */
  32549. height?: number;
  32550. /**
  32551. * multiplier allowing render at a higher or lower resolution
  32552. * If value is defined then height and width will be ignored and taken from camera
  32553. */
  32554. precision?: number;
  32555. /**
  32556. * number in pixels for canvas width
  32557. */
  32558. width?: number;
  32559. }
  32560. }
  32561. declare module "babylonjs/Misc/tools" {
  32562. import { Nullable, float } from "babylonjs/types";
  32563. import { DomManagement } from "babylonjs/Misc/domManagement";
  32564. import { WebRequest } from "babylonjs/Misc/webRequest";
  32565. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32566. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32567. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32568. import { Camera } from "babylonjs/Cameras/camera";
  32569. import { Engine } from "babylonjs/Engines/engine";
  32570. interface IColor4Like {
  32571. r: float;
  32572. g: float;
  32573. b: float;
  32574. a: float;
  32575. }
  32576. /**
  32577. * Class containing a set of static utilities functions
  32578. */
  32579. export class Tools {
  32580. /**
  32581. * Gets or sets the base URL to use to load assets
  32582. */
  32583. static BaseUrl: string;
  32584. /**
  32585. * Enable/Disable Custom HTTP Request Headers globally.
  32586. * default = false
  32587. * @see CustomRequestHeaders
  32588. */
  32589. static UseCustomRequestHeaders: boolean;
  32590. /**
  32591. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32592. * i.e. when loading files, where the server/service expects an Authorization header
  32593. */
  32594. static CustomRequestHeaders: {
  32595. [key: string]: string;
  32596. };
  32597. /**
  32598. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32599. */
  32600. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32601. /**
  32602. * Default behaviour for cors in the application.
  32603. * It can be a string if the expected behavior is identical in the entire app.
  32604. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32605. */
  32606. static CorsBehavior: string | ((url: string | string[]) => string);
  32607. /**
  32608. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32609. * @ignorenaming
  32610. */
  32611. static UseFallbackTexture: boolean;
  32612. /**
  32613. * Use this object to register external classes like custom textures or material
  32614. * to allow the laoders to instantiate them
  32615. */
  32616. static RegisteredExternalClasses: {
  32617. [key: string]: Object;
  32618. };
  32619. /**
  32620. * Texture content used if a texture cannot loaded
  32621. * @ignorenaming
  32622. */
  32623. static fallbackTexture: string;
  32624. /**
  32625. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32626. * @param u defines the coordinate on X axis
  32627. * @param v defines the coordinate on Y axis
  32628. * @param width defines the width of the source data
  32629. * @param height defines the height of the source data
  32630. * @param pixels defines the source byte array
  32631. * @param color defines the output color
  32632. */
  32633. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32634. /**
  32635. * Interpolates between a and b via alpha
  32636. * @param a The lower value (returned when alpha = 0)
  32637. * @param b The upper value (returned when alpha = 1)
  32638. * @param alpha The interpolation-factor
  32639. * @return The mixed value
  32640. */
  32641. static Mix(a: number, b: number, alpha: number): number;
  32642. /**
  32643. * Tries to instantiate a new object from a given class name
  32644. * @param className defines the class name to instantiate
  32645. * @returns the new object or null if the system was not able to do the instantiation
  32646. */
  32647. static Instantiate(className: string): any;
  32648. /**
  32649. * Provides a slice function that will work even on IE
  32650. * @param data defines the array to slice
  32651. * @param start defines the start of the data (optional)
  32652. * @param end defines the end of the data (optional)
  32653. * @returns the new sliced array
  32654. */
  32655. static Slice<T>(data: T, start?: number, end?: number): T;
  32656. /**
  32657. * Polyfill for setImmediate
  32658. * @param action defines the action to execute after the current execution block
  32659. */
  32660. static SetImmediate(action: () => void): void;
  32661. /**
  32662. * Function indicating if a number is an exponent of 2
  32663. * @param value defines the value to test
  32664. * @returns true if the value is an exponent of 2
  32665. */
  32666. static IsExponentOfTwo(value: number): boolean;
  32667. private static _tmpFloatArray;
  32668. /**
  32669. * Returns the nearest 32-bit single precision float representation of a Number
  32670. * @param value A Number. If the parameter is of a different type, it will get converted
  32671. * to a number or to NaN if it cannot be converted
  32672. * @returns number
  32673. */
  32674. static FloatRound(value: number): number;
  32675. /**
  32676. * Extracts the filename from a path
  32677. * @param path defines the path to use
  32678. * @returns the filename
  32679. */
  32680. static GetFilename(path: string): string;
  32681. /**
  32682. * Extracts the "folder" part of a path (everything before the filename).
  32683. * @param uri The URI to extract the info from
  32684. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32685. * @returns The "folder" part of the path
  32686. */
  32687. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32688. /**
  32689. * Extracts text content from a DOM element hierarchy
  32690. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32691. */
  32692. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32693. /**
  32694. * Convert an angle in radians to degrees
  32695. * @param angle defines the angle to convert
  32696. * @returns the angle in degrees
  32697. */
  32698. static ToDegrees(angle: number): number;
  32699. /**
  32700. * Convert an angle in degrees to radians
  32701. * @param angle defines the angle to convert
  32702. * @returns the angle in radians
  32703. */
  32704. static ToRadians(angle: number): number;
  32705. /**
  32706. * Encode a buffer to a base64 string
  32707. * @param buffer defines the buffer to encode
  32708. * @returns the encoded string
  32709. */
  32710. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32711. /**
  32712. * Returns an array if obj is not an array
  32713. * @param obj defines the object to evaluate as an array
  32714. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32715. * @returns either obj directly if obj is an array or a new array containing obj
  32716. */
  32717. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32718. /**
  32719. * Gets the pointer prefix to use
  32720. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32721. */
  32722. static GetPointerPrefix(): string;
  32723. /**
  32724. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32725. * @param url define the url we are trying
  32726. * @param element define the dom element where to configure the cors policy
  32727. */
  32728. static SetCorsBehavior(url: string | string[], element: {
  32729. crossOrigin: string | null;
  32730. }): void;
  32731. /**
  32732. * Removes unwanted characters from an url
  32733. * @param url defines the url to clean
  32734. * @returns the cleaned url
  32735. */
  32736. static CleanUrl(url: string): string;
  32737. /**
  32738. * Gets or sets a function used to pre-process url before using them to load assets
  32739. */
  32740. static PreprocessUrl: (url: string) => string;
  32741. /**
  32742. * Loads an image as an HTMLImageElement.
  32743. * @param input url string, ArrayBuffer, or Blob to load
  32744. * @param onLoad callback called when the image successfully loads
  32745. * @param onError callback called when the image fails to load
  32746. * @param offlineProvider offline provider for caching
  32747. * @returns the HTMLImageElement of the loaded image
  32748. */
  32749. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32750. /**
  32751. * Loads a file
  32752. * @param url url string, ArrayBuffer, or Blob to load
  32753. * @param onSuccess callback called when the file successfully loads
  32754. * @param onProgress callback called while file is loading (if the server supports this mode)
  32755. * @param offlineProvider defines the offline provider for caching
  32756. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32757. * @param onError callback called when the file fails to load
  32758. * @returns a file request object
  32759. */
  32760. 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;
  32761. /**
  32762. * Loads a file from a url
  32763. * @param url the file url to load
  32764. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32765. */
  32766. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32767. /**
  32768. * Load a script (identified by an url). When the url returns, the
  32769. * content of this file is added into a new script element, attached to the DOM (body element)
  32770. * @param scriptUrl defines the url of the script to laod
  32771. * @param onSuccess defines the callback called when the script is loaded
  32772. * @param onError defines the callback to call if an error occurs
  32773. * @param scriptId defines the id of the script element
  32774. */
  32775. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32776. /**
  32777. * Load an asynchronous script (identified by an url). When the url returns, the
  32778. * content of this file is added into a new script element, attached to the DOM (body element)
  32779. * @param scriptUrl defines the url of the script to laod
  32780. * @param scriptId defines the id of the script element
  32781. * @returns a promise request object
  32782. */
  32783. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32784. /**
  32785. * Loads a file from a blob
  32786. * @param fileToLoad defines the blob to use
  32787. * @param callback defines the callback to call when data is loaded
  32788. * @param progressCallback defines the callback to call during loading process
  32789. * @returns a file request object
  32790. */
  32791. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32792. /**
  32793. * Loads a file
  32794. * @param fileToLoad defines the file to load
  32795. * @param callback defines the callback to call when data is loaded
  32796. * @param progressCallBack defines the callback to call during loading process
  32797. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32798. * @returns a file request object
  32799. */
  32800. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32801. /**
  32802. * Creates a data url from a given string content
  32803. * @param content defines the content to convert
  32804. * @returns the new data url link
  32805. */
  32806. static FileAsURL(content: string): string;
  32807. /**
  32808. * Format the given number to a specific decimal format
  32809. * @param value defines the number to format
  32810. * @param decimals defines the number of decimals to use
  32811. * @returns the formatted string
  32812. */
  32813. static Format(value: number, decimals?: number): string;
  32814. /**
  32815. * Tries to copy an object by duplicating every property
  32816. * @param source defines the source object
  32817. * @param destination defines the target object
  32818. * @param doNotCopyList defines a list of properties to avoid
  32819. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32820. */
  32821. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32822. /**
  32823. * Gets a boolean indicating if the given object has no own property
  32824. * @param obj defines the object to test
  32825. * @returns true if object has no own property
  32826. */
  32827. static IsEmpty(obj: any): boolean;
  32828. /**
  32829. * Function used to register events at window level
  32830. * @param windowElement defines the Window object to use
  32831. * @param events defines the events to register
  32832. */
  32833. static RegisterTopRootEvents(windowElement: Window, events: {
  32834. name: string;
  32835. handler: Nullable<(e: FocusEvent) => any>;
  32836. }[]): void;
  32837. /**
  32838. * Function used to unregister events from window level
  32839. * @param windowElement defines the Window object to use
  32840. * @param events defines the events to unregister
  32841. */
  32842. static UnregisterTopRootEvents(windowElement: Window, events: {
  32843. name: string;
  32844. handler: Nullable<(e: FocusEvent) => any>;
  32845. }[]): void;
  32846. /**
  32847. * @ignore
  32848. */
  32849. static _ScreenshotCanvas: HTMLCanvasElement;
  32850. /**
  32851. * Dumps the current bound framebuffer
  32852. * @param width defines the rendering width
  32853. * @param height defines the rendering height
  32854. * @param engine defines the hosting engine
  32855. * @param successCallback defines the callback triggered once the data are available
  32856. * @param mimeType defines the mime type of the result
  32857. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32858. */
  32859. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32860. /**
  32861. * Converts the canvas data to blob.
  32862. * This acts as a polyfill for browsers not supporting the to blob function.
  32863. * @param canvas Defines the canvas to extract the data from
  32864. * @param successCallback Defines the callback triggered once the data are available
  32865. * @param mimeType Defines the mime type of the result
  32866. */
  32867. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32868. /**
  32869. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32870. * @param successCallback defines the callback triggered once the data are available
  32871. * @param mimeType defines the mime type of the result
  32872. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32873. */
  32874. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32875. /**
  32876. * Downloads a blob in the browser
  32877. * @param blob defines the blob to download
  32878. * @param fileName defines the name of the downloaded file
  32879. */
  32880. static Download(blob: Blob, fileName: string): void;
  32881. /**
  32882. * Captures a screenshot of the current rendering
  32883. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32884. * @param engine defines the rendering engine
  32885. * @param camera defines the source camera
  32886. * @param size This parameter can be set to a single number or to an object with the
  32887. * following (optional) properties: precision, width, height. If a single number is passed,
  32888. * it will be used for both width and height. If an object is passed, the screenshot size
  32889. * will be derived from the parameters. The precision property is a multiplier allowing
  32890. * rendering at a higher or lower resolution
  32891. * @param successCallback defines the callback receives a single parameter which contains the
  32892. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32893. * src parameter of an <img> to display it
  32894. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32895. * Check your browser for supported MIME types
  32896. */
  32897. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32898. /**
  32899. * Captures a screenshot of the current rendering
  32900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32901. * @param engine defines the rendering engine
  32902. * @param camera defines the source camera
  32903. * @param size This parameter can be set to a single number or to an object with the
  32904. * following (optional) properties: precision, width, height. If a single number is passed,
  32905. * it will be used for both width and height. If an object is passed, the screenshot size
  32906. * will be derived from the parameters. The precision property is a multiplier allowing
  32907. * rendering at a higher or lower resolution
  32908. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32909. * Check your browser for supported MIME types
  32910. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32911. * to the src parameter of an <img> to display it
  32912. */
  32913. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32914. /**
  32915. * Generates an image screenshot from the specified camera.
  32916. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32917. * @param engine The engine to use for rendering
  32918. * @param camera The camera to use for rendering
  32919. * @param size This parameter can be set to a single number or to an object with the
  32920. * following (optional) properties: precision, width, height. If a single number is passed,
  32921. * it will be used for both width and height. If an object is passed, the screenshot size
  32922. * will be derived from the parameters. The precision property is a multiplier allowing
  32923. * rendering at a higher or lower resolution
  32924. * @param successCallback The callback receives a single parameter which contains the
  32925. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32926. * src parameter of an <img> to display it
  32927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32928. * Check your browser for supported MIME types
  32929. * @param samples Texture samples (default: 1)
  32930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32931. * @param fileName A name for for the downloaded file.
  32932. */
  32933. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32934. /**
  32935. * Generates an image screenshot from the specified camera.
  32936. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32937. * @param engine The engine to use for rendering
  32938. * @param camera The camera to use for rendering
  32939. * @param size This parameter can be set to a single number or to an object with the
  32940. * following (optional) properties: precision, width, height. If a single number is passed,
  32941. * it will be used for both width and height. If an object is passed, the screenshot size
  32942. * will be derived from the parameters. The precision property is a multiplier allowing
  32943. * rendering at a higher or lower resolution
  32944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32945. * Check your browser for supported MIME types
  32946. * @param samples Texture samples (default: 1)
  32947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32948. * @param fileName A name for for the downloaded file.
  32949. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32950. * to the src parameter of an <img> to display it
  32951. */
  32952. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32953. /**
  32954. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32955. * Be aware Math.random() could cause collisions, but:
  32956. * "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"
  32957. * @returns a pseudo random id
  32958. */
  32959. static RandomId(): string;
  32960. /**
  32961. * Test if the given uri is a base64 string
  32962. * @param uri The uri to test
  32963. * @return True if the uri is a base64 string or false otherwise
  32964. */
  32965. static IsBase64(uri: string): boolean;
  32966. /**
  32967. * Decode the given base64 uri.
  32968. * @param uri The uri to decode
  32969. * @return The decoded base64 data.
  32970. */
  32971. static DecodeBase64(uri: string): ArrayBuffer;
  32972. /**
  32973. * Gets the absolute url.
  32974. * @param url the input url
  32975. * @return the absolute url
  32976. */
  32977. static GetAbsoluteUrl(url: string): string;
  32978. /**
  32979. * No log
  32980. */
  32981. static readonly NoneLogLevel: number;
  32982. /**
  32983. * Only message logs
  32984. */
  32985. static readonly MessageLogLevel: number;
  32986. /**
  32987. * Only warning logs
  32988. */
  32989. static readonly WarningLogLevel: number;
  32990. /**
  32991. * Only error logs
  32992. */
  32993. static readonly ErrorLogLevel: number;
  32994. /**
  32995. * All logs
  32996. */
  32997. static readonly AllLogLevel: number;
  32998. /**
  32999. * Gets a value indicating the number of loading errors
  33000. * @ignorenaming
  33001. */
  33002. static readonly errorsCount: number;
  33003. /**
  33004. * Callback called when a new log is added
  33005. */
  33006. static OnNewCacheEntry: (entry: string) => void;
  33007. /**
  33008. * Log a message to the console
  33009. * @param message defines the message to log
  33010. */
  33011. static Log(message: string): void;
  33012. /**
  33013. * Write a warning message to the console
  33014. * @param message defines the message to log
  33015. */
  33016. static Warn(message: string): void;
  33017. /**
  33018. * Write an error message to the console
  33019. * @param message defines the message to log
  33020. */
  33021. static Error(message: string): void;
  33022. /**
  33023. * Gets current log cache (list of logs)
  33024. */
  33025. static readonly LogCache: string;
  33026. /**
  33027. * Clears the log cache
  33028. */
  33029. static ClearLogCache(): void;
  33030. /**
  33031. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33032. */
  33033. static LogLevels: number;
  33034. /**
  33035. * Checks if the window object exists
  33036. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33037. */
  33038. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33039. /**
  33040. * No performance log
  33041. */
  33042. static readonly PerformanceNoneLogLevel: number;
  33043. /**
  33044. * Use user marks to log performance
  33045. */
  33046. static readonly PerformanceUserMarkLogLevel: number;
  33047. /**
  33048. * Log performance to the console
  33049. */
  33050. static readonly PerformanceConsoleLogLevel: number;
  33051. private static _performance;
  33052. /**
  33053. * Sets the current performance log level
  33054. */
  33055. static PerformanceLogLevel: number;
  33056. private static _StartPerformanceCounterDisabled;
  33057. private static _EndPerformanceCounterDisabled;
  33058. private static _StartUserMark;
  33059. private static _EndUserMark;
  33060. private static _StartPerformanceConsole;
  33061. private static _EndPerformanceConsole;
  33062. /**
  33063. * Starts a performance counter
  33064. */
  33065. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33066. /**
  33067. * Ends a specific performance coutner
  33068. */
  33069. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33070. /**
  33071. * Gets either window.performance.now() if supported or Date.now() else
  33072. */
  33073. static readonly Now: number;
  33074. /**
  33075. * This method will return the name of the class used to create the instance of the given object.
  33076. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33077. * @param object the object to get the class name from
  33078. * @param isType defines if the object is actually a type
  33079. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33080. */
  33081. static GetClassName(object: any, isType?: boolean): string;
  33082. /**
  33083. * Gets the first element of an array satisfying a given predicate
  33084. * @param array defines the array to browse
  33085. * @param predicate defines the predicate to use
  33086. * @returns null if not found or the element
  33087. */
  33088. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33089. /**
  33090. * This method will return the name of the full name of the class, including its owning module (if any).
  33091. * 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).
  33092. * @param object the object to get the class name from
  33093. * @param isType defines if the object is actually a type
  33094. * @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.
  33095. * @ignorenaming
  33096. */
  33097. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33098. /**
  33099. * Returns a promise that resolves after the given amount of time.
  33100. * @param delay Number of milliseconds to delay
  33101. * @returns Promise that resolves after the given amount of time
  33102. */
  33103. static DelayAsync(delay: number): Promise<void>;
  33104. }
  33105. /**
  33106. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33107. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33108. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33109. * @param name The name of the class, case should be preserved
  33110. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33111. */
  33112. export function className(name: string, module?: string): (target: Object) => void;
  33113. /**
  33114. * An implementation of a loop for asynchronous functions.
  33115. */
  33116. export class AsyncLoop {
  33117. /**
  33118. * Defines the number of iterations for the loop
  33119. */
  33120. iterations: number;
  33121. /**
  33122. * Defines the current index of the loop.
  33123. */
  33124. index: number;
  33125. private _done;
  33126. private _fn;
  33127. private _successCallback;
  33128. /**
  33129. * Constructor.
  33130. * @param iterations the number of iterations.
  33131. * @param func the function to run each iteration
  33132. * @param successCallback the callback that will be called upon succesful execution
  33133. * @param offset starting offset.
  33134. */
  33135. constructor(
  33136. /**
  33137. * Defines the number of iterations for the loop
  33138. */
  33139. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33140. /**
  33141. * Execute the next iteration. Must be called after the last iteration was finished.
  33142. */
  33143. executeNext(): void;
  33144. /**
  33145. * Break the loop and run the success callback.
  33146. */
  33147. breakLoop(): void;
  33148. /**
  33149. * Create and run an async loop.
  33150. * @param iterations the number of iterations.
  33151. * @param fn the function to run each iteration
  33152. * @param successCallback the callback that will be called upon succesful execution
  33153. * @param offset starting offset.
  33154. * @returns the created async loop object
  33155. */
  33156. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33157. /**
  33158. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33159. * @param iterations total number of iterations
  33160. * @param syncedIterations number of synchronous iterations in each async iteration.
  33161. * @param fn the function to call each iteration.
  33162. * @param callback a success call back that will be called when iterating stops.
  33163. * @param breakFunction a break condition (optional)
  33164. * @param timeout timeout settings for the setTimeout function. default - 0.
  33165. * @returns the created async loop object
  33166. */
  33167. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33168. }
  33169. }
  33170. declare module "babylonjs/Collisions/collisionCoordinator" {
  33171. import { Nullable } from "babylonjs/types";
  33172. import { Scene } from "babylonjs/scene";
  33173. import { Vector3 } from "babylonjs/Maths/math.vector";
  33174. import { Collider } from "babylonjs/Collisions/collider";
  33175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33176. /** @hidden */
  33177. export interface ICollisionCoordinator {
  33178. createCollider(): Collider;
  33179. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33180. init(scene: Scene): void;
  33181. }
  33182. /** @hidden */
  33183. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33184. private _scene;
  33185. private _scaledPosition;
  33186. private _scaledVelocity;
  33187. private _finalPosition;
  33188. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33189. createCollider(): Collider;
  33190. init(scene: Scene): void;
  33191. private _collideWithWorld;
  33192. }
  33193. }
  33194. declare module "babylonjs/Inputs/scene.inputManager" {
  33195. import { Nullable } from "babylonjs/types";
  33196. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33197. import { Vector2 } from "babylonjs/Maths/math.vector";
  33198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33199. import { Scene } from "babylonjs/scene";
  33200. /**
  33201. * Class used to manage all inputs for the scene.
  33202. */
  33203. export class InputManager {
  33204. /** The distance in pixel that you have to move to prevent some events */
  33205. static DragMovementThreshold: number;
  33206. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33207. static LongPressDelay: number;
  33208. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33209. static DoubleClickDelay: number;
  33210. /** If you need to check double click without raising a single click at first click, enable this flag */
  33211. static ExclusiveDoubleClickMode: boolean;
  33212. private _wheelEventName;
  33213. private _onPointerMove;
  33214. private _onPointerDown;
  33215. private _onPointerUp;
  33216. private _initClickEvent;
  33217. private _initActionManager;
  33218. private _delayedSimpleClick;
  33219. private _delayedSimpleClickTimeout;
  33220. private _previousDelayedSimpleClickTimeout;
  33221. private _meshPickProceed;
  33222. private _previousButtonPressed;
  33223. private _currentPickResult;
  33224. private _previousPickResult;
  33225. private _totalPointersPressed;
  33226. private _doubleClickOccured;
  33227. private _pointerOverMesh;
  33228. private _pickedDownMesh;
  33229. private _pickedUpMesh;
  33230. private _pointerX;
  33231. private _pointerY;
  33232. private _unTranslatedPointerX;
  33233. private _unTranslatedPointerY;
  33234. private _startingPointerPosition;
  33235. private _previousStartingPointerPosition;
  33236. private _startingPointerTime;
  33237. private _previousStartingPointerTime;
  33238. private _pointerCaptures;
  33239. private _onKeyDown;
  33240. private _onKeyUp;
  33241. private _onCanvasFocusObserver;
  33242. private _onCanvasBlurObserver;
  33243. private _scene;
  33244. /**
  33245. * Creates a new InputManager
  33246. * @param scene defines the hosting scene
  33247. */
  33248. constructor(scene: Scene);
  33249. /**
  33250. * Gets the mesh that is currently under the pointer
  33251. */
  33252. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33253. /**
  33254. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33255. */
  33256. readonly unTranslatedPointer: Vector2;
  33257. /**
  33258. * Gets or sets the current on-screen X position of the pointer
  33259. */
  33260. pointerX: number;
  33261. /**
  33262. * Gets or sets the current on-screen Y position of the pointer
  33263. */
  33264. pointerY: number;
  33265. private _updatePointerPosition;
  33266. private _processPointerMove;
  33267. private _setRayOnPointerInfo;
  33268. private _checkPrePointerObservable;
  33269. /**
  33270. * Use this method to simulate a pointer move on a mesh
  33271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33274. */
  33275. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33276. /**
  33277. * Use this method to simulate a pointer down on a mesh
  33278. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33279. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33280. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33281. */
  33282. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33283. private _processPointerDown;
  33284. /** @hidden */
  33285. _isPointerSwiping(): boolean;
  33286. /**
  33287. * Use this method to simulate a pointer up on a mesh
  33288. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33289. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33290. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33291. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33292. */
  33293. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33294. private _processPointerUp;
  33295. /**
  33296. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33297. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33298. * @returns true if the pointer was captured
  33299. */
  33300. isPointerCaptured(pointerId?: number): boolean;
  33301. /**
  33302. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33303. * @param attachUp defines if you want to attach events to pointerup
  33304. * @param attachDown defines if you want to attach events to pointerdown
  33305. * @param attachMove defines if you want to attach events to pointermove
  33306. */
  33307. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33308. /**
  33309. * Detaches all event handlers
  33310. */
  33311. detachControl(): void;
  33312. /**
  33313. * Force the value of meshUnderPointer
  33314. * @param mesh defines the mesh to use
  33315. */
  33316. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33317. /**
  33318. * Gets the mesh under the pointer
  33319. * @returns a Mesh or null if no mesh is under the pointer
  33320. */
  33321. getPointerOverMesh(): Nullable<AbstractMesh>;
  33322. }
  33323. }
  33324. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33325. /**
  33326. * Helper class used to generate session unique ID
  33327. */
  33328. export class UniqueIdGenerator {
  33329. private static _UniqueIdCounter;
  33330. /**
  33331. * Gets an unique (relatively to the current scene) Id
  33332. */
  33333. static readonly UniqueId: number;
  33334. }
  33335. }
  33336. declare module "babylonjs/Animations/animationGroup" {
  33337. import { Animatable } from "babylonjs/Animations/animatable";
  33338. import { Animation } from "babylonjs/Animations/animation";
  33339. import { Scene, IDisposable } from "babylonjs/scene";
  33340. import { Observable } from "babylonjs/Misc/observable";
  33341. import { Nullable } from "babylonjs/types";
  33342. import "babylonjs/Animations/animatable";
  33343. /**
  33344. * This class defines the direct association between an animation and a target
  33345. */
  33346. export class TargetedAnimation {
  33347. /**
  33348. * Animation to perform
  33349. */
  33350. animation: Animation;
  33351. /**
  33352. * Target to animate
  33353. */
  33354. target: any;
  33355. /**
  33356. * Serialize the object
  33357. * @returns the JSON object representing the current entity
  33358. */
  33359. serialize(): any;
  33360. }
  33361. /**
  33362. * Use this class to create coordinated animations on multiple targets
  33363. */
  33364. export class AnimationGroup implements IDisposable {
  33365. /** The name of the animation group */
  33366. name: string;
  33367. private _scene;
  33368. private _targetedAnimations;
  33369. private _animatables;
  33370. private _from;
  33371. private _to;
  33372. private _isStarted;
  33373. private _isPaused;
  33374. private _speedRatio;
  33375. private _loopAnimation;
  33376. /**
  33377. * Gets or sets the unique id of the node
  33378. */
  33379. uniqueId: number;
  33380. /**
  33381. * This observable will notify when one animation have ended
  33382. */
  33383. onAnimationEndObservable: Observable<TargetedAnimation>;
  33384. /**
  33385. * Observer raised when one animation loops
  33386. */
  33387. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33388. /**
  33389. * This observable will notify when all animations have ended.
  33390. */
  33391. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33392. /**
  33393. * This observable will notify when all animations have paused.
  33394. */
  33395. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33396. /**
  33397. * This observable will notify when all animations are playing.
  33398. */
  33399. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33400. /**
  33401. * Gets the first frame
  33402. */
  33403. readonly from: number;
  33404. /**
  33405. * Gets the last frame
  33406. */
  33407. readonly to: number;
  33408. /**
  33409. * Define if the animations are started
  33410. */
  33411. readonly isStarted: boolean;
  33412. /**
  33413. * Gets a value indicating that the current group is playing
  33414. */
  33415. readonly isPlaying: boolean;
  33416. /**
  33417. * Gets or sets the speed ratio to use for all animations
  33418. */
  33419. /**
  33420. * Gets or sets the speed ratio to use for all animations
  33421. */
  33422. speedRatio: number;
  33423. /**
  33424. * Gets or sets if all animations should loop or not
  33425. */
  33426. loopAnimation: boolean;
  33427. /**
  33428. * Gets the targeted animations for this animation group
  33429. */
  33430. readonly targetedAnimations: Array<TargetedAnimation>;
  33431. /**
  33432. * returning the list of animatables controlled by this animation group.
  33433. */
  33434. readonly animatables: Array<Animatable>;
  33435. /**
  33436. * Instantiates a new Animation Group.
  33437. * This helps managing several animations at once.
  33438. * @see http://doc.babylonjs.com/how_to/group
  33439. * @param name Defines the name of the group
  33440. * @param scene Defines the scene the group belongs to
  33441. */
  33442. constructor(
  33443. /** The name of the animation group */
  33444. name: string, scene?: Nullable<Scene>);
  33445. /**
  33446. * Add an animation (with its target) in the group
  33447. * @param animation defines the animation we want to add
  33448. * @param target defines the target of the animation
  33449. * @returns the TargetedAnimation object
  33450. */
  33451. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33452. /**
  33453. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33454. * It can add constant keys at begin or end
  33455. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33456. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33457. * @returns the animation group
  33458. */
  33459. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33460. /**
  33461. * Start all animations on given targets
  33462. * @param loop defines if animations must loop
  33463. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33464. * @param from defines the from key (optional)
  33465. * @param to defines the to key (optional)
  33466. * @returns the current animation group
  33467. */
  33468. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33469. /**
  33470. * Pause all animations
  33471. * @returns the animation group
  33472. */
  33473. pause(): AnimationGroup;
  33474. /**
  33475. * Play all animations to initial state
  33476. * This function will start() the animations if they were not started or will restart() them if they were paused
  33477. * @param loop defines if animations must loop
  33478. * @returns the animation group
  33479. */
  33480. play(loop?: boolean): AnimationGroup;
  33481. /**
  33482. * Reset all animations to initial state
  33483. * @returns the animation group
  33484. */
  33485. reset(): AnimationGroup;
  33486. /**
  33487. * Restart animations from key 0
  33488. * @returns the animation group
  33489. */
  33490. restart(): AnimationGroup;
  33491. /**
  33492. * Stop all animations
  33493. * @returns the animation group
  33494. */
  33495. stop(): AnimationGroup;
  33496. /**
  33497. * Set animation weight for all animatables
  33498. * @param weight defines the weight to use
  33499. * @return the animationGroup
  33500. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33501. */
  33502. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33503. /**
  33504. * Synchronize and normalize all animatables with a source animatable
  33505. * @param root defines the root animatable to synchronize with
  33506. * @return the animationGroup
  33507. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33508. */
  33509. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33510. /**
  33511. * Goes to a specific frame in this animation group
  33512. * @param frame the frame number to go to
  33513. * @return the animationGroup
  33514. */
  33515. goToFrame(frame: number): AnimationGroup;
  33516. /**
  33517. * Dispose all associated resources
  33518. */
  33519. dispose(): void;
  33520. private _checkAnimationGroupEnded;
  33521. /**
  33522. * Clone the current animation group and returns a copy
  33523. * @param newName defines the name of the new group
  33524. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33525. * @returns the new aniamtion group
  33526. */
  33527. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33528. /**
  33529. * Serializes the animationGroup to an object
  33530. * @returns Serialized object
  33531. */
  33532. serialize(): any;
  33533. /**
  33534. * Returns a new AnimationGroup object parsed from the source provided.
  33535. * @param parsedAnimationGroup defines the source
  33536. * @param scene defines the scene that will receive the animationGroup
  33537. * @returns a new AnimationGroup
  33538. */
  33539. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33540. /**
  33541. * Returns the string "AnimationGroup"
  33542. * @returns "AnimationGroup"
  33543. */
  33544. getClassName(): string;
  33545. /**
  33546. * Creates a detailled string about the object
  33547. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33548. * @returns a string representing the object
  33549. */
  33550. toString(fullDetails?: boolean): string;
  33551. }
  33552. }
  33553. declare module "babylonjs/scene" {
  33554. import { Nullable } from "babylonjs/types";
  33555. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33556. import { Observable } from "babylonjs/Misc/observable";
  33557. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33558. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33559. import { Geometry } from "babylonjs/Meshes/geometry";
  33560. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33561. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33563. import { Mesh } from "babylonjs/Meshes/mesh";
  33564. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33565. import { Bone } from "babylonjs/Bones/bone";
  33566. import { Skeleton } from "babylonjs/Bones/skeleton";
  33567. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33568. import { Camera } from "babylonjs/Cameras/camera";
  33569. import { AbstractScene } from "babylonjs/abstractScene";
  33570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33571. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33572. import { Material } from "babylonjs/Materials/material";
  33573. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33574. import { Effect } from "babylonjs/Materials/effect";
  33575. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33576. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33577. import { Light } from "babylonjs/Lights/light";
  33578. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33579. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33580. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33581. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33583. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33584. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33585. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33586. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33587. import { Engine } from "babylonjs/Engines/engine";
  33588. import { Node } from "babylonjs/node";
  33589. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33590. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33591. import { WebRequest } from "babylonjs/Misc/webRequest";
  33592. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33593. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33594. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33595. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33596. import { Plane } from "babylonjs/Maths/math.plane";
  33597. import { Ray } from "babylonjs/Culling/ray";
  33598. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33599. import { Animation } from "babylonjs/Animations/animation";
  33600. import { Animatable } from "babylonjs/Animations/animatable";
  33601. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33602. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33603. import { Collider } from "babylonjs/Collisions/collider";
  33604. /**
  33605. * Define an interface for all classes that will hold resources
  33606. */
  33607. export interface IDisposable {
  33608. /**
  33609. * Releases all held resources
  33610. */
  33611. dispose(): void;
  33612. }
  33613. /** Interface defining initialization parameters for Scene class */
  33614. export interface SceneOptions {
  33615. /**
  33616. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33617. * It will improve performance when the number of geometries becomes important.
  33618. */
  33619. useGeometryUniqueIdsMap?: boolean;
  33620. /**
  33621. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33622. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33623. */
  33624. useMaterialMeshMap?: boolean;
  33625. /**
  33626. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33627. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33628. */
  33629. useClonedMeshhMap?: boolean;
  33630. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33631. virtual?: boolean;
  33632. }
  33633. /**
  33634. * Represents a scene to be rendered by the engine.
  33635. * @see http://doc.babylonjs.com/features/scene
  33636. */
  33637. export class Scene extends AbstractScene implements IAnimatable {
  33638. /** The fog is deactivated */
  33639. static readonly FOGMODE_NONE: number;
  33640. /** The fog density is following an exponential function */
  33641. static readonly FOGMODE_EXP: number;
  33642. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33643. static readonly FOGMODE_EXP2: number;
  33644. /** The fog density is following a linear function. */
  33645. static readonly FOGMODE_LINEAR: number;
  33646. /**
  33647. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33648. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33649. */
  33650. static MinDeltaTime: number;
  33651. /**
  33652. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33654. */
  33655. static MaxDeltaTime: number;
  33656. /**
  33657. * Factory used to create the default material.
  33658. * @param name The name of the material to create
  33659. * @param scene The scene to create the material for
  33660. * @returns The default material
  33661. */
  33662. static DefaultMaterialFactory(scene: Scene): Material;
  33663. /**
  33664. * Factory used to create the a collision coordinator.
  33665. * @returns The collision coordinator
  33666. */
  33667. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33668. /** @hidden */
  33669. _inputManager: InputManager;
  33670. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33671. cameraToUseForPointers: Nullable<Camera>;
  33672. /** @hidden */
  33673. readonly _isScene: boolean;
  33674. /**
  33675. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33676. */
  33677. autoClear: boolean;
  33678. /**
  33679. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33680. */
  33681. autoClearDepthAndStencil: boolean;
  33682. /**
  33683. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33684. */
  33685. clearColor: Color4;
  33686. /**
  33687. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33688. */
  33689. ambientColor: Color3;
  33690. /**
  33691. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33692. * It should only be one of the following (if not the default embedded one):
  33693. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33694. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33695. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33696. * The material properties need to be setup according to the type of texture in use.
  33697. */
  33698. environmentBRDFTexture: BaseTexture;
  33699. /** @hidden */
  33700. protected _environmentTexture: Nullable<BaseTexture>;
  33701. /**
  33702. * Texture used in all pbr material as the reflection texture.
  33703. * As in the majority of the scene they are the same (exception for multi room and so on),
  33704. * this is easier to reference from here than from all the materials.
  33705. */
  33706. /**
  33707. * Texture used in all pbr material as the reflection texture.
  33708. * As in the majority of the scene they are the same (exception for multi room and so on),
  33709. * this is easier to set here than in all the materials.
  33710. */
  33711. environmentTexture: Nullable<BaseTexture>;
  33712. /** @hidden */
  33713. protected _environmentIntensity: number;
  33714. /**
  33715. * Intensity of the environment in all pbr material.
  33716. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33717. * As in the majority of the scene they are the same (exception for multi room and so on),
  33718. * this is easier to reference from here than from all the materials.
  33719. */
  33720. /**
  33721. * Intensity of the environment in all pbr material.
  33722. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33723. * As in the majority of the scene they are the same (exception for multi room and so on),
  33724. * this is easier to set here than in all the materials.
  33725. */
  33726. environmentIntensity: number;
  33727. /** @hidden */
  33728. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33729. /**
  33730. * Default image processing configuration used either in the rendering
  33731. * Forward main pass or through the imageProcessingPostProcess if present.
  33732. * As in the majority of the scene they are the same (exception for multi camera),
  33733. * this is easier to reference from here than from all the materials and post process.
  33734. *
  33735. * No setter as we it is a shared configuration, you can set the values instead.
  33736. */
  33737. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33738. private _forceWireframe;
  33739. /**
  33740. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33741. */
  33742. forceWireframe: boolean;
  33743. private _forcePointsCloud;
  33744. /**
  33745. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33746. */
  33747. forcePointsCloud: boolean;
  33748. /**
  33749. * Gets or sets the active clipplane 1
  33750. */
  33751. clipPlane: Nullable<Plane>;
  33752. /**
  33753. * Gets or sets the active clipplane 2
  33754. */
  33755. clipPlane2: Nullable<Plane>;
  33756. /**
  33757. * Gets or sets the active clipplane 3
  33758. */
  33759. clipPlane3: Nullable<Plane>;
  33760. /**
  33761. * Gets or sets the active clipplane 4
  33762. */
  33763. clipPlane4: Nullable<Plane>;
  33764. /**
  33765. * Gets or sets a boolean indicating if animations are enabled
  33766. */
  33767. animationsEnabled: boolean;
  33768. private _animationPropertiesOverride;
  33769. /**
  33770. * Gets or sets the animation properties override
  33771. */
  33772. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33773. /**
  33774. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33775. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33776. */
  33777. useConstantAnimationDeltaTime: boolean;
  33778. /**
  33779. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33780. * Please note that it requires to run a ray cast through the scene on every frame
  33781. */
  33782. constantlyUpdateMeshUnderPointer: boolean;
  33783. /**
  33784. * Defines the HTML cursor to use when hovering over interactive elements
  33785. */
  33786. hoverCursor: string;
  33787. /**
  33788. * Defines the HTML default cursor to use (empty by default)
  33789. */
  33790. defaultCursor: string;
  33791. /**
  33792. * This is used to call preventDefault() on pointer down
  33793. * in order to block unwanted artifacts like system double clicks
  33794. */
  33795. preventDefaultOnPointerDown: boolean;
  33796. /**
  33797. * This is used to call preventDefault() on pointer up
  33798. * in order to block unwanted artifacts like system double clicks
  33799. */
  33800. preventDefaultOnPointerUp: boolean;
  33801. /**
  33802. * Gets or sets user defined metadata
  33803. */
  33804. metadata: any;
  33805. /**
  33806. * For internal use only. Please do not use.
  33807. */
  33808. reservedDataStore: any;
  33809. /**
  33810. * Gets the name of the plugin used to load this scene (null by default)
  33811. */
  33812. loadingPluginName: string;
  33813. /**
  33814. * Use this array to add regular expressions used to disable offline support for specific urls
  33815. */
  33816. disableOfflineSupportExceptionRules: RegExp[];
  33817. /**
  33818. * An event triggered when the scene is disposed.
  33819. */
  33820. onDisposeObservable: Observable<Scene>;
  33821. private _onDisposeObserver;
  33822. /** Sets a function to be executed when this scene is disposed. */
  33823. onDispose: () => void;
  33824. /**
  33825. * An event triggered before rendering the scene (right after animations and physics)
  33826. */
  33827. onBeforeRenderObservable: Observable<Scene>;
  33828. private _onBeforeRenderObserver;
  33829. /** Sets a function to be executed before rendering this scene */
  33830. beforeRender: Nullable<() => void>;
  33831. /**
  33832. * An event triggered after rendering the scene
  33833. */
  33834. onAfterRenderObservable: Observable<Scene>;
  33835. /**
  33836. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33837. */
  33838. onAfterRenderCameraObservable: Observable<Camera>;
  33839. private _onAfterRenderObserver;
  33840. /** Sets a function to be executed after rendering this scene */
  33841. afterRender: Nullable<() => void>;
  33842. /**
  33843. * An event triggered before animating the scene
  33844. */
  33845. onBeforeAnimationsObservable: Observable<Scene>;
  33846. /**
  33847. * An event triggered after animations processing
  33848. */
  33849. onAfterAnimationsObservable: Observable<Scene>;
  33850. /**
  33851. * An event triggered before draw calls are ready to be sent
  33852. */
  33853. onBeforeDrawPhaseObservable: Observable<Scene>;
  33854. /**
  33855. * An event triggered after draw calls have been sent
  33856. */
  33857. onAfterDrawPhaseObservable: Observable<Scene>;
  33858. /**
  33859. * An event triggered when the scene is ready
  33860. */
  33861. onReadyObservable: Observable<Scene>;
  33862. /**
  33863. * An event triggered before rendering a camera
  33864. */
  33865. onBeforeCameraRenderObservable: Observable<Camera>;
  33866. private _onBeforeCameraRenderObserver;
  33867. /** Sets a function to be executed before rendering a camera*/
  33868. beforeCameraRender: () => void;
  33869. /**
  33870. * An event triggered after rendering a camera
  33871. */
  33872. onAfterCameraRenderObservable: Observable<Camera>;
  33873. private _onAfterCameraRenderObserver;
  33874. /** Sets a function to be executed after rendering a camera*/
  33875. afterCameraRender: () => void;
  33876. /**
  33877. * An event triggered when active meshes evaluation is about to start
  33878. */
  33879. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33880. /**
  33881. * An event triggered when active meshes evaluation is done
  33882. */
  33883. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33884. /**
  33885. * An event triggered when particles rendering is about to start
  33886. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33887. */
  33888. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33889. /**
  33890. * An event triggered when particles rendering is done
  33891. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33892. */
  33893. onAfterParticlesRenderingObservable: Observable<Scene>;
  33894. /**
  33895. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33896. */
  33897. onDataLoadedObservable: Observable<Scene>;
  33898. /**
  33899. * An event triggered when a camera is created
  33900. */
  33901. onNewCameraAddedObservable: Observable<Camera>;
  33902. /**
  33903. * An event triggered when a camera is removed
  33904. */
  33905. onCameraRemovedObservable: Observable<Camera>;
  33906. /**
  33907. * An event triggered when a light is created
  33908. */
  33909. onNewLightAddedObservable: Observable<Light>;
  33910. /**
  33911. * An event triggered when a light is removed
  33912. */
  33913. onLightRemovedObservable: Observable<Light>;
  33914. /**
  33915. * An event triggered when a geometry is created
  33916. */
  33917. onNewGeometryAddedObservable: Observable<Geometry>;
  33918. /**
  33919. * An event triggered when a geometry is removed
  33920. */
  33921. onGeometryRemovedObservable: Observable<Geometry>;
  33922. /**
  33923. * An event triggered when a transform node is created
  33924. */
  33925. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33926. /**
  33927. * An event triggered when a transform node is removed
  33928. */
  33929. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33930. /**
  33931. * An event triggered when a mesh is created
  33932. */
  33933. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33934. /**
  33935. * An event triggered when a mesh is removed
  33936. */
  33937. onMeshRemovedObservable: Observable<AbstractMesh>;
  33938. /**
  33939. * An event triggered when a skeleton is created
  33940. */
  33941. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33942. /**
  33943. * An event triggered when a skeleton is removed
  33944. */
  33945. onSkeletonRemovedObservable: Observable<Skeleton>;
  33946. /**
  33947. * An event triggered when a material is created
  33948. */
  33949. onNewMaterialAddedObservable: Observable<Material>;
  33950. /**
  33951. * An event triggered when a material is removed
  33952. */
  33953. onMaterialRemovedObservable: Observable<Material>;
  33954. /**
  33955. * An event triggered when a texture is created
  33956. */
  33957. onNewTextureAddedObservable: Observable<BaseTexture>;
  33958. /**
  33959. * An event triggered when a texture is removed
  33960. */
  33961. onTextureRemovedObservable: Observable<BaseTexture>;
  33962. /**
  33963. * An event triggered when render targets are about to be rendered
  33964. * Can happen multiple times per frame.
  33965. */
  33966. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33967. /**
  33968. * An event triggered when render targets were rendered.
  33969. * Can happen multiple times per frame.
  33970. */
  33971. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33972. /**
  33973. * An event triggered before calculating deterministic simulation step
  33974. */
  33975. onBeforeStepObservable: Observable<Scene>;
  33976. /**
  33977. * An event triggered after calculating deterministic simulation step
  33978. */
  33979. onAfterStepObservable: Observable<Scene>;
  33980. /**
  33981. * An event triggered when the activeCamera property is updated
  33982. */
  33983. onActiveCameraChanged: Observable<Scene>;
  33984. /**
  33985. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33986. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33987. * 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)
  33988. */
  33989. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33990. /**
  33991. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33992. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33993. * 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)
  33994. */
  33995. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33996. /**
  33997. * This Observable will when a mesh has been imported into the scene.
  33998. */
  33999. onMeshImportedObservable: Observable<AbstractMesh>;
  34000. /**
  34001. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34002. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34003. */
  34004. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34005. /** @hidden */
  34006. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34007. /**
  34008. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34009. */
  34010. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34011. /**
  34012. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34013. */
  34014. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34015. /**
  34016. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34017. */
  34018. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34019. /** Callback called when a pointer move is detected */
  34020. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34021. /** Callback called when a pointer down is detected */
  34022. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34023. /** Callback called when a pointer up is detected */
  34024. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34025. /** Callback called when a pointer pick is detected */
  34026. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34027. /**
  34028. * 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).
  34029. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34030. */
  34031. onPrePointerObservable: Observable<PointerInfoPre>;
  34032. /**
  34033. * Observable event triggered each time an input event is received from the rendering canvas
  34034. */
  34035. onPointerObservable: Observable<PointerInfo>;
  34036. /**
  34037. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34038. */
  34039. readonly unTranslatedPointer: Vector2;
  34040. /**
  34041. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34042. */
  34043. static DragMovementThreshold: number;
  34044. /**
  34045. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34046. */
  34047. static LongPressDelay: number;
  34048. /**
  34049. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34050. */
  34051. static DoubleClickDelay: number;
  34052. /** If you need to check double click without raising a single click at first click, enable this flag */
  34053. static ExclusiveDoubleClickMode: boolean;
  34054. /** @hidden */
  34055. _mirroredCameraPosition: Nullable<Vector3>;
  34056. /**
  34057. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34058. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34059. */
  34060. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34061. /**
  34062. * Observable event triggered each time an keyboard event is received from the hosting window
  34063. */
  34064. onKeyboardObservable: Observable<KeyboardInfo>;
  34065. private _useRightHandedSystem;
  34066. /**
  34067. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34068. */
  34069. useRightHandedSystem: boolean;
  34070. private _timeAccumulator;
  34071. private _currentStepId;
  34072. private _currentInternalStep;
  34073. /**
  34074. * Sets the step Id used by deterministic lock step
  34075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34076. * @param newStepId defines the step Id
  34077. */
  34078. setStepId(newStepId: number): void;
  34079. /**
  34080. * Gets the step Id used by deterministic lock step
  34081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34082. * @returns the step Id
  34083. */
  34084. getStepId(): number;
  34085. /**
  34086. * Gets the internal step used by deterministic lock step
  34087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34088. * @returns the internal step
  34089. */
  34090. getInternalStep(): number;
  34091. private _fogEnabled;
  34092. /**
  34093. * Gets or sets a boolean indicating if fog is enabled on this scene
  34094. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34095. * (Default is true)
  34096. */
  34097. fogEnabled: boolean;
  34098. private _fogMode;
  34099. /**
  34100. * Gets or sets the fog mode to use
  34101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34102. * | mode | value |
  34103. * | --- | --- |
  34104. * | FOGMODE_NONE | 0 |
  34105. * | FOGMODE_EXP | 1 |
  34106. * | FOGMODE_EXP2 | 2 |
  34107. * | FOGMODE_LINEAR | 3 |
  34108. */
  34109. fogMode: number;
  34110. /**
  34111. * Gets or sets the fog color to use
  34112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34113. * (Default is Color3(0.2, 0.2, 0.3))
  34114. */
  34115. fogColor: Color3;
  34116. /**
  34117. * Gets or sets the fog density to use
  34118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34119. * (Default is 0.1)
  34120. */
  34121. fogDensity: number;
  34122. /**
  34123. * Gets or sets the fog start distance to use
  34124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34125. * (Default is 0)
  34126. */
  34127. fogStart: number;
  34128. /**
  34129. * Gets or sets the fog end distance to use
  34130. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34131. * (Default is 1000)
  34132. */
  34133. fogEnd: number;
  34134. private _shadowsEnabled;
  34135. /**
  34136. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34137. */
  34138. shadowsEnabled: boolean;
  34139. private _lightsEnabled;
  34140. /**
  34141. * Gets or sets a boolean indicating if lights are enabled on this scene
  34142. */
  34143. lightsEnabled: boolean;
  34144. /** All of the active cameras added to this scene. */
  34145. activeCameras: Camera[];
  34146. /** @hidden */
  34147. _activeCamera: Nullable<Camera>;
  34148. /** Gets or sets the current active camera */
  34149. activeCamera: Nullable<Camera>;
  34150. private _defaultMaterial;
  34151. /** The default material used on meshes when no material is affected */
  34152. /** The default material used on meshes when no material is affected */
  34153. defaultMaterial: Material;
  34154. private _texturesEnabled;
  34155. /**
  34156. * Gets or sets a boolean indicating if textures are enabled on this scene
  34157. */
  34158. texturesEnabled: boolean;
  34159. /**
  34160. * Gets or sets a boolean indicating if particles are enabled on this scene
  34161. */
  34162. particlesEnabled: boolean;
  34163. /**
  34164. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34165. */
  34166. spritesEnabled: boolean;
  34167. private _skeletonsEnabled;
  34168. /**
  34169. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34170. */
  34171. skeletonsEnabled: boolean;
  34172. /**
  34173. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34174. */
  34175. lensFlaresEnabled: boolean;
  34176. /**
  34177. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34179. */
  34180. collisionsEnabled: boolean;
  34181. private _collisionCoordinator;
  34182. /** @hidden */
  34183. readonly collisionCoordinator: ICollisionCoordinator;
  34184. /**
  34185. * Defines the gravity applied to this scene (used only for collisions)
  34186. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34187. */
  34188. gravity: Vector3;
  34189. /**
  34190. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34191. */
  34192. postProcessesEnabled: boolean;
  34193. /**
  34194. * The list of postprocesses added to the scene
  34195. */
  34196. postProcesses: PostProcess[];
  34197. /**
  34198. * Gets the current postprocess manager
  34199. */
  34200. postProcessManager: PostProcessManager;
  34201. /**
  34202. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34203. */
  34204. renderTargetsEnabled: boolean;
  34205. /**
  34206. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34207. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34208. */
  34209. dumpNextRenderTargets: boolean;
  34210. /**
  34211. * The list of user defined render targets added to the scene
  34212. */
  34213. customRenderTargets: RenderTargetTexture[];
  34214. /**
  34215. * Defines if texture loading must be delayed
  34216. * If true, textures will only be loaded when they need to be rendered
  34217. */
  34218. useDelayedTextureLoading: boolean;
  34219. /**
  34220. * Gets the list of meshes imported to the scene through SceneLoader
  34221. */
  34222. importedMeshesFiles: String[];
  34223. /**
  34224. * Gets or sets a boolean indicating if probes are enabled on this scene
  34225. */
  34226. probesEnabled: boolean;
  34227. /**
  34228. * Gets or sets the current offline provider to use to store scene data
  34229. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34230. */
  34231. offlineProvider: IOfflineProvider;
  34232. /**
  34233. * Gets or sets the action manager associated with the scene
  34234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34235. */
  34236. actionManager: AbstractActionManager;
  34237. private _meshesForIntersections;
  34238. /**
  34239. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34240. */
  34241. proceduralTexturesEnabled: boolean;
  34242. private _engine;
  34243. private _totalVertices;
  34244. /** @hidden */
  34245. _activeIndices: PerfCounter;
  34246. /** @hidden */
  34247. _activeParticles: PerfCounter;
  34248. /** @hidden */
  34249. _activeBones: PerfCounter;
  34250. private _animationRatio;
  34251. /** @hidden */
  34252. _animationTimeLast: number;
  34253. /** @hidden */
  34254. _animationTime: number;
  34255. /**
  34256. * Gets or sets a general scale for animation speed
  34257. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34258. */
  34259. animationTimeScale: number;
  34260. /** @hidden */
  34261. _cachedMaterial: Nullable<Material>;
  34262. /** @hidden */
  34263. _cachedEffect: Nullable<Effect>;
  34264. /** @hidden */
  34265. _cachedVisibility: Nullable<number>;
  34266. private _renderId;
  34267. private _frameId;
  34268. private _executeWhenReadyTimeoutId;
  34269. private _intermediateRendering;
  34270. private _viewUpdateFlag;
  34271. private _projectionUpdateFlag;
  34272. /** @hidden */
  34273. _toBeDisposed: Nullable<IDisposable>[];
  34274. private _activeRequests;
  34275. /** @hidden */
  34276. _pendingData: any[];
  34277. private _isDisposed;
  34278. /**
  34279. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34280. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34281. */
  34282. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34283. private _activeMeshes;
  34284. private _processedMaterials;
  34285. private _renderTargets;
  34286. /** @hidden */
  34287. _activeParticleSystems: SmartArray<IParticleSystem>;
  34288. private _activeSkeletons;
  34289. private _softwareSkinnedMeshes;
  34290. private _renderingManager;
  34291. /** @hidden */
  34292. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34293. private _transformMatrix;
  34294. private _sceneUbo;
  34295. /** @hidden */
  34296. _viewMatrix: Matrix;
  34297. private _projectionMatrix;
  34298. /** @hidden */
  34299. _forcedViewPosition: Nullable<Vector3>;
  34300. /** @hidden */
  34301. _frustumPlanes: Plane[];
  34302. /**
  34303. * Gets the list of frustum planes (built from the active camera)
  34304. */
  34305. readonly frustumPlanes: Plane[];
  34306. /**
  34307. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34308. * This is useful if there are more lights that the maximum simulteanous authorized
  34309. */
  34310. requireLightSorting: boolean;
  34311. /** @hidden */
  34312. readonly useMaterialMeshMap: boolean;
  34313. /** @hidden */
  34314. readonly useClonedMeshhMap: boolean;
  34315. private _externalData;
  34316. private _uid;
  34317. /**
  34318. * @hidden
  34319. * Backing store of defined scene components.
  34320. */
  34321. _components: ISceneComponent[];
  34322. /**
  34323. * @hidden
  34324. * Backing store of defined scene components.
  34325. */
  34326. _serializableComponents: ISceneSerializableComponent[];
  34327. /**
  34328. * List of components to register on the next registration step.
  34329. */
  34330. private _transientComponents;
  34331. /**
  34332. * Registers the transient components if needed.
  34333. */
  34334. private _registerTransientComponents;
  34335. /**
  34336. * @hidden
  34337. * Add a component to the scene.
  34338. * Note that the ccomponent could be registered on th next frame if this is called after
  34339. * the register component stage.
  34340. * @param component Defines the component to add to the scene
  34341. */
  34342. _addComponent(component: ISceneComponent): void;
  34343. /**
  34344. * @hidden
  34345. * Gets a component from the scene.
  34346. * @param name defines the name of the component to retrieve
  34347. * @returns the component or null if not present
  34348. */
  34349. _getComponent(name: string): Nullable<ISceneComponent>;
  34350. /**
  34351. * @hidden
  34352. * Defines the actions happening before camera updates.
  34353. */
  34354. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34355. /**
  34356. * @hidden
  34357. * Defines the actions happening before clear the canvas.
  34358. */
  34359. _beforeClearStage: Stage<SimpleStageAction>;
  34360. /**
  34361. * @hidden
  34362. * Defines the actions when collecting render targets for the frame.
  34363. */
  34364. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34365. /**
  34366. * @hidden
  34367. * Defines the actions happening for one camera in the frame.
  34368. */
  34369. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34370. /**
  34371. * @hidden
  34372. * Defines the actions happening during the per mesh ready checks.
  34373. */
  34374. _isReadyForMeshStage: Stage<MeshStageAction>;
  34375. /**
  34376. * @hidden
  34377. * Defines the actions happening before evaluate active mesh checks.
  34378. */
  34379. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34380. /**
  34381. * @hidden
  34382. * Defines the actions happening during the evaluate sub mesh checks.
  34383. */
  34384. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34385. /**
  34386. * @hidden
  34387. * Defines the actions happening during the active mesh stage.
  34388. */
  34389. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34390. /**
  34391. * @hidden
  34392. * Defines the actions happening during the per camera render target step.
  34393. */
  34394. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34395. /**
  34396. * @hidden
  34397. * Defines the actions happening just before the active camera is drawing.
  34398. */
  34399. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34400. /**
  34401. * @hidden
  34402. * Defines the actions happening just before a render target is drawing.
  34403. */
  34404. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34405. /**
  34406. * @hidden
  34407. * Defines the actions happening just before a rendering group is drawing.
  34408. */
  34409. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34410. /**
  34411. * @hidden
  34412. * Defines the actions happening just before a mesh is drawing.
  34413. */
  34414. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34415. /**
  34416. * @hidden
  34417. * Defines the actions happening just after a mesh has been drawn.
  34418. */
  34419. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34420. /**
  34421. * @hidden
  34422. * Defines the actions happening just after a rendering group has been drawn.
  34423. */
  34424. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34425. /**
  34426. * @hidden
  34427. * Defines the actions happening just after the active camera has been drawn.
  34428. */
  34429. _afterCameraDrawStage: Stage<CameraStageAction>;
  34430. /**
  34431. * @hidden
  34432. * Defines the actions happening just after a render target has been drawn.
  34433. */
  34434. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34435. /**
  34436. * @hidden
  34437. * Defines the actions happening just after rendering all cameras and computing intersections.
  34438. */
  34439. _afterRenderStage: Stage<SimpleStageAction>;
  34440. /**
  34441. * @hidden
  34442. * Defines the actions happening when a pointer move event happens.
  34443. */
  34444. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34445. /**
  34446. * @hidden
  34447. * Defines the actions happening when a pointer down event happens.
  34448. */
  34449. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34450. /**
  34451. * @hidden
  34452. * Defines the actions happening when a pointer up event happens.
  34453. */
  34454. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34455. /**
  34456. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34457. */
  34458. private geometriesByUniqueId;
  34459. /**
  34460. * Creates a new Scene
  34461. * @param engine defines the engine to use to render this scene
  34462. * @param options defines the scene options
  34463. */
  34464. constructor(engine: Engine, options?: SceneOptions);
  34465. /**
  34466. * Gets a string idenfifying the name of the class
  34467. * @returns "Scene" string
  34468. */
  34469. getClassName(): string;
  34470. private _defaultMeshCandidates;
  34471. /**
  34472. * @hidden
  34473. */
  34474. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34475. private _defaultSubMeshCandidates;
  34476. /**
  34477. * @hidden
  34478. */
  34479. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34480. /**
  34481. * Sets the default candidate providers for the scene.
  34482. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34483. * and getCollidingSubMeshCandidates to their default function
  34484. */
  34485. setDefaultCandidateProviders(): void;
  34486. /**
  34487. * Gets the mesh that is currently under the pointer
  34488. */
  34489. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34490. /**
  34491. * Gets or sets the current on-screen X position of the pointer
  34492. */
  34493. pointerX: number;
  34494. /**
  34495. * Gets or sets the current on-screen Y position of the pointer
  34496. */
  34497. pointerY: number;
  34498. /**
  34499. * Gets the cached material (ie. the latest rendered one)
  34500. * @returns the cached material
  34501. */
  34502. getCachedMaterial(): Nullable<Material>;
  34503. /**
  34504. * Gets the cached effect (ie. the latest rendered one)
  34505. * @returns the cached effect
  34506. */
  34507. getCachedEffect(): Nullable<Effect>;
  34508. /**
  34509. * Gets the cached visibility state (ie. the latest rendered one)
  34510. * @returns the cached visibility state
  34511. */
  34512. getCachedVisibility(): Nullable<number>;
  34513. /**
  34514. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34515. * @param material defines the current material
  34516. * @param effect defines the current effect
  34517. * @param visibility defines the current visibility state
  34518. * @returns true if one parameter is not cached
  34519. */
  34520. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34521. /**
  34522. * Gets the engine associated with the scene
  34523. * @returns an Engine
  34524. */
  34525. getEngine(): Engine;
  34526. /**
  34527. * Gets the total number of vertices rendered per frame
  34528. * @returns the total number of vertices rendered per frame
  34529. */
  34530. getTotalVertices(): number;
  34531. /**
  34532. * Gets the performance counter for total vertices
  34533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34534. */
  34535. readonly totalVerticesPerfCounter: PerfCounter;
  34536. /**
  34537. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34538. * @returns the total number of active indices rendered per frame
  34539. */
  34540. getActiveIndices(): number;
  34541. /**
  34542. * Gets the performance counter for active indices
  34543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34544. */
  34545. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34546. /**
  34547. * Gets the total number of active particles rendered per frame
  34548. * @returns the total number of active particles rendered per frame
  34549. */
  34550. getActiveParticles(): number;
  34551. /**
  34552. * Gets the performance counter for active particles
  34553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34554. */
  34555. readonly activeParticlesPerfCounter: PerfCounter;
  34556. /**
  34557. * Gets the total number of active bones rendered per frame
  34558. * @returns the total number of active bones rendered per frame
  34559. */
  34560. getActiveBones(): number;
  34561. /**
  34562. * Gets the performance counter for active bones
  34563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34564. */
  34565. readonly activeBonesPerfCounter: PerfCounter;
  34566. /**
  34567. * Gets the array of active meshes
  34568. * @returns an array of AbstractMesh
  34569. */
  34570. getActiveMeshes(): SmartArray<AbstractMesh>;
  34571. /**
  34572. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34573. * @returns a number
  34574. */
  34575. getAnimationRatio(): number;
  34576. /**
  34577. * Gets an unique Id for the current render phase
  34578. * @returns a number
  34579. */
  34580. getRenderId(): number;
  34581. /**
  34582. * Gets an unique Id for the current frame
  34583. * @returns a number
  34584. */
  34585. getFrameId(): number;
  34586. /** Call this function if you want to manually increment the render Id*/
  34587. incrementRenderId(): void;
  34588. private _createUbo;
  34589. /**
  34590. * Use this method to simulate a pointer move on a mesh
  34591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34594. * @returns the current scene
  34595. */
  34596. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34597. /**
  34598. * Use this method to simulate a pointer down on a mesh
  34599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34602. * @returns the current scene
  34603. */
  34604. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34605. /**
  34606. * Use this method to simulate a pointer up on a mesh
  34607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34610. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34611. * @returns the current scene
  34612. */
  34613. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34614. /**
  34615. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34616. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34617. * @returns true if the pointer was captured
  34618. */
  34619. isPointerCaptured(pointerId?: number): boolean;
  34620. /**
  34621. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34622. * @param attachUp defines if you want to attach events to pointerup
  34623. * @param attachDown defines if you want to attach events to pointerdown
  34624. * @param attachMove defines if you want to attach events to pointermove
  34625. */
  34626. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34627. /** Detaches all event handlers*/
  34628. detachControl(): void;
  34629. /**
  34630. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34631. * Delay loaded resources are not taking in account
  34632. * @return true if all required resources are ready
  34633. */
  34634. isReady(): boolean;
  34635. /** Resets all cached information relative to material (including effect and visibility) */
  34636. resetCachedMaterial(): void;
  34637. /**
  34638. * Registers a function to be called before every frame render
  34639. * @param func defines the function to register
  34640. */
  34641. registerBeforeRender(func: () => void): void;
  34642. /**
  34643. * Unregisters a function called before every frame render
  34644. * @param func defines the function to unregister
  34645. */
  34646. unregisterBeforeRender(func: () => void): void;
  34647. /**
  34648. * Registers a function to be called after every frame render
  34649. * @param func defines the function to register
  34650. */
  34651. registerAfterRender(func: () => void): void;
  34652. /**
  34653. * Unregisters a function called after every frame render
  34654. * @param func defines the function to unregister
  34655. */
  34656. unregisterAfterRender(func: () => void): void;
  34657. private _executeOnceBeforeRender;
  34658. /**
  34659. * The provided function will run before render once and will be disposed afterwards.
  34660. * A timeout delay can be provided so that the function will be executed in N ms.
  34661. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34662. * @param func The function to be executed.
  34663. * @param timeout optional delay in ms
  34664. */
  34665. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34666. /** @hidden */
  34667. _addPendingData(data: any): void;
  34668. /** @hidden */
  34669. _removePendingData(data: any): void;
  34670. /**
  34671. * Returns the number of items waiting to be loaded
  34672. * @returns the number of items waiting to be loaded
  34673. */
  34674. getWaitingItemsCount(): number;
  34675. /**
  34676. * Returns a boolean indicating if the scene is still loading data
  34677. */
  34678. readonly isLoading: boolean;
  34679. /**
  34680. * Registers a function to be executed when the scene is ready
  34681. * @param {Function} func - the function to be executed
  34682. */
  34683. executeWhenReady(func: () => void): void;
  34684. /**
  34685. * Returns a promise that resolves when the scene is ready
  34686. * @returns A promise that resolves when the scene is ready
  34687. */
  34688. whenReadyAsync(): Promise<void>;
  34689. /** @hidden */
  34690. _checkIsReady(): void;
  34691. /**
  34692. * Gets all animatable attached to the scene
  34693. */
  34694. readonly animatables: Animatable[];
  34695. /**
  34696. * Resets the last animation time frame.
  34697. * Useful to override when animations start running when loading a scene for the first time.
  34698. */
  34699. resetLastAnimationTimeFrame(): void;
  34700. /**
  34701. * Gets the current view matrix
  34702. * @returns a Matrix
  34703. */
  34704. getViewMatrix(): Matrix;
  34705. /**
  34706. * Gets the current projection matrix
  34707. * @returns a Matrix
  34708. */
  34709. getProjectionMatrix(): Matrix;
  34710. /**
  34711. * Gets the current transform matrix
  34712. * @returns a Matrix made of View * Projection
  34713. */
  34714. getTransformMatrix(): Matrix;
  34715. /**
  34716. * Sets the current transform matrix
  34717. * @param viewL defines the View matrix to use
  34718. * @param projectionL defines the Projection matrix to use
  34719. * @param viewR defines the right View matrix to use (if provided)
  34720. * @param projectionR defines the right Projection matrix to use (if provided)
  34721. */
  34722. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34723. /**
  34724. * Gets the uniform buffer used to store scene data
  34725. * @returns a UniformBuffer
  34726. */
  34727. getSceneUniformBuffer(): UniformBuffer;
  34728. /**
  34729. * Gets an unique (relatively to the current scene) Id
  34730. * @returns an unique number for the scene
  34731. */
  34732. getUniqueId(): number;
  34733. /**
  34734. * Add a mesh to the list of scene's meshes
  34735. * @param newMesh defines the mesh to add
  34736. * @param recursive if all child meshes should also be added to the scene
  34737. */
  34738. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34739. /**
  34740. * Remove a mesh for the list of scene's meshes
  34741. * @param toRemove defines the mesh to remove
  34742. * @param recursive if all child meshes should also be removed from the scene
  34743. * @returns the index where the mesh was in the mesh list
  34744. */
  34745. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34746. /**
  34747. * Add a transform node to the list of scene's transform nodes
  34748. * @param newTransformNode defines the transform node to add
  34749. */
  34750. addTransformNode(newTransformNode: TransformNode): void;
  34751. /**
  34752. * Remove a transform node for the list of scene's transform nodes
  34753. * @param toRemove defines the transform node to remove
  34754. * @returns the index where the transform node was in the transform node list
  34755. */
  34756. removeTransformNode(toRemove: TransformNode): number;
  34757. /**
  34758. * Remove a skeleton for the list of scene's skeletons
  34759. * @param toRemove defines the skeleton to remove
  34760. * @returns the index where the skeleton was in the skeleton list
  34761. */
  34762. removeSkeleton(toRemove: Skeleton): number;
  34763. /**
  34764. * Remove a morph target for the list of scene's morph targets
  34765. * @param toRemove defines the morph target to remove
  34766. * @returns the index where the morph target was in the morph target list
  34767. */
  34768. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34769. /**
  34770. * Remove a light for the list of scene's lights
  34771. * @param toRemove defines the light to remove
  34772. * @returns the index where the light was in the light list
  34773. */
  34774. removeLight(toRemove: Light): number;
  34775. /**
  34776. * Remove a camera for the list of scene's cameras
  34777. * @param toRemove defines the camera to remove
  34778. * @returns the index where the camera was in the camera list
  34779. */
  34780. removeCamera(toRemove: Camera): number;
  34781. /**
  34782. * Remove a particle system for the list of scene's particle systems
  34783. * @param toRemove defines the particle system to remove
  34784. * @returns the index where the particle system was in the particle system list
  34785. */
  34786. removeParticleSystem(toRemove: IParticleSystem): number;
  34787. /**
  34788. * Remove a animation for the list of scene's animations
  34789. * @param toRemove defines the animation to remove
  34790. * @returns the index where the animation was in the animation list
  34791. */
  34792. removeAnimation(toRemove: Animation): number;
  34793. /**
  34794. * Will stop the animation of the given target
  34795. * @param target - the target
  34796. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34797. * @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)
  34798. */
  34799. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34800. /**
  34801. * Removes the given animation group from this scene.
  34802. * @param toRemove The animation group to remove
  34803. * @returns The index of the removed animation group
  34804. */
  34805. removeAnimationGroup(toRemove: AnimationGroup): number;
  34806. /**
  34807. * Removes the given multi-material from this scene.
  34808. * @param toRemove The multi-material to remove
  34809. * @returns The index of the removed multi-material
  34810. */
  34811. removeMultiMaterial(toRemove: MultiMaterial): number;
  34812. /**
  34813. * Removes the given material from this scene.
  34814. * @param toRemove The material to remove
  34815. * @returns The index of the removed material
  34816. */
  34817. removeMaterial(toRemove: Material): number;
  34818. /**
  34819. * Removes the given action manager from this scene.
  34820. * @param toRemove The action manager to remove
  34821. * @returns The index of the removed action manager
  34822. */
  34823. removeActionManager(toRemove: AbstractActionManager): number;
  34824. /**
  34825. * Removes the given texture from this scene.
  34826. * @param toRemove The texture to remove
  34827. * @returns The index of the removed texture
  34828. */
  34829. removeTexture(toRemove: BaseTexture): number;
  34830. /**
  34831. * Adds the given light to this scene
  34832. * @param newLight The light to add
  34833. */
  34834. addLight(newLight: Light): void;
  34835. /**
  34836. * Sorts the list list based on light priorities
  34837. */
  34838. sortLightsByPriority(): void;
  34839. /**
  34840. * Adds the given camera to this scene
  34841. * @param newCamera The camera to add
  34842. */
  34843. addCamera(newCamera: Camera): void;
  34844. /**
  34845. * Adds the given skeleton to this scene
  34846. * @param newSkeleton The skeleton to add
  34847. */
  34848. addSkeleton(newSkeleton: Skeleton): void;
  34849. /**
  34850. * Adds the given particle system to this scene
  34851. * @param newParticleSystem The particle system to add
  34852. */
  34853. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34854. /**
  34855. * Adds the given animation to this scene
  34856. * @param newAnimation The animation to add
  34857. */
  34858. addAnimation(newAnimation: Animation): void;
  34859. /**
  34860. * Adds the given animation group to this scene.
  34861. * @param newAnimationGroup The animation group to add
  34862. */
  34863. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34864. /**
  34865. * Adds the given multi-material to this scene
  34866. * @param newMultiMaterial The multi-material to add
  34867. */
  34868. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34869. /**
  34870. * Adds the given material to this scene
  34871. * @param newMaterial The material to add
  34872. */
  34873. addMaterial(newMaterial: Material): void;
  34874. /**
  34875. * Adds the given morph target to this scene
  34876. * @param newMorphTargetManager The morph target to add
  34877. */
  34878. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34879. /**
  34880. * Adds the given geometry to this scene
  34881. * @param newGeometry The geometry to add
  34882. */
  34883. addGeometry(newGeometry: Geometry): void;
  34884. /**
  34885. * Adds the given action manager to this scene
  34886. * @param newActionManager The action manager to add
  34887. */
  34888. addActionManager(newActionManager: AbstractActionManager): void;
  34889. /**
  34890. * Adds the given texture to this scene.
  34891. * @param newTexture The texture to add
  34892. */
  34893. addTexture(newTexture: BaseTexture): void;
  34894. /**
  34895. * Switch active camera
  34896. * @param newCamera defines the new active camera
  34897. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34898. */
  34899. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34900. /**
  34901. * sets the active camera of the scene using its ID
  34902. * @param id defines the camera's ID
  34903. * @return the new active camera or null if none found.
  34904. */
  34905. setActiveCameraByID(id: string): Nullable<Camera>;
  34906. /**
  34907. * sets the active camera of the scene using its name
  34908. * @param name defines the camera's name
  34909. * @returns the new active camera or null if none found.
  34910. */
  34911. setActiveCameraByName(name: string): Nullable<Camera>;
  34912. /**
  34913. * get an animation group using its name
  34914. * @param name defines the material's name
  34915. * @return the animation group or null if none found.
  34916. */
  34917. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34918. /**
  34919. * Get a material using its unique id
  34920. * @param uniqueId defines the material's unique id
  34921. * @return the material or null if none found.
  34922. */
  34923. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34924. /**
  34925. * get a material using its id
  34926. * @param id defines the material's ID
  34927. * @return the material or null if none found.
  34928. */
  34929. getMaterialByID(id: string): Nullable<Material>;
  34930. /**
  34931. * Gets a the last added material using a given id
  34932. * @param id defines the material's ID
  34933. * @return the last material with the given id or null if none found.
  34934. */
  34935. getLastMaterialByID(id: string): Nullable<Material>;
  34936. /**
  34937. * Gets a material using its name
  34938. * @param name defines the material's name
  34939. * @return the material or null if none found.
  34940. */
  34941. getMaterialByName(name: string): Nullable<Material>;
  34942. /**
  34943. * Get a texture using its unique id
  34944. * @param uniqueId defines the texture's unique id
  34945. * @return the texture or null if none found.
  34946. */
  34947. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34948. /**
  34949. * Gets a camera using its id
  34950. * @param id defines the id to look for
  34951. * @returns the camera or null if not found
  34952. */
  34953. getCameraByID(id: string): Nullable<Camera>;
  34954. /**
  34955. * Gets a camera using its unique id
  34956. * @param uniqueId defines the unique id to look for
  34957. * @returns the camera or null if not found
  34958. */
  34959. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34960. /**
  34961. * Gets a camera using its name
  34962. * @param name defines the camera's name
  34963. * @return the camera or null if none found.
  34964. */
  34965. getCameraByName(name: string): Nullable<Camera>;
  34966. /**
  34967. * Gets a bone using its id
  34968. * @param id defines the bone's id
  34969. * @return the bone or null if not found
  34970. */
  34971. getBoneByID(id: string): Nullable<Bone>;
  34972. /**
  34973. * Gets a bone using its id
  34974. * @param name defines the bone's name
  34975. * @return the bone or null if not found
  34976. */
  34977. getBoneByName(name: string): Nullable<Bone>;
  34978. /**
  34979. * Gets a light node using its name
  34980. * @param name defines the the light's name
  34981. * @return the light or null if none found.
  34982. */
  34983. getLightByName(name: string): Nullable<Light>;
  34984. /**
  34985. * Gets a light node using its id
  34986. * @param id defines the light's id
  34987. * @return the light or null if none found.
  34988. */
  34989. getLightByID(id: string): Nullable<Light>;
  34990. /**
  34991. * Gets a light node using its scene-generated unique ID
  34992. * @param uniqueId defines the light's unique id
  34993. * @return the light or null if none found.
  34994. */
  34995. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34996. /**
  34997. * Gets a particle system by id
  34998. * @param id defines the particle system id
  34999. * @return the corresponding system or null if none found
  35000. */
  35001. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35002. /**
  35003. * Gets a geometry using its ID
  35004. * @param id defines the geometry's id
  35005. * @return the geometry or null if none found.
  35006. */
  35007. getGeometryByID(id: string): Nullable<Geometry>;
  35008. private _getGeometryByUniqueID;
  35009. /**
  35010. * Add a new geometry to this scene
  35011. * @param geometry defines the geometry to be added to the scene.
  35012. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35013. * @return a boolean defining if the geometry was added or not
  35014. */
  35015. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35016. /**
  35017. * Removes an existing geometry
  35018. * @param geometry defines the geometry to be removed from the scene
  35019. * @return a boolean defining if the geometry was removed or not
  35020. */
  35021. removeGeometry(geometry: Geometry): boolean;
  35022. /**
  35023. * Gets the list of geometries attached to the scene
  35024. * @returns an array of Geometry
  35025. */
  35026. getGeometries(): Geometry[];
  35027. /**
  35028. * Gets the first added mesh found of a given ID
  35029. * @param id defines the id to search for
  35030. * @return the mesh found or null if not found at all
  35031. */
  35032. getMeshByID(id: string): Nullable<AbstractMesh>;
  35033. /**
  35034. * Gets a list of meshes using their id
  35035. * @param id defines the id to search for
  35036. * @returns a list of meshes
  35037. */
  35038. getMeshesByID(id: string): Array<AbstractMesh>;
  35039. /**
  35040. * Gets the first added transform node found of a given ID
  35041. * @param id defines the id to search for
  35042. * @return the found transform node or null if not found at all.
  35043. */
  35044. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35045. /**
  35046. * Gets a transform node with its auto-generated unique id
  35047. * @param uniqueId efines the unique id to search for
  35048. * @return the found transform node or null if not found at all.
  35049. */
  35050. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35051. /**
  35052. * Gets a list of transform nodes using their id
  35053. * @param id defines the id to search for
  35054. * @returns a list of transform nodes
  35055. */
  35056. getTransformNodesByID(id: string): Array<TransformNode>;
  35057. /**
  35058. * Gets a mesh with its auto-generated unique id
  35059. * @param uniqueId defines the unique id to search for
  35060. * @return the found mesh or null if not found at all.
  35061. */
  35062. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35063. /**
  35064. * Gets a the last added mesh using a given id
  35065. * @param id defines the id to search for
  35066. * @return the found mesh or null if not found at all.
  35067. */
  35068. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35069. /**
  35070. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35071. * @param id defines the id to search for
  35072. * @return the found node or null if not found at all
  35073. */
  35074. getLastEntryByID(id: string): Nullable<Node>;
  35075. /**
  35076. * Gets a node (Mesh, Camera, Light) using a given id
  35077. * @param id defines the id to search for
  35078. * @return the found node or null if not found at all
  35079. */
  35080. getNodeByID(id: string): Nullable<Node>;
  35081. /**
  35082. * Gets a node (Mesh, Camera, Light) using a given name
  35083. * @param name defines the name to search for
  35084. * @return the found node or null if not found at all.
  35085. */
  35086. getNodeByName(name: string): Nullable<Node>;
  35087. /**
  35088. * Gets a mesh using a given name
  35089. * @param name defines the name to search for
  35090. * @return the found mesh or null if not found at all.
  35091. */
  35092. getMeshByName(name: string): Nullable<AbstractMesh>;
  35093. /**
  35094. * Gets a transform node using a given name
  35095. * @param name defines the name to search for
  35096. * @return the found transform node or null if not found at all.
  35097. */
  35098. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35099. /**
  35100. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35101. * @param id defines the id to search for
  35102. * @return the found skeleton or null if not found at all.
  35103. */
  35104. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35105. /**
  35106. * Gets a skeleton using a given auto generated unique id
  35107. * @param uniqueId defines the unique id to search for
  35108. * @return the found skeleton or null if not found at all.
  35109. */
  35110. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35111. /**
  35112. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35113. * @param id defines the id to search for
  35114. * @return the found skeleton or null if not found at all.
  35115. */
  35116. getSkeletonById(id: string): Nullable<Skeleton>;
  35117. /**
  35118. * Gets a skeleton using a given name
  35119. * @param name defines the name to search for
  35120. * @return the found skeleton or null if not found at all.
  35121. */
  35122. getSkeletonByName(name: string): Nullable<Skeleton>;
  35123. /**
  35124. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35125. * @param id defines the id to search for
  35126. * @return the found morph target manager or null if not found at all.
  35127. */
  35128. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35129. /**
  35130. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35131. * @param id defines the id to search for
  35132. * @return the found morph target or null if not found at all.
  35133. */
  35134. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35135. /**
  35136. * Gets a boolean indicating if the given mesh is active
  35137. * @param mesh defines the mesh to look for
  35138. * @returns true if the mesh is in the active list
  35139. */
  35140. isActiveMesh(mesh: AbstractMesh): boolean;
  35141. /**
  35142. * Return a unique id as a string which can serve as an identifier for the scene
  35143. */
  35144. readonly uid: string;
  35145. /**
  35146. * Add an externaly attached data from its key.
  35147. * This method call will fail and return false, if such key already exists.
  35148. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35149. * @param key the unique key that identifies the data
  35150. * @param data the data object to associate to the key for this Engine instance
  35151. * @return true if no such key were already present and the data was added successfully, false otherwise
  35152. */
  35153. addExternalData<T>(key: string, data: T): boolean;
  35154. /**
  35155. * Get an externaly attached data from its key
  35156. * @param key the unique key that identifies the data
  35157. * @return the associated data, if present (can be null), or undefined if not present
  35158. */
  35159. getExternalData<T>(key: string): Nullable<T>;
  35160. /**
  35161. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35162. * @param key the unique key that identifies the data
  35163. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35164. * @return the associated data, can be null if the factory returned null.
  35165. */
  35166. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35167. /**
  35168. * Remove an externaly attached data from the Engine instance
  35169. * @param key the unique key that identifies the data
  35170. * @return true if the data was successfully removed, false if it doesn't exist
  35171. */
  35172. removeExternalData(key: string): boolean;
  35173. private _evaluateSubMesh;
  35174. /**
  35175. * Clear the processed materials smart array preventing retention point in material dispose.
  35176. */
  35177. freeProcessedMaterials(): void;
  35178. private _preventFreeActiveMeshesAndRenderingGroups;
  35179. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35180. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35181. * when disposing several meshes in a row or a hierarchy of meshes.
  35182. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35183. */
  35184. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35185. /**
  35186. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35187. */
  35188. freeActiveMeshes(): void;
  35189. /**
  35190. * Clear the info related to rendering groups preventing retention points during dispose.
  35191. */
  35192. freeRenderingGroups(): void;
  35193. /** @hidden */
  35194. _isInIntermediateRendering(): boolean;
  35195. /**
  35196. * Lambda returning the list of potentially active meshes.
  35197. */
  35198. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35199. /**
  35200. * Lambda returning the list of potentially active sub meshes.
  35201. */
  35202. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35203. /**
  35204. * Lambda returning the list of potentially intersecting sub meshes.
  35205. */
  35206. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35207. /**
  35208. * Lambda returning the list of potentially colliding sub meshes.
  35209. */
  35210. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35211. private _activeMeshesFrozen;
  35212. /**
  35213. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35214. * @returns the current scene
  35215. */
  35216. freezeActiveMeshes(): Scene;
  35217. /**
  35218. * Use this function to restart evaluating active meshes on every frame
  35219. * @returns the current scene
  35220. */
  35221. unfreezeActiveMeshes(): Scene;
  35222. private _evaluateActiveMeshes;
  35223. private _activeMesh;
  35224. /**
  35225. * Update the transform matrix to update from the current active camera
  35226. * @param force defines a boolean used to force the update even if cache is up to date
  35227. */
  35228. updateTransformMatrix(force?: boolean): void;
  35229. private _bindFrameBuffer;
  35230. /** @hidden */
  35231. _allowPostProcessClearColor: boolean;
  35232. /** @hidden */
  35233. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35234. private _processSubCameras;
  35235. private _checkIntersections;
  35236. /** @hidden */
  35237. _advancePhysicsEngineStep(step: number): void;
  35238. /**
  35239. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35240. */
  35241. getDeterministicFrameTime: () => number;
  35242. /** @hidden */
  35243. _animate(): void;
  35244. /** Execute all animations (for a frame) */
  35245. animate(): void;
  35246. /**
  35247. * Render the scene
  35248. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35249. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35250. */
  35251. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35252. /**
  35253. * Freeze all materials
  35254. * A frozen material will not be updatable but should be faster to render
  35255. */
  35256. freezeMaterials(): void;
  35257. /**
  35258. * Unfreeze all materials
  35259. * A frozen material will not be updatable but should be faster to render
  35260. */
  35261. unfreezeMaterials(): void;
  35262. /**
  35263. * Releases all held ressources
  35264. */
  35265. dispose(): void;
  35266. /**
  35267. * Gets if the scene is already disposed
  35268. */
  35269. readonly isDisposed: boolean;
  35270. /**
  35271. * Call this function to reduce memory footprint of the scene.
  35272. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35273. */
  35274. clearCachedVertexData(): void;
  35275. /**
  35276. * This function will remove the local cached buffer data from texture.
  35277. * It will save memory but will prevent the texture from being rebuilt
  35278. */
  35279. cleanCachedTextureBuffer(): void;
  35280. /**
  35281. * Get the world extend vectors with an optional filter
  35282. *
  35283. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35284. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35285. */
  35286. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35287. min: Vector3;
  35288. max: Vector3;
  35289. };
  35290. /**
  35291. * Creates a ray that can be used to pick in the scene
  35292. * @param x defines the x coordinate of the origin (on-screen)
  35293. * @param y defines the y coordinate of the origin (on-screen)
  35294. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35295. * @param camera defines the camera to use for the picking
  35296. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35297. * @returns a Ray
  35298. */
  35299. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35300. /**
  35301. * Creates a ray that can be used to pick in the scene
  35302. * @param x defines the x coordinate of the origin (on-screen)
  35303. * @param y defines the y coordinate of the origin (on-screen)
  35304. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35305. * @param result defines the ray where to store the picking ray
  35306. * @param camera defines the camera to use for the picking
  35307. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35308. * @returns the current scene
  35309. */
  35310. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35311. /**
  35312. * Creates a ray that can be used to pick in the scene
  35313. * @param x defines the x coordinate of the origin (on-screen)
  35314. * @param y defines the y coordinate of the origin (on-screen)
  35315. * @param camera defines the camera to use for the picking
  35316. * @returns a Ray
  35317. */
  35318. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35319. /**
  35320. * Creates a ray that can be used to pick in the scene
  35321. * @param x defines the x coordinate of the origin (on-screen)
  35322. * @param y defines the y coordinate of the origin (on-screen)
  35323. * @param result defines the ray where to store the picking ray
  35324. * @param camera defines the camera to use for the picking
  35325. * @returns the current scene
  35326. */
  35327. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35328. /** Launch a ray to try to pick a mesh in the scene
  35329. * @param x position on screen
  35330. * @param y position on screen
  35331. * @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
  35332. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35333. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35334. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35335. * @returns a PickingInfo
  35336. */
  35337. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35338. /** Use the given ray to pick a mesh in the scene
  35339. * @param ray The ray to use to pick meshes
  35340. * @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
  35341. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35342. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35343. * @returns a PickingInfo
  35344. */
  35345. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35346. /**
  35347. * Launch a ray to try to pick a mesh in the scene
  35348. * @param x X position on screen
  35349. * @param y Y position on screen
  35350. * @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
  35351. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35352. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35353. * @returns an array of PickingInfo
  35354. */
  35355. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35356. /**
  35357. * Launch a ray to try to pick a mesh in the scene
  35358. * @param ray Ray to use
  35359. * @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
  35360. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35361. * @returns an array of PickingInfo
  35362. */
  35363. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35364. /**
  35365. * Force the value of meshUnderPointer
  35366. * @param mesh defines the mesh to use
  35367. */
  35368. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35369. /**
  35370. * Gets the mesh under the pointer
  35371. * @returns a Mesh or null if no mesh is under the pointer
  35372. */
  35373. getPointerOverMesh(): Nullable<AbstractMesh>;
  35374. /** @hidden */
  35375. _rebuildGeometries(): void;
  35376. /** @hidden */
  35377. _rebuildTextures(): void;
  35378. private _getByTags;
  35379. /**
  35380. * Get a list of meshes by tags
  35381. * @param tagsQuery defines the tags query to use
  35382. * @param forEach defines a predicate used to filter results
  35383. * @returns an array of Mesh
  35384. */
  35385. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35386. /**
  35387. * Get a list of cameras by tags
  35388. * @param tagsQuery defines the tags query to use
  35389. * @param forEach defines a predicate used to filter results
  35390. * @returns an array of Camera
  35391. */
  35392. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35393. /**
  35394. * Get a list of lights by tags
  35395. * @param tagsQuery defines the tags query to use
  35396. * @param forEach defines a predicate used to filter results
  35397. * @returns an array of Light
  35398. */
  35399. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35400. /**
  35401. * Get a list of materials by tags
  35402. * @param tagsQuery defines the tags query to use
  35403. * @param forEach defines a predicate used to filter results
  35404. * @returns an array of Material
  35405. */
  35406. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35407. /**
  35408. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35409. * This allowed control for front to back rendering or reversly depending of the special needs.
  35410. *
  35411. * @param renderingGroupId The rendering group id corresponding to its index
  35412. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35413. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35414. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35415. */
  35416. 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;
  35417. /**
  35418. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35419. *
  35420. * @param renderingGroupId The rendering group id corresponding to its index
  35421. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35422. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35423. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35424. */
  35425. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35426. /**
  35427. * Gets the current auto clear configuration for one rendering group of the rendering
  35428. * manager.
  35429. * @param index the rendering group index to get the information for
  35430. * @returns The auto clear setup for the requested rendering group
  35431. */
  35432. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35433. private _blockMaterialDirtyMechanism;
  35434. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35435. blockMaterialDirtyMechanism: boolean;
  35436. /**
  35437. * Will flag all materials as dirty to trigger new shader compilation
  35438. * @param flag defines the flag used to specify which material part must be marked as dirty
  35439. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35440. */
  35441. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35442. /** @hidden */
  35443. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35444. /** @hidden */
  35445. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35446. }
  35447. }
  35448. declare module "babylonjs/assetContainer" {
  35449. import { AbstractScene } from "babylonjs/abstractScene";
  35450. import { Scene } from "babylonjs/scene";
  35451. import { Mesh } from "babylonjs/Meshes/mesh";
  35452. /**
  35453. * Set of assets to keep when moving a scene into an asset container.
  35454. */
  35455. export class KeepAssets extends AbstractScene {
  35456. }
  35457. /**
  35458. * Container with a set of assets that can be added or removed from a scene.
  35459. */
  35460. export class AssetContainer extends AbstractScene {
  35461. /**
  35462. * The scene the AssetContainer belongs to.
  35463. */
  35464. scene: Scene;
  35465. /**
  35466. * Instantiates an AssetContainer.
  35467. * @param scene The scene the AssetContainer belongs to.
  35468. */
  35469. constructor(scene: Scene);
  35470. /**
  35471. * Adds all the assets from the container to the scene.
  35472. */
  35473. addAllToScene(): void;
  35474. /**
  35475. * Removes all the assets in the container from the scene
  35476. */
  35477. removeAllFromScene(): void;
  35478. /**
  35479. * Disposes all the assets in the container
  35480. */
  35481. dispose(): void;
  35482. private _moveAssets;
  35483. /**
  35484. * Removes all the assets contained in the scene and adds them to the container.
  35485. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35486. */
  35487. moveAllFromScene(keepAssets?: KeepAssets): void;
  35488. /**
  35489. * 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.
  35490. * @returns the root mesh
  35491. */
  35492. createRootMesh(): Mesh;
  35493. }
  35494. }
  35495. declare module "babylonjs/abstractScene" {
  35496. import { Scene } from "babylonjs/scene";
  35497. import { Nullable } from "babylonjs/types";
  35498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35500. import { Geometry } from "babylonjs/Meshes/geometry";
  35501. import { Skeleton } from "babylonjs/Bones/skeleton";
  35502. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35503. import { AssetContainer } from "babylonjs/assetContainer";
  35504. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35505. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35507. import { Material } from "babylonjs/Materials/material";
  35508. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35509. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35510. import { Camera } from "babylonjs/Cameras/camera";
  35511. import { Light } from "babylonjs/Lights/light";
  35512. import { Node } from "babylonjs/node";
  35513. import { Animation } from "babylonjs/Animations/animation";
  35514. /**
  35515. * Defines how the parser contract is defined.
  35516. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35517. */
  35518. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35519. /**
  35520. * Defines how the individual parser contract is defined.
  35521. * These parser can parse an individual asset
  35522. */
  35523. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35524. /**
  35525. * Base class of the scene acting as a container for the different elements composing a scene.
  35526. * This class is dynamically extended by the different components of the scene increasing
  35527. * flexibility and reducing coupling
  35528. */
  35529. export abstract class AbstractScene {
  35530. /**
  35531. * Stores the list of available parsers in the application.
  35532. */
  35533. private static _BabylonFileParsers;
  35534. /**
  35535. * Stores the list of available individual parsers in the application.
  35536. */
  35537. private static _IndividualBabylonFileParsers;
  35538. /**
  35539. * Adds a parser in the list of available ones
  35540. * @param name Defines the name of the parser
  35541. * @param parser Defines the parser to add
  35542. */
  35543. static AddParser(name: string, parser: BabylonFileParser): void;
  35544. /**
  35545. * Gets a general parser from the list of avaialble ones
  35546. * @param name Defines the name of the parser
  35547. * @returns the requested parser or null
  35548. */
  35549. static GetParser(name: string): Nullable<BabylonFileParser>;
  35550. /**
  35551. * Adds n individual parser in the list of available ones
  35552. * @param name Defines the name of the parser
  35553. * @param parser Defines the parser to add
  35554. */
  35555. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35556. /**
  35557. * Gets an individual parser from the list of avaialble ones
  35558. * @param name Defines the name of the parser
  35559. * @returns the requested parser or null
  35560. */
  35561. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35562. /**
  35563. * Parser json data and populate both a scene and its associated container object
  35564. * @param jsonData Defines the data to parse
  35565. * @param scene Defines the scene to parse the data for
  35566. * @param container Defines the container attached to the parsing sequence
  35567. * @param rootUrl Defines the root url of the data
  35568. */
  35569. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35570. /**
  35571. * Gets the list of root nodes (ie. nodes with no parent)
  35572. */
  35573. rootNodes: Node[];
  35574. /** All of the cameras added to this scene
  35575. * @see http://doc.babylonjs.com/babylon101/cameras
  35576. */
  35577. cameras: Camera[];
  35578. /**
  35579. * All of the lights added to this scene
  35580. * @see http://doc.babylonjs.com/babylon101/lights
  35581. */
  35582. lights: Light[];
  35583. /**
  35584. * All of the (abstract) meshes added to this scene
  35585. */
  35586. meshes: AbstractMesh[];
  35587. /**
  35588. * The list of skeletons added to the scene
  35589. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35590. */
  35591. skeletons: Skeleton[];
  35592. /**
  35593. * All of the particle systems added to this scene
  35594. * @see http://doc.babylonjs.com/babylon101/particles
  35595. */
  35596. particleSystems: IParticleSystem[];
  35597. /**
  35598. * Gets a list of Animations associated with the scene
  35599. */
  35600. animations: Animation[];
  35601. /**
  35602. * All of the animation groups added to this scene
  35603. * @see http://doc.babylonjs.com/how_to/group
  35604. */
  35605. animationGroups: AnimationGroup[];
  35606. /**
  35607. * All of the multi-materials added to this scene
  35608. * @see http://doc.babylonjs.com/how_to/multi_materials
  35609. */
  35610. multiMaterials: MultiMaterial[];
  35611. /**
  35612. * All of the materials added to this scene
  35613. * In the context of a Scene, it is not supposed to be modified manually.
  35614. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35615. * Note also that the order of the Material wihin the array is not significant and might change.
  35616. * @see http://doc.babylonjs.com/babylon101/materials
  35617. */
  35618. materials: Material[];
  35619. /**
  35620. * The list of morph target managers added to the scene
  35621. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35622. */
  35623. morphTargetManagers: MorphTargetManager[];
  35624. /**
  35625. * The list of geometries used in the scene.
  35626. */
  35627. geometries: Geometry[];
  35628. /**
  35629. * All of the tranform nodes added to this scene
  35630. * In the context of a Scene, it is not supposed to be modified manually.
  35631. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35632. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35633. * @see http://doc.babylonjs.com/how_to/transformnode
  35634. */
  35635. transformNodes: TransformNode[];
  35636. /**
  35637. * ActionManagers available on the scene.
  35638. */
  35639. actionManagers: AbstractActionManager[];
  35640. /**
  35641. * Textures to keep.
  35642. */
  35643. textures: BaseTexture[];
  35644. /**
  35645. * Environment texture for the scene
  35646. */
  35647. environmentTexture: Nullable<BaseTexture>;
  35648. }
  35649. }
  35650. declare module "babylonjs/Audio/sound" {
  35651. import { Observable } from "babylonjs/Misc/observable";
  35652. import { Vector3 } from "babylonjs/Maths/math.vector";
  35653. import { Nullable } from "babylonjs/types";
  35654. import { Scene } from "babylonjs/scene";
  35655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35656. /**
  35657. * Interface used to define options for Sound class
  35658. */
  35659. export interface ISoundOptions {
  35660. /**
  35661. * Does the sound autoplay once loaded.
  35662. */
  35663. autoplay?: boolean;
  35664. /**
  35665. * Does the sound loop after it finishes playing once.
  35666. */
  35667. loop?: boolean;
  35668. /**
  35669. * Sound's volume
  35670. */
  35671. volume?: number;
  35672. /**
  35673. * Is it a spatial sound?
  35674. */
  35675. spatialSound?: boolean;
  35676. /**
  35677. * Maximum distance to hear that sound
  35678. */
  35679. maxDistance?: number;
  35680. /**
  35681. * Uses user defined attenuation function
  35682. */
  35683. useCustomAttenuation?: boolean;
  35684. /**
  35685. * Define the roll off factor of spatial sounds.
  35686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35687. */
  35688. rolloffFactor?: number;
  35689. /**
  35690. * Define the reference distance the sound should be heard perfectly.
  35691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35692. */
  35693. refDistance?: number;
  35694. /**
  35695. * Define the distance attenuation model the sound will follow.
  35696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35697. */
  35698. distanceModel?: string;
  35699. /**
  35700. * Defines the playback speed (1 by default)
  35701. */
  35702. playbackRate?: number;
  35703. /**
  35704. * Defines if the sound is from a streaming source
  35705. */
  35706. streaming?: boolean;
  35707. /**
  35708. * Defines an optional length (in seconds) inside the sound file
  35709. */
  35710. length?: number;
  35711. /**
  35712. * Defines an optional offset (in seconds) inside the sound file
  35713. */
  35714. offset?: number;
  35715. /**
  35716. * If true, URLs will not be required to state the audio file codec to use.
  35717. */
  35718. skipCodecCheck?: boolean;
  35719. }
  35720. /**
  35721. * Defines a sound that can be played in the application.
  35722. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35724. */
  35725. export class Sound {
  35726. /**
  35727. * The name of the sound in the scene.
  35728. */
  35729. name: string;
  35730. /**
  35731. * Does the sound autoplay once loaded.
  35732. */
  35733. autoplay: boolean;
  35734. /**
  35735. * Does the sound loop after it finishes playing once.
  35736. */
  35737. loop: boolean;
  35738. /**
  35739. * Does the sound use a custom attenuation curve to simulate the falloff
  35740. * happening when the source gets further away from the camera.
  35741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35742. */
  35743. useCustomAttenuation: boolean;
  35744. /**
  35745. * The sound track id this sound belongs to.
  35746. */
  35747. soundTrackId: number;
  35748. /**
  35749. * Is this sound currently played.
  35750. */
  35751. isPlaying: boolean;
  35752. /**
  35753. * Is this sound currently paused.
  35754. */
  35755. isPaused: boolean;
  35756. /**
  35757. * Does this sound enables spatial sound.
  35758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35759. */
  35760. spatialSound: boolean;
  35761. /**
  35762. * Define the reference distance the sound should be heard perfectly.
  35763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35764. */
  35765. refDistance: number;
  35766. /**
  35767. * Define the roll off factor of spatial sounds.
  35768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35769. */
  35770. rolloffFactor: number;
  35771. /**
  35772. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35774. */
  35775. maxDistance: number;
  35776. /**
  35777. * Define the distance attenuation model the sound will follow.
  35778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35779. */
  35780. distanceModel: string;
  35781. /**
  35782. * @hidden
  35783. * Back Compat
  35784. **/
  35785. onended: () => any;
  35786. /**
  35787. * Observable event when the current playing sound finishes.
  35788. */
  35789. onEndedObservable: Observable<Sound>;
  35790. private _panningModel;
  35791. private _playbackRate;
  35792. private _streaming;
  35793. private _startTime;
  35794. private _startOffset;
  35795. private _position;
  35796. /** @hidden */
  35797. _positionInEmitterSpace: boolean;
  35798. private _localDirection;
  35799. private _volume;
  35800. private _isReadyToPlay;
  35801. private _isDirectional;
  35802. private _readyToPlayCallback;
  35803. private _audioBuffer;
  35804. private _soundSource;
  35805. private _streamingSource;
  35806. private _soundPanner;
  35807. private _soundGain;
  35808. private _inputAudioNode;
  35809. private _outputAudioNode;
  35810. private _coneInnerAngle;
  35811. private _coneOuterAngle;
  35812. private _coneOuterGain;
  35813. private _scene;
  35814. private _connectedTransformNode;
  35815. private _customAttenuationFunction;
  35816. private _registerFunc;
  35817. private _isOutputConnected;
  35818. private _htmlAudioElement;
  35819. private _urlType;
  35820. private _length?;
  35821. private _offset?;
  35822. /** @hidden */
  35823. static _SceneComponentInitialization: (scene: Scene) => void;
  35824. /**
  35825. * Create a sound and attach it to a scene
  35826. * @param name Name of your sound
  35827. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35828. * @param scene defines the scene the sound belongs to
  35829. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35830. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35831. */
  35832. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35833. /**
  35834. * Release the sound and its associated resources
  35835. */
  35836. dispose(): void;
  35837. /**
  35838. * Gets if the sounds is ready to be played or not.
  35839. * @returns true if ready, otherwise false
  35840. */
  35841. isReady(): boolean;
  35842. private _soundLoaded;
  35843. /**
  35844. * Sets the data of the sound from an audiobuffer
  35845. * @param audioBuffer The audioBuffer containing the data
  35846. */
  35847. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35848. /**
  35849. * Updates the current sounds options such as maxdistance, loop...
  35850. * @param options A JSON object containing values named as the object properties
  35851. */
  35852. updateOptions(options: ISoundOptions): void;
  35853. private _createSpatialParameters;
  35854. private _updateSpatialParameters;
  35855. /**
  35856. * Switch the panning model to HRTF:
  35857. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35859. */
  35860. switchPanningModelToHRTF(): void;
  35861. /**
  35862. * Switch the panning model to Equal Power:
  35863. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35865. */
  35866. switchPanningModelToEqualPower(): void;
  35867. private _switchPanningModel;
  35868. /**
  35869. * Connect this sound to a sound track audio node like gain...
  35870. * @param soundTrackAudioNode the sound track audio node to connect to
  35871. */
  35872. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35873. /**
  35874. * Transform this sound into a directional source
  35875. * @param coneInnerAngle Size of the inner cone in degree
  35876. * @param coneOuterAngle Size of the outer cone in degree
  35877. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35878. */
  35879. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35880. /**
  35881. * Gets or sets the inner angle for the directional cone.
  35882. */
  35883. /**
  35884. * Gets or sets the inner angle for the directional cone.
  35885. */
  35886. directionalConeInnerAngle: number;
  35887. /**
  35888. * Gets or sets the outer angle for the directional cone.
  35889. */
  35890. /**
  35891. * Gets or sets the outer angle for the directional cone.
  35892. */
  35893. directionalConeOuterAngle: number;
  35894. /**
  35895. * Sets the position of the emitter if spatial sound is enabled
  35896. * @param newPosition Defines the new posisiton
  35897. */
  35898. setPosition(newPosition: Vector3): void;
  35899. /**
  35900. * Sets the local direction of the emitter if spatial sound is enabled
  35901. * @param newLocalDirection Defines the new local direction
  35902. */
  35903. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35904. private _updateDirection;
  35905. /** @hidden */
  35906. updateDistanceFromListener(): void;
  35907. /**
  35908. * Sets a new custom attenuation function for the sound.
  35909. * @param callback Defines the function used for the attenuation
  35910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35911. */
  35912. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35913. /**
  35914. * Play the sound
  35915. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35916. * @param offset (optional) Start the sound at a specific time in seconds
  35917. * @param length (optional) Sound duration (in seconds)
  35918. */
  35919. play(time?: number, offset?: number, length?: number): void;
  35920. private _onended;
  35921. /**
  35922. * Stop the sound
  35923. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35924. */
  35925. stop(time?: number): void;
  35926. /**
  35927. * Put the sound in pause
  35928. */
  35929. pause(): void;
  35930. /**
  35931. * Sets a dedicated volume for this sounds
  35932. * @param newVolume Define the new volume of the sound
  35933. * @param time Define time for gradual change to new volume
  35934. */
  35935. setVolume(newVolume: number, time?: number): void;
  35936. /**
  35937. * Set the sound play back rate
  35938. * @param newPlaybackRate Define the playback rate the sound should be played at
  35939. */
  35940. setPlaybackRate(newPlaybackRate: number): void;
  35941. /**
  35942. * Gets the volume of the sound.
  35943. * @returns the volume of the sound
  35944. */
  35945. getVolume(): number;
  35946. /**
  35947. * Attach the sound to a dedicated mesh
  35948. * @param transformNode The transform node to connect the sound with
  35949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35950. */
  35951. attachToMesh(transformNode: TransformNode): void;
  35952. /**
  35953. * Detach the sound from the previously attached mesh
  35954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35955. */
  35956. detachFromMesh(): void;
  35957. private _onRegisterAfterWorldMatrixUpdate;
  35958. /**
  35959. * Clone the current sound in the scene.
  35960. * @returns the new sound clone
  35961. */
  35962. clone(): Nullable<Sound>;
  35963. /**
  35964. * Gets the current underlying audio buffer containing the data
  35965. * @returns the audio buffer
  35966. */
  35967. getAudioBuffer(): Nullable<AudioBuffer>;
  35968. /**
  35969. * Serializes the Sound in a JSON representation
  35970. * @returns the JSON representation of the sound
  35971. */
  35972. serialize(): any;
  35973. /**
  35974. * Parse a JSON representation of a sound to innstantiate in a given scene
  35975. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35976. * @param scene Define the scene the new parsed sound should be created in
  35977. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35978. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35979. * @returns the newly parsed sound
  35980. */
  35981. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35982. }
  35983. }
  35984. declare module "babylonjs/Actions/directAudioActions" {
  35985. import { Action } from "babylonjs/Actions/action";
  35986. import { Condition } from "babylonjs/Actions/condition";
  35987. import { Sound } from "babylonjs/Audio/sound";
  35988. /**
  35989. * This defines an action helpful to play a defined sound on a triggered action.
  35990. */
  35991. export class PlaySoundAction extends Action {
  35992. private _sound;
  35993. /**
  35994. * Instantiate the action
  35995. * @param triggerOptions defines the trigger options
  35996. * @param sound defines the sound to play
  35997. * @param condition defines the trigger related conditions
  35998. */
  35999. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36000. /** @hidden */
  36001. _prepare(): void;
  36002. /**
  36003. * Execute the action and play the sound.
  36004. */
  36005. execute(): void;
  36006. /**
  36007. * Serializes the actions and its related information.
  36008. * @param parent defines the object to serialize in
  36009. * @returns the serialized object
  36010. */
  36011. serialize(parent: any): any;
  36012. }
  36013. /**
  36014. * This defines an action helpful to stop a defined sound on a triggered action.
  36015. */
  36016. export class StopSoundAction extends Action {
  36017. private _sound;
  36018. /**
  36019. * Instantiate the action
  36020. * @param triggerOptions defines the trigger options
  36021. * @param sound defines the sound to stop
  36022. * @param condition defines the trigger related conditions
  36023. */
  36024. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36025. /** @hidden */
  36026. _prepare(): void;
  36027. /**
  36028. * Execute the action and stop the sound.
  36029. */
  36030. execute(): void;
  36031. /**
  36032. * Serializes the actions and its related information.
  36033. * @param parent defines the object to serialize in
  36034. * @returns the serialized object
  36035. */
  36036. serialize(parent: any): any;
  36037. }
  36038. }
  36039. declare module "babylonjs/Actions/interpolateValueAction" {
  36040. import { Action } from "babylonjs/Actions/action";
  36041. import { Condition } from "babylonjs/Actions/condition";
  36042. import { Observable } from "babylonjs/Misc/observable";
  36043. /**
  36044. * This defines an action responsible to change the value of a property
  36045. * by interpolating between its current value and the newly set one once triggered.
  36046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36047. */
  36048. export class InterpolateValueAction extends Action {
  36049. /**
  36050. * Defines the path of the property where the value should be interpolated
  36051. */
  36052. propertyPath: string;
  36053. /**
  36054. * Defines the target value at the end of the interpolation.
  36055. */
  36056. value: any;
  36057. /**
  36058. * Defines the time it will take for the property to interpolate to the value.
  36059. */
  36060. duration: number;
  36061. /**
  36062. * Defines if the other scene animations should be stopped when the action has been triggered
  36063. */
  36064. stopOtherAnimations?: boolean;
  36065. /**
  36066. * Defines a callback raised once the interpolation animation has been done.
  36067. */
  36068. onInterpolationDone?: () => void;
  36069. /**
  36070. * Observable triggered once the interpolation animation has been done.
  36071. */
  36072. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36073. private _target;
  36074. private _effectiveTarget;
  36075. private _property;
  36076. /**
  36077. * Instantiate the action
  36078. * @param triggerOptions defines the trigger options
  36079. * @param target defines the object containing the value to interpolate
  36080. * @param propertyPath defines the path to the property in the target object
  36081. * @param value defines the target value at the end of the interpolation
  36082. * @param duration deines the time it will take for the property to interpolate to the value.
  36083. * @param condition defines the trigger related conditions
  36084. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36085. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36086. */
  36087. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36088. /** @hidden */
  36089. _prepare(): void;
  36090. /**
  36091. * Execute the action starts the value interpolation.
  36092. */
  36093. execute(): void;
  36094. /**
  36095. * Serializes the actions and its related information.
  36096. * @param parent defines the object to serialize in
  36097. * @returns the serialized object
  36098. */
  36099. serialize(parent: any): any;
  36100. }
  36101. }
  36102. declare module "babylonjs/Actions/index" {
  36103. export * from "babylonjs/Actions/abstractActionManager";
  36104. export * from "babylonjs/Actions/action";
  36105. export * from "babylonjs/Actions/actionEvent";
  36106. export * from "babylonjs/Actions/actionManager";
  36107. export * from "babylonjs/Actions/condition";
  36108. export * from "babylonjs/Actions/directActions";
  36109. export * from "babylonjs/Actions/directAudioActions";
  36110. export * from "babylonjs/Actions/interpolateValueAction";
  36111. }
  36112. declare module "babylonjs/Animations/index" {
  36113. export * from "babylonjs/Animations/animatable";
  36114. export * from "babylonjs/Animations/animation";
  36115. export * from "babylonjs/Animations/animationGroup";
  36116. export * from "babylonjs/Animations/animationPropertiesOverride";
  36117. export * from "babylonjs/Animations/easing";
  36118. export * from "babylonjs/Animations/runtimeAnimation";
  36119. export * from "babylonjs/Animations/animationEvent";
  36120. export * from "babylonjs/Animations/animationGroup";
  36121. export * from "babylonjs/Animations/animationKey";
  36122. export * from "babylonjs/Animations/animationRange";
  36123. export * from "babylonjs/Animations/animatable.interface";
  36124. }
  36125. declare module "babylonjs/Audio/soundTrack" {
  36126. import { Sound } from "babylonjs/Audio/sound";
  36127. import { Analyser } from "babylonjs/Audio/analyser";
  36128. import { Scene } from "babylonjs/scene";
  36129. /**
  36130. * Options allowed during the creation of a sound track.
  36131. */
  36132. export interface ISoundTrackOptions {
  36133. /**
  36134. * The volume the sound track should take during creation
  36135. */
  36136. volume?: number;
  36137. /**
  36138. * Define if the sound track is the main sound track of the scene
  36139. */
  36140. mainTrack?: boolean;
  36141. }
  36142. /**
  36143. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36144. * It will be also used in a future release to apply effects on a specific track.
  36145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36146. */
  36147. export class SoundTrack {
  36148. /**
  36149. * The unique identifier of the sound track in the scene.
  36150. */
  36151. id: number;
  36152. /**
  36153. * The list of sounds included in the sound track.
  36154. */
  36155. soundCollection: Array<Sound>;
  36156. private _outputAudioNode;
  36157. private _scene;
  36158. private _isMainTrack;
  36159. private _connectedAnalyser;
  36160. private _options;
  36161. private _isInitialized;
  36162. /**
  36163. * Creates a new sound track.
  36164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36165. * @param scene Define the scene the sound track belongs to
  36166. * @param options
  36167. */
  36168. constructor(scene: Scene, options?: ISoundTrackOptions);
  36169. private _initializeSoundTrackAudioGraph;
  36170. /**
  36171. * Release the sound track and its associated resources
  36172. */
  36173. dispose(): void;
  36174. /**
  36175. * Adds a sound to this sound track
  36176. * @param sound define the cound to add
  36177. * @ignoreNaming
  36178. */
  36179. AddSound(sound: Sound): void;
  36180. /**
  36181. * Removes a sound to this sound track
  36182. * @param sound define the cound to remove
  36183. * @ignoreNaming
  36184. */
  36185. RemoveSound(sound: Sound): void;
  36186. /**
  36187. * Set a global volume for the full sound track.
  36188. * @param newVolume Define the new volume of the sound track
  36189. */
  36190. setVolume(newVolume: number): void;
  36191. /**
  36192. * Switch the panning model to HRTF:
  36193. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36195. */
  36196. switchPanningModelToHRTF(): void;
  36197. /**
  36198. * Switch the panning model to Equal Power:
  36199. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36201. */
  36202. switchPanningModelToEqualPower(): void;
  36203. /**
  36204. * Connect the sound track to an audio analyser allowing some amazing
  36205. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36207. * @param analyser The analyser to connect to the engine
  36208. */
  36209. connectToAnalyser(analyser: Analyser): void;
  36210. }
  36211. }
  36212. declare module "babylonjs/Audio/audioSceneComponent" {
  36213. import { Sound } from "babylonjs/Audio/sound";
  36214. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36215. import { Nullable } from "babylonjs/types";
  36216. import { Vector3 } from "babylonjs/Maths/math.vector";
  36217. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36218. import { Scene } from "babylonjs/scene";
  36219. import { AbstractScene } from "babylonjs/abstractScene";
  36220. import "babylonjs/Audio/audioEngine";
  36221. module "babylonjs/abstractScene" {
  36222. interface AbstractScene {
  36223. /**
  36224. * The list of sounds used in the scene.
  36225. */
  36226. sounds: Nullable<Array<Sound>>;
  36227. }
  36228. }
  36229. module "babylonjs/scene" {
  36230. interface Scene {
  36231. /**
  36232. * @hidden
  36233. * Backing field
  36234. */
  36235. _mainSoundTrack: SoundTrack;
  36236. /**
  36237. * The main sound track played by the scene.
  36238. * It cotains your primary collection of sounds.
  36239. */
  36240. mainSoundTrack: SoundTrack;
  36241. /**
  36242. * The list of sound tracks added to the scene
  36243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36244. */
  36245. soundTracks: Nullable<Array<SoundTrack>>;
  36246. /**
  36247. * Gets a sound using a given name
  36248. * @param name defines the name to search for
  36249. * @return the found sound or null if not found at all.
  36250. */
  36251. getSoundByName(name: string): Nullable<Sound>;
  36252. /**
  36253. * Gets or sets if audio support is enabled
  36254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36255. */
  36256. audioEnabled: boolean;
  36257. /**
  36258. * Gets or sets if audio will be output to headphones
  36259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36260. */
  36261. headphone: boolean;
  36262. /**
  36263. * Gets or sets custom audio listener position provider
  36264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36265. */
  36266. audioListenerPositionProvider: Nullable<() => Vector3>;
  36267. }
  36268. }
  36269. /**
  36270. * Defines the sound scene component responsible to manage any sounds
  36271. * in a given scene.
  36272. */
  36273. export class AudioSceneComponent implements ISceneSerializableComponent {
  36274. /**
  36275. * The component name helpfull to identify the component in the list of scene components.
  36276. */
  36277. readonly name: string;
  36278. /**
  36279. * The scene the component belongs to.
  36280. */
  36281. scene: Scene;
  36282. private _audioEnabled;
  36283. /**
  36284. * Gets whether audio is enabled or not.
  36285. * Please use related enable/disable method to switch state.
  36286. */
  36287. readonly audioEnabled: boolean;
  36288. private _headphone;
  36289. /**
  36290. * Gets whether audio is outputing to headphone or not.
  36291. * Please use the according Switch methods to change output.
  36292. */
  36293. readonly headphone: boolean;
  36294. private _audioListenerPositionProvider;
  36295. /**
  36296. * Gets the current audio listener position provider
  36297. */
  36298. /**
  36299. * Sets a custom listener position for all sounds in the scene
  36300. * By default, this is the position of the first active camera
  36301. */
  36302. audioListenerPositionProvider: Nullable<() => Vector3>;
  36303. /**
  36304. * Creates a new instance of the component for the given scene
  36305. * @param scene Defines the scene to register the component in
  36306. */
  36307. constructor(scene: Scene);
  36308. /**
  36309. * Registers the component in a given scene
  36310. */
  36311. register(): void;
  36312. /**
  36313. * Rebuilds the elements related to this component in case of
  36314. * context lost for instance.
  36315. */
  36316. rebuild(): void;
  36317. /**
  36318. * Serializes the component data to the specified json object
  36319. * @param serializationObject The object to serialize to
  36320. */
  36321. serialize(serializationObject: any): void;
  36322. /**
  36323. * Adds all the elements from the container to the scene
  36324. * @param container the container holding the elements
  36325. */
  36326. addFromContainer(container: AbstractScene): void;
  36327. /**
  36328. * Removes all the elements in the container from the scene
  36329. * @param container contains the elements to remove
  36330. * @param dispose if the removed element should be disposed (default: false)
  36331. */
  36332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36333. /**
  36334. * Disposes the component and the associated ressources.
  36335. */
  36336. dispose(): void;
  36337. /**
  36338. * Disables audio in the associated scene.
  36339. */
  36340. disableAudio(): void;
  36341. /**
  36342. * Enables audio in the associated scene.
  36343. */
  36344. enableAudio(): void;
  36345. /**
  36346. * Switch audio to headphone output.
  36347. */
  36348. switchAudioModeForHeadphones(): void;
  36349. /**
  36350. * Switch audio to normal speakers.
  36351. */
  36352. switchAudioModeForNormalSpeakers(): void;
  36353. private _afterRender;
  36354. }
  36355. }
  36356. declare module "babylonjs/Audio/weightedsound" {
  36357. import { Sound } from "babylonjs/Audio/sound";
  36358. /**
  36359. * Wraps one or more Sound objects and selects one with random weight for playback.
  36360. */
  36361. export class WeightedSound {
  36362. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36363. loop: boolean;
  36364. private _coneInnerAngle;
  36365. private _coneOuterAngle;
  36366. private _volume;
  36367. /** A Sound is currently playing. */
  36368. isPlaying: boolean;
  36369. /** A Sound is currently paused. */
  36370. isPaused: boolean;
  36371. private _sounds;
  36372. private _weights;
  36373. private _currentIndex?;
  36374. /**
  36375. * Creates a new WeightedSound from the list of sounds given.
  36376. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36377. * @param sounds Array of Sounds that will be selected from.
  36378. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36379. */
  36380. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36381. /**
  36382. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36383. */
  36384. /**
  36385. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36386. */
  36387. directionalConeInnerAngle: number;
  36388. /**
  36389. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36390. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36391. */
  36392. /**
  36393. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36394. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36395. */
  36396. directionalConeOuterAngle: number;
  36397. /**
  36398. * Playback volume.
  36399. */
  36400. /**
  36401. * Playback volume.
  36402. */
  36403. volume: number;
  36404. private _onended;
  36405. /**
  36406. * Suspend playback
  36407. */
  36408. pause(): void;
  36409. /**
  36410. * Stop playback
  36411. */
  36412. stop(): void;
  36413. /**
  36414. * Start playback.
  36415. * @param startOffset Position the clip head at a specific time in seconds.
  36416. */
  36417. play(startOffset?: number): void;
  36418. }
  36419. }
  36420. declare module "babylonjs/Audio/index" {
  36421. export * from "babylonjs/Audio/analyser";
  36422. export * from "babylonjs/Audio/audioEngine";
  36423. export * from "babylonjs/Audio/audioSceneComponent";
  36424. export * from "babylonjs/Audio/sound";
  36425. export * from "babylonjs/Audio/soundTrack";
  36426. export * from "babylonjs/Audio/weightedsound";
  36427. }
  36428. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36429. import { Behavior } from "babylonjs/Behaviors/behavior";
  36430. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36431. import { BackEase } from "babylonjs/Animations/easing";
  36432. /**
  36433. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36435. */
  36436. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36437. /**
  36438. * Gets the name of the behavior.
  36439. */
  36440. readonly name: string;
  36441. /**
  36442. * The easing function used by animations
  36443. */
  36444. static EasingFunction: BackEase;
  36445. /**
  36446. * The easing mode used by animations
  36447. */
  36448. static EasingMode: number;
  36449. /**
  36450. * The duration of the animation, in milliseconds
  36451. */
  36452. transitionDuration: number;
  36453. /**
  36454. * Length of the distance animated by the transition when lower radius is reached
  36455. */
  36456. lowerRadiusTransitionRange: number;
  36457. /**
  36458. * Length of the distance animated by the transition when upper radius is reached
  36459. */
  36460. upperRadiusTransitionRange: number;
  36461. private _autoTransitionRange;
  36462. /**
  36463. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36464. */
  36465. /**
  36466. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36467. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36468. */
  36469. autoTransitionRange: boolean;
  36470. private _attachedCamera;
  36471. private _onAfterCheckInputsObserver;
  36472. private _onMeshTargetChangedObserver;
  36473. /**
  36474. * Initializes the behavior.
  36475. */
  36476. init(): void;
  36477. /**
  36478. * Attaches the behavior to its arc rotate camera.
  36479. * @param camera Defines the camera to attach the behavior to
  36480. */
  36481. attach(camera: ArcRotateCamera): void;
  36482. /**
  36483. * Detaches the behavior from its current arc rotate camera.
  36484. */
  36485. detach(): void;
  36486. private _radiusIsAnimating;
  36487. private _radiusBounceTransition;
  36488. private _animatables;
  36489. private _cachedWheelPrecision;
  36490. /**
  36491. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36492. * @param radiusLimit The limit to check against.
  36493. * @return Bool to indicate if at limit.
  36494. */
  36495. private _isRadiusAtLimit;
  36496. /**
  36497. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36498. * @param radiusDelta The delta by which to animate to. Can be negative.
  36499. */
  36500. private _applyBoundRadiusAnimation;
  36501. /**
  36502. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36503. */
  36504. protected _clearAnimationLocks(): void;
  36505. /**
  36506. * Stops and removes all animations that have been applied to the camera
  36507. */
  36508. stopAllAnimations(): void;
  36509. }
  36510. }
  36511. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36512. import { Behavior } from "babylonjs/Behaviors/behavior";
  36513. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36514. import { ExponentialEase } from "babylonjs/Animations/easing";
  36515. import { Nullable } from "babylonjs/types";
  36516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36517. import { Vector3 } from "babylonjs/Maths/math.vector";
  36518. /**
  36519. * 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.
  36520. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36521. */
  36522. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36523. /**
  36524. * Gets the name of the behavior.
  36525. */
  36526. readonly name: string;
  36527. private _mode;
  36528. private _radiusScale;
  36529. private _positionScale;
  36530. private _defaultElevation;
  36531. private _elevationReturnTime;
  36532. private _elevationReturnWaitTime;
  36533. private _zoomStopsAnimation;
  36534. private _framingTime;
  36535. /**
  36536. * The easing function used by animations
  36537. */
  36538. static EasingFunction: ExponentialEase;
  36539. /**
  36540. * The easing mode used by animations
  36541. */
  36542. static EasingMode: number;
  36543. /**
  36544. * Sets the current mode used by the behavior
  36545. */
  36546. /**
  36547. * Gets current mode used by the behavior.
  36548. */
  36549. mode: number;
  36550. /**
  36551. * Sets the scale applied to the radius (1 by default)
  36552. */
  36553. /**
  36554. * Gets the scale applied to the radius
  36555. */
  36556. radiusScale: number;
  36557. /**
  36558. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36559. */
  36560. /**
  36561. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36562. */
  36563. positionScale: number;
  36564. /**
  36565. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36566. * behaviour is triggered, in radians.
  36567. */
  36568. /**
  36569. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36570. * behaviour is triggered, in radians.
  36571. */
  36572. defaultElevation: number;
  36573. /**
  36574. * Sets the time (in milliseconds) taken to return to the default beta position.
  36575. * Negative value indicates camera should not return to default.
  36576. */
  36577. /**
  36578. * Gets the time (in milliseconds) taken to return to the default beta position.
  36579. * Negative value indicates camera should not return to default.
  36580. */
  36581. elevationReturnTime: number;
  36582. /**
  36583. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36584. */
  36585. /**
  36586. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36587. */
  36588. elevationReturnWaitTime: number;
  36589. /**
  36590. * Sets the flag that indicates if user zooming should stop animation.
  36591. */
  36592. /**
  36593. * Gets the flag that indicates if user zooming should stop animation.
  36594. */
  36595. zoomStopsAnimation: boolean;
  36596. /**
  36597. * Sets the transition time when framing the mesh, in milliseconds
  36598. */
  36599. /**
  36600. * Gets the transition time when framing the mesh, in milliseconds
  36601. */
  36602. framingTime: number;
  36603. /**
  36604. * Define if the behavior should automatically change the configured
  36605. * camera limits and sensibilities.
  36606. */
  36607. autoCorrectCameraLimitsAndSensibility: boolean;
  36608. private _onPrePointerObservableObserver;
  36609. private _onAfterCheckInputsObserver;
  36610. private _onMeshTargetChangedObserver;
  36611. private _attachedCamera;
  36612. private _isPointerDown;
  36613. private _lastInteractionTime;
  36614. /**
  36615. * Initializes the behavior.
  36616. */
  36617. init(): void;
  36618. /**
  36619. * Attaches the behavior to its arc rotate camera.
  36620. * @param camera Defines the camera to attach the behavior to
  36621. */
  36622. attach(camera: ArcRotateCamera): void;
  36623. /**
  36624. * Detaches the behavior from its current arc rotate camera.
  36625. */
  36626. detach(): void;
  36627. private _animatables;
  36628. private _betaIsAnimating;
  36629. private _betaTransition;
  36630. private _radiusTransition;
  36631. private _vectorTransition;
  36632. /**
  36633. * Targets the given mesh and updates zoom level accordingly.
  36634. * @param mesh The mesh to target.
  36635. * @param radius Optional. If a cached radius position already exists, overrides default.
  36636. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36637. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36638. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36639. */
  36640. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36641. /**
  36642. * Targets the given mesh with its children and updates zoom level accordingly.
  36643. * @param mesh The mesh to target.
  36644. * @param radius Optional. If a cached radius position already exists, overrides default.
  36645. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36646. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36647. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36648. */
  36649. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36650. /**
  36651. * Targets the given meshes with their children and updates zoom level accordingly.
  36652. * @param meshes The mesh to target.
  36653. * @param radius Optional. If a cached radius position already exists, overrides default.
  36654. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36655. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36656. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36657. */
  36658. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36659. /**
  36660. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36661. * @param minimumWorld Determines the smaller position of the bounding box extend
  36662. * @param maximumWorld Determines the bigger position of the bounding box extend
  36663. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36664. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36665. */
  36666. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36667. /**
  36668. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36669. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36670. * frustum width.
  36671. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36672. * to fully enclose the mesh in the viewing frustum.
  36673. */
  36674. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36675. /**
  36676. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36677. * is automatically returned to its default position (expected to be above ground plane).
  36678. */
  36679. private _maintainCameraAboveGround;
  36680. /**
  36681. * Returns the frustum slope based on the canvas ratio and camera FOV
  36682. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36683. */
  36684. private _getFrustumSlope;
  36685. /**
  36686. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36687. */
  36688. private _clearAnimationLocks;
  36689. /**
  36690. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36691. */
  36692. private _applyUserInteraction;
  36693. /**
  36694. * Stops and removes all animations that have been applied to the camera
  36695. */
  36696. stopAllAnimations(): void;
  36697. /**
  36698. * Gets a value indicating if the user is moving the camera
  36699. */
  36700. readonly isUserIsMoving: boolean;
  36701. /**
  36702. * The camera can move all the way towards the mesh.
  36703. */
  36704. static IgnoreBoundsSizeMode: number;
  36705. /**
  36706. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36707. */
  36708. static FitFrustumSidesMode: number;
  36709. }
  36710. }
  36711. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36712. import { Nullable } from "babylonjs/types";
  36713. import { Camera } from "babylonjs/Cameras/camera";
  36714. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36715. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36716. /**
  36717. * Base class for Camera Pointer Inputs.
  36718. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36719. * for example usage.
  36720. */
  36721. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36722. /**
  36723. * Defines the camera the input is attached to.
  36724. */
  36725. abstract camera: Camera;
  36726. /**
  36727. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36728. */
  36729. protected _altKey: boolean;
  36730. protected _ctrlKey: boolean;
  36731. protected _metaKey: boolean;
  36732. protected _shiftKey: boolean;
  36733. /**
  36734. * Which mouse buttons were pressed at time of last mouse event.
  36735. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36736. */
  36737. protected _buttonsPressed: number;
  36738. /**
  36739. * Defines the buttons associated with the input to handle camera move.
  36740. */
  36741. buttons: number[];
  36742. /**
  36743. * Attach the input controls to a specific dom element to get the input from.
  36744. * @param element Defines the element the controls should be listened from
  36745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36746. */
  36747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36748. /**
  36749. * Detach the current controls from the specified dom element.
  36750. * @param element Defines the element to stop listening the inputs from
  36751. */
  36752. detachControl(element: Nullable<HTMLElement>): void;
  36753. /**
  36754. * Gets the class name of the current input.
  36755. * @returns the class name
  36756. */
  36757. getClassName(): string;
  36758. /**
  36759. * Get the friendly name associated with the input class.
  36760. * @returns the input friendly name
  36761. */
  36762. getSimpleName(): string;
  36763. /**
  36764. * Called on pointer POINTERDOUBLETAP event.
  36765. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36766. */
  36767. protected onDoubleTap(type: string): void;
  36768. /**
  36769. * Called on pointer POINTERMOVE event if only a single touch is active.
  36770. * Override this method to provide functionality.
  36771. */
  36772. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36773. /**
  36774. * Called on pointer POINTERMOVE event if multiple touches are active.
  36775. * Override this method to provide functionality.
  36776. */
  36777. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36778. /**
  36779. * Called on JS contextmenu event.
  36780. * Override this method to provide functionality.
  36781. */
  36782. protected onContextMenu(evt: PointerEvent): void;
  36783. /**
  36784. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36785. * press.
  36786. * Override this method to provide functionality.
  36787. */
  36788. protected onButtonDown(evt: PointerEvent): void;
  36789. /**
  36790. * Called each time a new POINTERUP event occurs. Ie, for each button
  36791. * release.
  36792. * Override this method to provide functionality.
  36793. */
  36794. protected onButtonUp(evt: PointerEvent): void;
  36795. /**
  36796. * Called when window becomes inactive.
  36797. * Override this method to provide functionality.
  36798. */
  36799. protected onLostFocus(): void;
  36800. private _pointerInput;
  36801. private _observer;
  36802. private _onLostFocus;
  36803. private pointA;
  36804. private pointB;
  36805. }
  36806. }
  36807. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36808. import { Nullable } from "babylonjs/types";
  36809. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36810. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36811. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36812. /**
  36813. * Manage the pointers inputs to control an arc rotate camera.
  36814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36815. */
  36816. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36817. /**
  36818. * Defines the camera the input is attached to.
  36819. */
  36820. camera: ArcRotateCamera;
  36821. /**
  36822. * Gets the class name of the current input.
  36823. * @returns the class name
  36824. */
  36825. getClassName(): string;
  36826. /**
  36827. * Defines the buttons associated with the input to handle camera move.
  36828. */
  36829. buttons: number[];
  36830. /**
  36831. * Defines the pointer angular sensibility along the X axis or how fast is
  36832. * the camera rotating.
  36833. */
  36834. angularSensibilityX: number;
  36835. /**
  36836. * Defines the pointer angular sensibility along the Y axis or how fast is
  36837. * the camera rotating.
  36838. */
  36839. angularSensibilityY: number;
  36840. /**
  36841. * Defines the pointer pinch precision or how fast is the camera zooming.
  36842. */
  36843. pinchPrecision: number;
  36844. /**
  36845. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36846. * from 0.
  36847. * It defines the percentage of current camera.radius to use as delta when
  36848. * pinch zoom is used.
  36849. */
  36850. pinchDeltaPercentage: number;
  36851. /**
  36852. * Defines the pointer panning sensibility or how fast is the camera moving.
  36853. */
  36854. panningSensibility: number;
  36855. /**
  36856. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36857. */
  36858. multiTouchPanning: boolean;
  36859. /**
  36860. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36861. * zoom (pinch) through multitouch.
  36862. */
  36863. multiTouchPanAndZoom: boolean;
  36864. /**
  36865. * Revers pinch action direction.
  36866. */
  36867. pinchInwards: boolean;
  36868. private _isPanClick;
  36869. private _twoFingerActivityCount;
  36870. private _isPinching;
  36871. /**
  36872. * Called on pointer POINTERMOVE event if only a single touch is active.
  36873. */
  36874. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36875. /**
  36876. * Called on pointer POINTERDOUBLETAP event.
  36877. */
  36878. protected onDoubleTap(type: string): void;
  36879. /**
  36880. * Called on pointer POINTERMOVE event if multiple touches are active.
  36881. */
  36882. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36883. /**
  36884. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36885. * press.
  36886. */
  36887. protected onButtonDown(evt: PointerEvent): void;
  36888. /**
  36889. * Called each time a new POINTERUP event occurs. Ie, for each button
  36890. * release.
  36891. */
  36892. protected onButtonUp(evt: PointerEvent): void;
  36893. /**
  36894. * Called when window becomes inactive.
  36895. */
  36896. protected onLostFocus(): void;
  36897. }
  36898. }
  36899. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36900. import { Nullable } from "babylonjs/types";
  36901. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36902. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36903. /**
  36904. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36906. */
  36907. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36908. /**
  36909. * Defines the camera the input is attached to.
  36910. */
  36911. camera: ArcRotateCamera;
  36912. /**
  36913. * Defines the list of key codes associated with the up action (increase alpha)
  36914. */
  36915. keysUp: number[];
  36916. /**
  36917. * Defines the list of key codes associated with the down action (decrease alpha)
  36918. */
  36919. keysDown: number[];
  36920. /**
  36921. * Defines the list of key codes associated with the left action (increase beta)
  36922. */
  36923. keysLeft: number[];
  36924. /**
  36925. * Defines the list of key codes associated with the right action (decrease beta)
  36926. */
  36927. keysRight: number[];
  36928. /**
  36929. * Defines the list of key codes associated with the reset action.
  36930. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36931. */
  36932. keysReset: number[];
  36933. /**
  36934. * Defines the panning sensibility of the inputs.
  36935. * (How fast is the camera paning)
  36936. */
  36937. panningSensibility: number;
  36938. /**
  36939. * Defines the zooming sensibility of the inputs.
  36940. * (How fast is the camera zooming)
  36941. */
  36942. zoomingSensibility: number;
  36943. /**
  36944. * Defines wether maintaining the alt key down switch the movement mode from
  36945. * orientation to zoom.
  36946. */
  36947. useAltToZoom: boolean;
  36948. /**
  36949. * Rotation speed of the camera
  36950. */
  36951. angularSpeed: number;
  36952. private _keys;
  36953. private _ctrlPressed;
  36954. private _altPressed;
  36955. private _onCanvasBlurObserver;
  36956. private _onKeyboardObserver;
  36957. private _engine;
  36958. private _scene;
  36959. /**
  36960. * Attach the input controls to a specific dom element to get the input from.
  36961. * @param element Defines the element the controls should be listened from
  36962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36963. */
  36964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36965. /**
  36966. * Detach the current controls from the specified dom element.
  36967. * @param element Defines the element to stop listening the inputs from
  36968. */
  36969. detachControl(element: Nullable<HTMLElement>): void;
  36970. /**
  36971. * Update the current camera state depending on the inputs that have been used this frame.
  36972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36973. */
  36974. checkInputs(): void;
  36975. /**
  36976. * Gets the class name of the current intput.
  36977. * @returns the class name
  36978. */
  36979. getClassName(): string;
  36980. /**
  36981. * Get the friendly name associated with the input class.
  36982. * @returns the input friendly name
  36983. */
  36984. getSimpleName(): string;
  36985. }
  36986. }
  36987. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36988. import { Nullable } from "babylonjs/types";
  36989. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36990. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36991. /**
  36992. * Manage the mouse wheel inputs to control an arc rotate camera.
  36993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36994. */
  36995. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36996. /**
  36997. * Defines the camera the input is attached to.
  36998. */
  36999. camera: ArcRotateCamera;
  37000. /**
  37001. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37002. */
  37003. wheelPrecision: number;
  37004. /**
  37005. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37006. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37007. */
  37008. wheelDeltaPercentage: number;
  37009. private _wheel;
  37010. private _observer;
  37011. private computeDeltaFromMouseWheelLegacyEvent;
  37012. /**
  37013. * Attach the input controls to a specific dom element to get the input from.
  37014. * @param element Defines the element the controls should be listened from
  37015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37016. */
  37017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37018. /**
  37019. * Detach the current controls from the specified dom element.
  37020. * @param element Defines the element to stop listening the inputs from
  37021. */
  37022. detachControl(element: Nullable<HTMLElement>): void;
  37023. /**
  37024. * Gets the class name of the current intput.
  37025. * @returns the class name
  37026. */
  37027. getClassName(): string;
  37028. /**
  37029. * Get the friendly name associated with the input class.
  37030. * @returns the input friendly name
  37031. */
  37032. getSimpleName(): string;
  37033. }
  37034. }
  37035. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37036. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37037. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37038. /**
  37039. * Default Inputs manager for the ArcRotateCamera.
  37040. * It groups all the default supported inputs for ease of use.
  37041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37042. */
  37043. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37044. /**
  37045. * Instantiates a new ArcRotateCameraInputsManager.
  37046. * @param camera Defines the camera the inputs belong to
  37047. */
  37048. constructor(camera: ArcRotateCamera);
  37049. /**
  37050. * Add mouse wheel input support to the input manager.
  37051. * @returns the current input manager
  37052. */
  37053. addMouseWheel(): ArcRotateCameraInputsManager;
  37054. /**
  37055. * Add pointers input support to the input manager.
  37056. * @returns the current input manager
  37057. */
  37058. addPointers(): ArcRotateCameraInputsManager;
  37059. /**
  37060. * Add keyboard input support to the input manager.
  37061. * @returns the current input manager
  37062. */
  37063. addKeyboard(): ArcRotateCameraInputsManager;
  37064. }
  37065. }
  37066. declare module "babylonjs/Cameras/arcRotateCamera" {
  37067. import { Observable } from "babylonjs/Misc/observable";
  37068. import { Nullable } from "babylonjs/types";
  37069. import { Scene } from "babylonjs/scene";
  37070. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37072. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37073. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37074. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37075. import { Camera } from "babylonjs/Cameras/camera";
  37076. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37077. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37078. import { Collider } from "babylonjs/Collisions/collider";
  37079. /**
  37080. * This represents an orbital type of camera.
  37081. *
  37082. * 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.
  37083. * 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.
  37084. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37085. */
  37086. export class ArcRotateCamera extends TargetCamera {
  37087. /**
  37088. * Defines the rotation angle of the camera along the longitudinal axis.
  37089. */
  37090. alpha: number;
  37091. /**
  37092. * Defines the rotation angle of the camera along the latitudinal axis.
  37093. */
  37094. beta: number;
  37095. /**
  37096. * Defines the radius of the camera from it s target point.
  37097. */
  37098. radius: number;
  37099. protected _target: Vector3;
  37100. protected _targetHost: Nullable<AbstractMesh>;
  37101. /**
  37102. * Defines the target point of the camera.
  37103. * The camera looks towards it form the radius distance.
  37104. */
  37105. target: Vector3;
  37106. /**
  37107. * Define the current local position of the camera in the scene
  37108. */
  37109. position: Vector3;
  37110. protected _upVector: Vector3;
  37111. protected _upToYMatrix: Matrix;
  37112. protected _YToUpMatrix: Matrix;
  37113. /**
  37114. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37115. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37116. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37117. */
  37118. upVector: Vector3;
  37119. /**
  37120. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37121. */
  37122. setMatUp(): void;
  37123. /**
  37124. * Current inertia value on the longitudinal axis.
  37125. * The bigger this number the longer it will take for the camera to stop.
  37126. */
  37127. inertialAlphaOffset: number;
  37128. /**
  37129. * Current inertia value on the latitudinal axis.
  37130. * The bigger this number the longer it will take for the camera to stop.
  37131. */
  37132. inertialBetaOffset: number;
  37133. /**
  37134. * Current inertia value on the radius axis.
  37135. * The bigger this number the longer it will take for the camera to stop.
  37136. */
  37137. inertialRadiusOffset: number;
  37138. /**
  37139. * Minimum allowed angle on the longitudinal axis.
  37140. * This can help limiting how the Camera is able to move in the scene.
  37141. */
  37142. lowerAlphaLimit: Nullable<number>;
  37143. /**
  37144. * Maximum allowed angle on the longitudinal axis.
  37145. * This can help limiting how the Camera is able to move in the scene.
  37146. */
  37147. upperAlphaLimit: Nullable<number>;
  37148. /**
  37149. * Minimum allowed angle on the latitudinal axis.
  37150. * This can help limiting how the Camera is able to move in the scene.
  37151. */
  37152. lowerBetaLimit: number;
  37153. /**
  37154. * Maximum allowed angle on the latitudinal axis.
  37155. * This can help limiting how the Camera is able to move in the scene.
  37156. */
  37157. upperBetaLimit: number;
  37158. /**
  37159. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37160. * This can help limiting how the Camera is able to move in the scene.
  37161. */
  37162. lowerRadiusLimit: Nullable<number>;
  37163. /**
  37164. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37165. * This can help limiting how the Camera is able to move in the scene.
  37166. */
  37167. upperRadiusLimit: Nullable<number>;
  37168. /**
  37169. * Defines the current inertia value used during panning of the camera along the X axis.
  37170. */
  37171. inertialPanningX: number;
  37172. /**
  37173. * Defines the current inertia value used during panning of the camera along the Y axis.
  37174. */
  37175. inertialPanningY: number;
  37176. /**
  37177. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37178. * Basically if your fingers moves away from more than this distance you will be considered
  37179. * in pinch mode.
  37180. */
  37181. pinchToPanMaxDistance: number;
  37182. /**
  37183. * Defines the maximum distance the camera can pan.
  37184. * This could help keeping the cammera always in your scene.
  37185. */
  37186. panningDistanceLimit: Nullable<number>;
  37187. /**
  37188. * Defines the target of the camera before paning.
  37189. */
  37190. panningOriginTarget: Vector3;
  37191. /**
  37192. * Defines the value of the inertia used during panning.
  37193. * 0 would mean stop inertia and one would mean no decelleration at all.
  37194. */
  37195. panningInertia: number;
  37196. /**
  37197. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37198. */
  37199. angularSensibilityX: number;
  37200. /**
  37201. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37202. */
  37203. angularSensibilityY: number;
  37204. /**
  37205. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37206. */
  37207. pinchPrecision: number;
  37208. /**
  37209. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37210. * It will be used instead of pinchDeltaPrecision if different from 0.
  37211. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37212. */
  37213. pinchDeltaPercentage: number;
  37214. /**
  37215. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37216. */
  37217. panningSensibility: number;
  37218. /**
  37219. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37220. */
  37221. keysUp: number[];
  37222. /**
  37223. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37224. */
  37225. keysDown: number[];
  37226. /**
  37227. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37228. */
  37229. keysLeft: number[];
  37230. /**
  37231. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37232. */
  37233. keysRight: number[];
  37234. /**
  37235. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37236. */
  37237. wheelPrecision: number;
  37238. /**
  37239. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37240. * It will be used instead of pinchDeltaPrecision if different from 0.
  37241. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37242. */
  37243. wheelDeltaPercentage: number;
  37244. /**
  37245. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37246. */
  37247. zoomOnFactor: number;
  37248. /**
  37249. * Defines a screen offset for the camera position.
  37250. */
  37251. targetScreenOffset: Vector2;
  37252. /**
  37253. * Allows the camera to be completely reversed.
  37254. * If false the camera can not arrive upside down.
  37255. */
  37256. allowUpsideDown: boolean;
  37257. /**
  37258. * Define if double tap/click is used to restore the previously saved state of the camera.
  37259. */
  37260. useInputToRestoreState: boolean;
  37261. /** @hidden */
  37262. _viewMatrix: Matrix;
  37263. /** @hidden */
  37264. _useCtrlForPanning: boolean;
  37265. /** @hidden */
  37266. _panningMouseButton: number;
  37267. /**
  37268. * Defines the input associated to the camera.
  37269. */
  37270. inputs: ArcRotateCameraInputsManager;
  37271. /** @hidden */
  37272. _reset: () => void;
  37273. /**
  37274. * Defines the allowed panning axis.
  37275. */
  37276. panningAxis: Vector3;
  37277. protected _localDirection: Vector3;
  37278. protected _transformedDirection: Vector3;
  37279. private _bouncingBehavior;
  37280. /**
  37281. * Gets the bouncing behavior of the camera if it has been enabled.
  37282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37283. */
  37284. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37285. /**
  37286. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37287. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37288. */
  37289. useBouncingBehavior: boolean;
  37290. private _framingBehavior;
  37291. /**
  37292. * Gets the framing behavior of the camera if it has been enabled.
  37293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37294. */
  37295. readonly framingBehavior: Nullable<FramingBehavior>;
  37296. /**
  37297. * Defines if the framing behavior of the camera is enabled on the camera.
  37298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37299. */
  37300. useFramingBehavior: boolean;
  37301. private _autoRotationBehavior;
  37302. /**
  37303. * Gets the auto rotation behavior of the camera if it has been enabled.
  37304. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37305. */
  37306. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37307. /**
  37308. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37310. */
  37311. useAutoRotationBehavior: boolean;
  37312. /**
  37313. * Observable triggered when the mesh target has been changed on the camera.
  37314. */
  37315. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37316. /**
  37317. * Event raised when the camera is colliding with a mesh.
  37318. */
  37319. onCollide: (collidedMesh: AbstractMesh) => void;
  37320. /**
  37321. * Defines whether the camera should check collision with the objects oh the scene.
  37322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37323. */
  37324. checkCollisions: boolean;
  37325. /**
  37326. * Defines the collision radius of the camera.
  37327. * This simulates a sphere around the camera.
  37328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37329. */
  37330. collisionRadius: Vector3;
  37331. protected _collider: Collider;
  37332. protected _previousPosition: Vector3;
  37333. protected _collisionVelocity: Vector3;
  37334. protected _newPosition: Vector3;
  37335. protected _previousAlpha: number;
  37336. protected _previousBeta: number;
  37337. protected _previousRadius: number;
  37338. protected _collisionTriggered: boolean;
  37339. protected _targetBoundingCenter: Nullable<Vector3>;
  37340. private _computationVector;
  37341. /**
  37342. * Instantiates a new ArcRotateCamera in a given scene
  37343. * @param name Defines the name of the camera
  37344. * @param alpha Defines the camera rotation along the logitudinal axis
  37345. * @param beta Defines the camera rotation along the latitudinal axis
  37346. * @param radius Defines the camera distance from its target
  37347. * @param target Defines the camera target
  37348. * @param scene Defines the scene the camera belongs to
  37349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37350. */
  37351. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37352. /** @hidden */
  37353. _initCache(): void;
  37354. /** @hidden */
  37355. _updateCache(ignoreParentClass?: boolean): void;
  37356. protected _getTargetPosition(): Vector3;
  37357. private _storedAlpha;
  37358. private _storedBeta;
  37359. private _storedRadius;
  37360. private _storedTarget;
  37361. private _storedTargetScreenOffset;
  37362. /**
  37363. * Stores the current state of the camera (alpha, beta, radius and target)
  37364. * @returns the camera itself
  37365. */
  37366. storeState(): Camera;
  37367. /**
  37368. * @hidden
  37369. * Restored camera state. You must call storeState() first
  37370. */
  37371. _restoreStateValues(): boolean;
  37372. /** @hidden */
  37373. _isSynchronizedViewMatrix(): boolean;
  37374. /**
  37375. * Attached controls to the current camera.
  37376. * @param element Defines the element the controls should be listened from
  37377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37378. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37379. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37380. */
  37381. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37382. /**
  37383. * Detach the current controls from the camera.
  37384. * The camera will stop reacting to inputs.
  37385. * @param element Defines the element to stop listening the inputs from
  37386. */
  37387. detachControl(element: HTMLElement): void;
  37388. /** @hidden */
  37389. _checkInputs(): void;
  37390. protected _checkLimits(): void;
  37391. /**
  37392. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37393. */
  37394. rebuildAnglesAndRadius(): void;
  37395. /**
  37396. * Use a position to define the current camera related information like aplha, beta and radius
  37397. * @param position Defines the position to set the camera at
  37398. */
  37399. setPosition(position: Vector3): void;
  37400. /**
  37401. * Defines the target the camera should look at.
  37402. * This will automatically adapt alpha beta and radius to fit within the new target.
  37403. * @param target Defines the new target as a Vector or a mesh
  37404. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37405. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37406. */
  37407. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37408. /** @hidden */
  37409. _getViewMatrix(): Matrix;
  37410. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37411. /**
  37412. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37413. * @param meshes Defines the mesh to zoom on
  37414. * @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)
  37415. */
  37416. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37417. /**
  37418. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37419. * The target will be changed but the radius
  37420. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37421. * @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)
  37422. */
  37423. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37424. min: Vector3;
  37425. max: Vector3;
  37426. distance: number;
  37427. }, doNotUpdateMaxZ?: boolean): void;
  37428. /**
  37429. * @override
  37430. * Override Camera.createRigCamera
  37431. */
  37432. createRigCamera(name: string, cameraIndex: number): Camera;
  37433. /**
  37434. * @hidden
  37435. * @override
  37436. * Override Camera._updateRigCameras
  37437. */
  37438. _updateRigCameras(): void;
  37439. /**
  37440. * Destroy the camera and release the current resources hold by it.
  37441. */
  37442. dispose(): void;
  37443. /**
  37444. * Gets the current object class name.
  37445. * @return the class name
  37446. */
  37447. getClassName(): string;
  37448. }
  37449. }
  37450. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37451. import { Behavior } from "babylonjs/Behaviors/behavior";
  37452. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37453. /**
  37454. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37455. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37456. */
  37457. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37458. /**
  37459. * Gets the name of the behavior.
  37460. */
  37461. readonly name: string;
  37462. private _zoomStopsAnimation;
  37463. private _idleRotationSpeed;
  37464. private _idleRotationWaitTime;
  37465. private _idleRotationSpinupTime;
  37466. /**
  37467. * Sets the flag that indicates if user zooming should stop animation.
  37468. */
  37469. /**
  37470. * Gets the flag that indicates if user zooming should stop animation.
  37471. */
  37472. zoomStopsAnimation: boolean;
  37473. /**
  37474. * Sets the default speed at which the camera rotates around the model.
  37475. */
  37476. /**
  37477. * Gets the default speed at which the camera rotates around the model.
  37478. */
  37479. idleRotationSpeed: number;
  37480. /**
  37481. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37482. */
  37483. /**
  37484. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37485. */
  37486. idleRotationWaitTime: number;
  37487. /**
  37488. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37489. */
  37490. /**
  37491. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37492. */
  37493. idleRotationSpinupTime: number;
  37494. /**
  37495. * Gets a value indicating if the camera is currently rotating because of this behavior
  37496. */
  37497. readonly rotationInProgress: boolean;
  37498. private _onPrePointerObservableObserver;
  37499. private _onAfterCheckInputsObserver;
  37500. private _attachedCamera;
  37501. private _isPointerDown;
  37502. private _lastFrameTime;
  37503. private _lastInteractionTime;
  37504. private _cameraRotationSpeed;
  37505. /**
  37506. * Initializes the behavior.
  37507. */
  37508. init(): void;
  37509. /**
  37510. * Attaches the behavior to its arc rotate camera.
  37511. * @param camera Defines the camera to attach the behavior to
  37512. */
  37513. attach(camera: ArcRotateCamera): void;
  37514. /**
  37515. * Detaches the behavior from its current arc rotate camera.
  37516. */
  37517. detach(): void;
  37518. /**
  37519. * Returns true if user is scrolling.
  37520. * @return true if user is scrolling.
  37521. */
  37522. private _userIsZooming;
  37523. private _lastFrameRadius;
  37524. private _shouldAnimationStopForInteraction;
  37525. /**
  37526. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37527. */
  37528. private _applyUserInteraction;
  37529. private _userIsMoving;
  37530. }
  37531. }
  37532. declare module "babylonjs/Behaviors/Cameras/index" {
  37533. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37534. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37535. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37536. }
  37537. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37538. import { Mesh } from "babylonjs/Meshes/mesh";
  37539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37540. import { Behavior } from "babylonjs/Behaviors/behavior";
  37541. /**
  37542. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37543. */
  37544. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37545. private ui;
  37546. /**
  37547. * The name of the behavior
  37548. */
  37549. name: string;
  37550. /**
  37551. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37552. */
  37553. distanceAwayFromFace: number;
  37554. /**
  37555. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37556. */
  37557. distanceAwayFromBottomOfFace: number;
  37558. private _faceVectors;
  37559. private _target;
  37560. private _scene;
  37561. private _onRenderObserver;
  37562. private _tmpMatrix;
  37563. private _tmpVector;
  37564. /**
  37565. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37566. * @param ui The transform node that should be attched to the mesh
  37567. */
  37568. constructor(ui: TransformNode);
  37569. /**
  37570. * Initializes the behavior
  37571. */
  37572. init(): void;
  37573. private _closestFace;
  37574. private _zeroVector;
  37575. private _lookAtTmpMatrix;
  37576. private _lookAtToRef;
  37577. /**
  37578. * Attaches the AttachToBoxBehavior to the passed in mesh
  37579. * @param target The mesh that the specified node will be attached to
  37580. */
  37581. attach(target: Mesh): void;
  37582. /**
  37583. * Detaches the behavior from the mesh
  37584. */
  37585. detach(): void;
  37586. }
  37587. }
  37588. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37589. import { Behavior } from "babylonjs/Behaviors/behavior";
  37590. import { Mesh } from "babylonjs/Meshes/mesh";
  37591. /**
  37592. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37593. */
  37594. export class FadeInOutBehavior implements Behavior<Mesh> {
  37595. /**
  37596. * Time in milliseconds to delay before fading in (Default: 0)
  37597. */
  37598. delay: number;
  37599. /**
  37600. * Time in milliseconds for the mesh to fade in (Default: 300)
  37601. */
  37602. fadeInTime: number;
  37603. private _millisecondsPerFrame;
  37604. private _hovered;
  37605. private _hoverValue;
  37606. private _ownerNode;
  37607. /**
  37608. * Instatiates the FadeInOutBehavior
  37609. */
  37610. constructor();
  37611. /**
  37612. * The name of the behavior
  37613. */
  37614. readonly name: string;
  37615. /**
  37616. * Initializes the behavior
  37617. */
  37618. init(): void;
  37619. /**
  37620. * Attaches the fade behavior on the passed in mesh
  37621. * @param ownerNode The mesh that will be faded in/out once attached
  37622. */
  37623. attach(ownerNode: Mesh): void;
  37624. /**
  37625. * Detaches the behavior from the mesh
  37626. */
  37627. detach(): void;
  37628. /**
  37629. * Triggers the mesh to begin fading in or out
  37630. * @param value if the object should fade in or out (true to fade in)
  37631. */
  37632. fadeIn(value: boolean): void;
  37633. private _update;
  37634. private _setAllVisibility;
  37635. }
  37636. }
  37637. declare module "babylonjs/Misc/pivotTools" {
  37638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37639. /**
  37640. * Class containing a set of static utilities functions for managing Pivots
  37641. * @hidden
  37642. */
  37643. export class PivotTools {
  37644. private static _PivotCached;
  37645. private static _OldPivotPoint;
  37646. private static _PivotTranslation;
  37647. private static _PivotTmpVector;
  37648. /** @hidden */
  37649. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37650. /** @hidden */
  37651. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37652. }
  37653. }
  37654. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37655. import { Scene } from "babylonjs/scene";
  37656. import { Vector4 } from "babylonjs/Maths/math.vector";
  37657. import { Mesh } from "babylonjs/Meshes/mesh";
  37658. import { Nullable } from "babylonjs/types";
  37659. import { Plane } from "babylonjs/Maths/math.plane";
  37660. /**
  37661. * Class containing static functions to help procedurally build meshes
  37662. */
  37663. export class PlaneBuilder {
  37664. /**
  37665. * Creates a plane mesh
  37666. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37667. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37668. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37672. * @param name defines the name of the mesh
  37673. * @param options defines the options used to create the mesh
  37674. * @param scene defines the hosting scene
  37675. * @returns the plane mesh
  37676. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37677. */
  37678. static CreatePlane(name: string, options: {
  37679. size?: number;
  37680. width?: number;
  37681. height?: number;
  37682. sideOrientation?: number;
  37683. frontUVs?: Vector4;
  37684. backUVs?: Vector4;
  37685. updatable?: boolean;
  37686. sourcePlane?: Plane;
  37687. }, scene?: Nullable<Scene>): Mesh;
  37688. }
  37689. }
  37690. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37691. import { Behavior } from "babylonjs/Behaviors/behavior";
  37692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37693. import { Observable } from "babylonjs/Misc/observable";
  37694. import { Vector3 } from "babylonjs/Maths/math.vector";
  37695. import { Ray } from "babylonjs/Culling/ray";
  37696. import "babylonjs/Meshes/Builders/planeBuilder";
  37697. /**
  37698. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37699. */
  37700. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37701. private static _AnyMouseID;
  37702. /**
  37703. * Abstract mesh the behavior is set on
  37704. */
  37705. attachedNode: AbstractMesh;
  37706. private _dragPlane;
  37707. private _scene;
  37708. private _pointerObserver;
  37709. private _beforeRenderObserver;
  37710. private static _planeScene;
  37711. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37712. /**
  37713. * 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)
  37714. */
  37715. maxDragAngle: number;
  37716. /**
  37717. * @hidden
  37718. */
  37719. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37720. /**
  37721. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37722. */
  37723. currentDraggingPointerID: number;
  37724. /**
  37725. * The last position where the pointer hit the drag plane in world space
  37726. */
  37727. lastDragPosition: Vector3;
  37728. /**
  37729. * If the behavior is currently in a dragging state
  37730. */
  37731. dragging: boolean;
  37732. /**
  37733. * 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)
  37734. */
  37735. dragDeltaRatio: number;
  37736. /**
  37737. * If the drag plane orientation should be updated during the dragging (Default: true)
  37738. */
  37739. updateDragPlane: boolean;
  37740. private _debugMode;
  37741. private _moving;
  37742. /**
  37743. * Fires each time the attached mesh is dragged with the pointer
  37744. * * delta between last drag position and current drag position in world space
  37745. * * dragDistance along the drag axis
  37746. * * dragPlaneNormal normal of the current drag plane used during the drag
  37747. * * dragPlanePoint in world space where the drag intersects the drag plane
  37748. */
  37749. onDragObservable: Observable<{
  37750. delta: Vector3;
  37751. dragPlanePoint: Vector3;
  37752. dragPlaneNormal: Vector3;
  37753. dragDistance: number;
  37754. pointerId: number;
  37755. }>;
  37756. /**
  37757. * Fires each time a drag begins (eg. mouse down on mesh)
  37758. */
  37759. onDragStartObservable: Observable<{
  37760. dragPlanePoint: Vector3;
  37761. pointerId: number;
  37762. }>;
  37763. /**
  37764. * Fires each time a drag ends (eg. mouse release after drag)
  37765. */
  37766. onDragEndObservable: Observable<{
  37767. dragPlanePoint: Vector3;
  37768. pointerId: number;
  37769. }>;
  37770. /**
  37771. * If the attached mesh should be moved when dragged
  37772. */
  37773. moveAttached: boolean;
  37774. /**
  37775. * If the drag behavior will react to drag events (Default: true)
  37776. */
  37777. enabled: boolean;
  37778. /**
  37779. * If pointer events should start and release the drag (Default: true)
  37780. */
  37781. startAndReleaseDragOnPointerEvents: boolean;
  37782. /**
  37783. * If camera controls should be detached during the drag
  37784. */
  37785. detachCameraControls: boolean;
  37786. /**
  37787. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37788. */
  37789. useObjectOrienationForDragging: boolean;
  37790. private _options;
  37791. /**
  37792. * Creates a pointer drag behavior that can be attached to a mesh
  37793. * @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)
  37794. */
  37795. constructor(options?: {
  37796. dragAxis?: Vector3;
  37797. dragPlaneNormal?: Vector3;
  37798. });
  37799. /**
  37800. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37801. */
  37802. validateDrag: (targetPosition: Vector3) => boolean;
  37803. /**
  37804. * The name of the behavior
  37805. */
  37806. readonly name: string;
  37807. /**
  37808. * Initializes the behavior
  37809. */
  37810. init(): void;
  37811. private _tmpVector;
  37812. private _alternatePickedPoint;
  37813. private _worldDragAxis;
  37814. private _targetPosition;
  37815. private _attachedElement;
  37816. /**
  37817. * Attaches the drag behavior the passed in mesh
  37818. * @param ownerNode The mesh that will be dragged around once attached
  37819. */
  37820. attach(ownerNode: AbstractMesh): void;
  37821. /**
  37822. * Force relase the drag action by code.
  37823. */
  37824. releaseDrag(): void;
  37825. private _startDragRay;
  37826. private _lastPointerRay;
  37827. /**
  37828. * Simulates the start of a pointer drag event on the behavior
  37829. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37830. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37831. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37832. */
  37833. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37834. private _startDrag;
  37835. private _dragDelta;
  37836. private _moveDrag;
  37837. private _pickWithRayOnDragPlane;
  37838. private _pointA;
  37839. private _pointB;
  37840. private _pointC;
  37841. private _lineA;
  37842. private _lineB;
  37843. private _localAxis;
  37844. private _lookAt;
  37845. private _updateDragPlanePosition;
  37846. /**
  37847. * Detaches the behavior from the mesh
  37848. */
  37849. detach(): void;
  37850. }
  37851. }
  37852. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37853. import { Mesh } from "babylonjs/Meshes/mesh";
  37854. import { Behavior } from "babylonjs/Behaviors/behavior";
  37855. /**
  37856. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37857. */
  37858. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37859. private _dragBehaviorA;
  37860. private _dragBehaviorB;
  37861. private _startDistance;
  37862. private _initialScale;
  37863. private _targetScale;
  37864. private _ownerNode;
  37865. private _sceneRenderObserver;
  37866. /**
  37867. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37868. */
  37869. constructor();
  37870. /**
  37871. * The name of the behavior
  37872. */
  37873. readonly name: string;
  37874. /**
  37875. * Initializes the behavior
  37876. */
  37877. init(): void;
  37878. private _getCurrentDistance;
  37879. /**
  37880. * Attaches the scale behavior the passed in mesh
  37881. * @param ownerNode The mesh that will be scaled around once attached
  37882. */
  37883. attach(ownerNode: Mesh): void;
  37884. /**
  37885. * Detaches the behavior from the mesh
  37886. */
  37887. detach(): void;
  37888. }
  37889. }
  37890. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37891. import { Behavior } from "babylonjs/Behaviors/behavior";
  37892. import { Mesh } from "babylonjs/Meshes/mesh";
  37893. import { Observable } from "babylonjs/Misc/observable";
  37894. /**
  37895. * 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
  37896. */
  37897. export class SixDofDragBehavior implements Behavior<Mesh> {
  37898. private static _virtualScene;
  37899. private _ownerNode;
  37900. private _sceneRenderObserver;
  37901. private _scene;
  37902. private _targetPosition;
  37903. private _virtualOriginMesh;
  37904. private _virtualDragMesh;
  37905. private _pointerObserver;
  37906. private _moving;
  37907. private _startingOrientation;
  37908. /**
  37909. * 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)
  37910. */
  37911. private zDragFactor;
  37912. /**
  37913. * If the object should rotate to face the drag origin
  37914. */
  37915. rotateDraggedObject: boolean;
  37916. /**
  37917. * If the behavior is currently in a dragging state
  37918. */
  37919. dragging: boolean;
  37920. /**
  37921. * 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)
  37922. */
  37923. dragDeltaRatio: number;
  37924. /**
  37925. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37926. */
  37927. currentDraggingPointerID: number;
  37928. /**
  37929. * If camera controls should be detached during the drag
  37930. */
  37931. detachCameraControls: boolean;
  37932. /**
  37933. * Fires each time a drag starts
  37934. */
  37935. onDragStartObservable: Observable<{}>;
  37936. /**
  37937. * Fires each time a drag ends (eg. mouse release after drag)
  37938. */
  37939. onDragEndObservable: Observable<{}>;
  37940. /**
  37941. * 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
  37942. */
  37943. constructor();
  37944. /**
  37945. * The name of the behavior
  37946. */
  37947. readonly name: string;
  37948. /**
  37949. * Initializes the behavior
  37950. */
  37951. init(): void;
  37952. /**
  37953. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37954. */
  37955. private readonly _pointerCamera;
  37956. /**
  37957. * Attaches the scale behavior the passed in mesh
  37958. * @param ownerNode The mesh that will be scaled around once attached
  37959. */
  37960. attach(ownerNode: Mesh): void;
  37961. /**
  37962. * Detaches the behavior from the mesh
  37963. */
  37964. detach(): void;
  37965. }
  37966. }
  37967. declare module "babylonjs/Behaviors/Meshes/index" {
  37968. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37969. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37970. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37971. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37972. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37973. }
  37974. declare module "babylonjs/Behaviors/index" {
  37975. export * from "babylonjs/Behaviors/behavior";
  37976. export * from "babylonjs/Behaviors/Cameras/index";
  37977. export * from "babylonjs/Behaviors/Meshes/index";
  37978. }
  37979. declare module "babylonjs/Bones/boneIKController" {
  37980. import { Bone } from "babylonjs/Bones/bone";
  37981. import { Vector3 } from "babylonjs/Maths/math.vector";
  37982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37983. import { Nullable } from "babylonjs/types";
  37984. /**
  37985. * Class used to apply inverse kinematics to bones
  37986. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37987. */
  37988. export class BoneIKController {
  37989. private static _tmpVecs;
  37990. private static _tmpQuat;
  37991. private static _tmpMats;
  37992. /**
  37993. * Gets or sets the target mesh
  37994. */
  37995. targetMesh: AbstractMesh;
  37996. /** Gets or sets the mesh used as pole */
  37997. poleTargetMesh: AbstractMesh;
  37998. /**
  37999. * Gets or sets the bone used as pole
  38000. */
  38001. poleTargetBone: Nullable<Bone>;
  38002. /**
  38003. * Gets or sets the target position
  38004. */
  38005. targetPosition: Vector3;
  38006. /**
  38007. * Gets or sets the pole target position
  38008. */
  38009. poleTargetPosition: Vector3;
  38010. /**
  38011. * Gets or sets the pole target local offset
  38012. */
  38013. poleTargetLocalOffset: Vector3;
  38014. /**
  38015. * Gets or sets the pole angle
  38016. */
  38017. poleAngle: number;
  38018. /**
  38019. * Gets or sets the mesh associated with the controller
  38020. */
  38021. mesh: AbstractMesh;
  38022. /**
  38023. * 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)
  38024. */
  38025. slerpAmount: number;
  38026. private _bone1Quat;
  38027. private _bone1Mat;
  38028. private _bone2Ang;
  38029. private _bone1;
  38030. private _bone2;
  38031. private _bone1Length;
  38032. private _bone2Length;
  38033. private _maxAngle;
  38034. private _maxReach;
  38035. private _rightHandedSystem;
  38036. private _bendAxis;
  38037. private _slerping;
  38038. private _adjustRoll;
  38039. /**
  38040. * Gets or sets maximum allowed angle
  38041. */
  38042. maxAngle: number;
  38043. /**
  38044. * Creates a new BoneIKController
  38045. * @param mesh defines the mesh to control
  38046. * @param bone defines the bone to control
  38047. * @param options defines options to set up the controller
  38048. */
  38049. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38050. targetMesh?: AbstractMesh;
  38051. poleTargetMesh?: AbstractMesh;
  38052. poleTargetBone?: Bone;
  38053. poleTargetLocalOffset?: Vector3;
  38054. poleAngle?: number;
  38055. bendAxis?: Vector3;
  38056. maxAngle?: number;
  38057. slerpAmount?: number;
  38058. });
  38059. private _setMaxAngle;
  38060. /**
  38061. * Force the controller to update the bones
  38062. */
  38063. update(): void;
  38064. }
  38065. }
  38066. declare module "babylonjs/Bones/boneLookController" {
  38067. import { Vector3 } from "babylonjs/Maths/math.vector";
  38068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38069. import { Bone } from "babylonjs/Bones/bone";
  38070. import { Space } from "babylonjs/Maths/math.axis";
  38071. /**
  38072. * Class used to make a bone look toward a point in space
  38073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38074. */
  38075. export class BoneLookController {
  38076. private static _tmpVecs;
  38077. private static _tmpQuat;
  38078. private static _tmpMats;
  38079. /**
  38080. * The target Vector3 that the bone will look at
  38081. */
  38082. target: Vector3;
  38083. /**
  38084. * The mesh that the bone is attached to
  38085. */
  38086. mesh: AbstractMesh;
  38087. /**
  38088. * The bone that will be looking to the target
  38089. */
  38090. bone: Bone;
  38091. /**
  38092. * The up axis of the coordinate system that is used when the bone is rotated
  38093. */
  38094. upAxis: Vector3;
  38095. /**
  38096. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38097. */
  38098. upAxisSpace: Space;
  38099. /**
  38100. * Used to make an adjustment to the yaw of the bone
  38101. */
  38102. adjustYaw: number;
  38103. /**
  38104. * Used to make an adjustment to the pitch of the bone
  38105. */
  38106. adjustPitch: number;
  38107. /**
  38108. * Used to make an adjustment to the roll of the bone
  38109. */
  38110. adjustRoll: number;
  38111. /**
  38112. * 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)
  38113. */
  38114. slerpAmount: number;
  38115. private _minYaw;
  38116. private _maxYaw;
  38117. private _minPitch;
  38118. private _maxPitch;
  38119. private _minYawSin;
  38120. private _minYawCos;
  38121. private _maxYawSin;
  38122. private _maxYawCos;
  38123. private _midYawConstraint;
  38124. private _minPitchTan;
  38125. private _maxPitchTan;
  38126. private _boneQuat;
  38127. private _slerping;
  38128. private _transformYawPitch;
  38129. private _transformYawPitchInv;
  38130. private _firstFrameSkipped;
  38131. private _yawRange;
  38132. private _fowardAxis;
  38133. /**
  38134. * Gets or sets the minimum yaw angle that the bone can look to
  38135. */
  38136. minYaw: number;
  38137. /**
  38138. * Gets or sets the maximum yaw angle that the bone can look to
  38139. */
  38140. maxYaw: number;
  38141. /**
  38142. * Gets or sets the minimum pitch angle that the bone can look to
  38143. */
  38144. minPitch: number;
  38145. /**
  38146. * Gets or sets the maximum pitch angle that the bone can look to
  38147. */
  38148. maxPitch: number;
  38149. /**
  38150. * Create a BoneLookController
  38151. * @param mesh the mesh that the bone belongs to
  38152. * @param bone the bone that will be looking to the target
  38153. * @param target the target Vector3 to look at
  38154. * @param options optional settings:
  38155. * * maxYaw: the maximum angle the bone will yaw to
  38156. * * minYaw: the minimum angle the bone will yaw to
  38157. * * maxPitch: the maximum angle the bone will pitch to
  38158. * * minPitch: the minimum angle the bone will yaw to
  38159. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38160. * * upAxis: the up axis of the coordinate system
  38161. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38162. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38163. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38164. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38165. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38166. * * adjustRoll: used to make an adjustment to the roll of the bone
  38167. **/
  38168. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38169. maxYaw?: number;
  38170. minYaw?: number;
  38171. maxPitch?: number;
  38172. minPitch?: number;
  38173. slerpAmount?: number;
  38174. upAxis?: Vector3;
  38175. upAxisSpace?: Space;
  38176. yawAxis?: Vector3;
  38177. pitchAxis?: Vector3;
  38178. adjustYaw?: number;
  38179. adjustPitch?: number;
  38180. adjustRoll?: number;
  38181. });
  38182. /**
  38183. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38184. */
  38185. update(): void;
  38186. private _getAngleDiff;
  38187. private _getAngleBetween;
  38188. private _isAngleBetween;
  38189. }
  38190. }
  38191. declare module "babylonjs/Bones/index" {
  38192. export * from "babylonjs/Bones/bone";
  38193. export * from "babylonjs/Bones/boneIKController";
  38194. export * from "babylonjs/Bones/boneLookController";
  38195. export * from "babylonjs/Bones/skeleton";
  38196. }
  38197. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38198. import { Nullable } from "babylonjs/types";
  38199. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38200. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38201. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38202. /**
  38203. * Manage the gamepad inputs to control an arc rotate camera.
  38204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38205. */
  38206. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38207. /**
  38208. * Defines the camera the input is attached to.
  38209. */
  38210. camera: ArcRotateCamera;
  38211. /**
  38212. * Defines the gamepad the input is gathering event from.
  38213. */
  38214. gamepad: Nullable<Gamepad>;
  38215. /**
  38216. * Defines the gamepad rotation sensiblity.
  38217. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38218. */
  38219. gamepadRotationSensibility: number;
  38220. /**
  38221. * Defines the gamepad move sensiblity.
  38222. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38223. */
  38224. gamepadMoveSensibility: number;
  38225. private _onGamepadConnectedObserver;
  38226. private _onGamepadDisconnectedObserver;
  38227. /**
  38228. * Attach the input controls to a specific dom element to get the input from.
  38229. * @param element Defines the element the controls should be listened from
  38230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38231. */
  38232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38233. /**
  38234. * Detach the current controls from the specified dom element.
  38235. * @param element Defines the element to stop listening the inputs from
  38236. */
  38237. detachControl(element: Nullable<HTMLElement>): void;
  38238. /**
  38239. * Update the current camera state depending on the inputs that have been used this frame.
  38240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38241. */
  38242. checkInputs(): void;
  38243. /**
  38244. * Gets the class name of the current intput.
  38245. * @returns the class name
  38246. */
  38247. getClassName(): string;
  38248. /**
  38249. * Get the friendly name associated with the input class.
  38250. * @returns the input friendly name
  38251. */
  38252. getSimpleName(): string;
  38253. }
  38254. }
  38255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38256. import { Nullable } from "babylonjs/types";
  38257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38259. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38260. interface ArcRotateCameraInputsManager {
  38261. /**
  38262. * Add orientation input support to the input manager.
  38263. * @returns the current input manager
  38264. */
  38265. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38266. }
  38267. }
  38268. /**
  38269. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38271. */
  38272. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38273. /**
  38274. * Defines the camera the input is attached to.
  38275. */
  38276. camera: ArcRotateCamera;
  38277. /**
  38278. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38279. */
  38280. alphaCorrection: number;
  38281. /**
  38282. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38283. */
  38284. gammaCorrection: number;
  38285. private _alpha;
  38286. private _gamma;
  38287. private _dirty;
  38288. private _deviceOrientationHandler;
  38289. /**
  38290. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38291. */
  38292. constructor();
  38293. /**
  38294. * Attach the input controls to a specific dom element to get the input from.
  38295. * @param element Defines the element the controls should be listened from
  38296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38297. */
  38298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38299. /** @hidden */
  38300. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38301. /**
  38302. * Update the current camera state depending on the inputs that have been used this frame.
  38303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38304. */
  38305. checkInputs(): void;
  38306. /**
  38307. * Detach the current controls from the specified dom element.
  38308. * @param element Defines the element to stop listening the inputs from
  38309. */
  38310. detachControl(element: Nullable<HTMLElement>): void;
  38311. /**
  38312. * Gets the class name of the current intput.
  38313. * @returns the class name
  38314. */
  38315. getClassName(): string;
  38316. /**
  38317. * Get the friendly name associated with the input class.
  38318. * @returns the input friendly name
  38319. */
  38320. getSimpleName(): string;
  38321. }
  38322. }
  38323. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38324. import { Nullable } from "babylonjs/types";
  38325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38326. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38327. /**
  38328. * Listen to mouse events to control the camera.
  38329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38330. */
  38331. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38332. /**
  38333. * Defines the camera the input is attached to.
  38334. */
  38335. camera: FlyCamera;
  38336. /**
  38337. * Defines if touch is enabled. (Default is true.)
  38338. */
  38339. touchEnabled: boolean;
  38340. /**
  38341. * Defines the buttons associated with the input to handle camera rotation.
  38342. */
  38343. buttons: number[];
  38344. /**
  38345. * Assign buttons for Yaw control.
  38346. */
  38347. buttonsYaw: number[];
  38348. /**
  38349. * Assign buttons for Pitch control.
  38350. */
  38351. buttonsPitch: number[];
  38352. /**
  38353. * Assign buttons for Roll control.
  38354. */
  38355. buttonsRoll: number[];
  38356. /**
  38357. * Detect if any button is being pressed while mouse is moved.
  38358. * -1 = Mouse locked.
  38359. * 0 = Left button.
  38360. * 1 = Middle Button.
  38361. * 2 = Right Button.
  38362. */
  38363. activeButton: number;
  38364. /**
  38365. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38366. * Higher values reduce its sensitivity.
  38367. */
  38368. angularSensibility: number;
  38369. private _mousemoveCallback;
  38370. private _observer;
  38371. private _rollObserver;
  38372. private previousPosition;
  38373. private noPreventDefault;
  38374. private element;
  38375. /**
  38376. * Listen to mouse events to control the camera.
  38377. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38379. */
  38380. constructor(touchEnabled?: boolean);
  38381. /**
  38382. * Attach the mouse control to the HTML DOM element.
  38383. * @param element Defines the element that listens to the input events.
  38384. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38385. */
  38386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38387. /**
  38388. * Detach the current controls from the specified dom element.
  38389. * @param element Defines the element to stop listening the inputs from
  38390. */
  38391. detachControl(element: Nullable<HTMLElement>): void;
  38392. /**
  38393. * Gets the class name of the current input.
  38394. * @returns the class name.
  38395. */
  38396. getClassName(): string;
  38397. /**
  38398. * Get the friendly name associated with the input class.
  38399. * @returns the input's friendly name.
  38400. */
  38401. getSimpleName(): string;
  38402. private _pointerInput;
  38403. private _onMouseMove;
  38404. /**
  38405. * Rotate camera by mouse offset.
  38406. */
  38407. private rotateCamera;
  38408. }
  38409. }
  38410. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38411. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38412. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38413. /**
  38414. * Default Inputs manager for the FlyCamera.
  38415. * It groups all the default supported inputs for ease of use.
  38416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38417. */
  38418. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38419. /**
  38420. * Instantiates a new FlyCameraInputsManager.
  38421. * @param camera Defines the camera the inputs belong to.
  38422. */
  38423. constructor(camera: FlyCamera);
  38424. /**
  38425. * Add keyboard input support to the input manager.
  38426. * @returns the new FlyCameraKeyboardMoveInput().
  38427. */
  38428. addKeyboard(): FlyCameraInputsManager;
  38429. /**
  38430. * Add mouse input support to the input manager.
  38431. * @param touchEnabled Enable touch screen support.
  38432. * @returns the new FlyCameraMouseInput().
  38433. */
  38434. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38435. }
  38436. }
  38437. declare module "babylonjs/Cameras/flyCamera" {
  38438. import { Scene } from "babylonjs/scene";
  38439. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38441. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38442. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38443. /**
  38444. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38445. * such as in a 3D Space Shooter or a Flight Simulator.
  38446. */
  38447. export class FlyCamera extends TargetCamera {
  38448. /**
  38449. * Define the collision ellipsoid of the camera.
  38450. * This is helpful for simulating a camera body, like a player's body.
  38451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38452. */
  38453. ellipsoid: Vector3;
  38454. /**
  38455. * Define an offset for the position of the ellipsoid around the camera.
  38456. * This can be helpful if the camera is attached away from the player's body center,
  38457. * such as at its head.
  38458. */
  38459. ellipsoidOffset: Vector3;
  38460. /**
  38461. * Enable or disable collisions of the camera with the rest of the scene objects.
  38462. */
  38463. checkCollisions: boolean;
  38464. /**
  38465. * Enable or disable gravity on the camera.
  38466. */
  38467. applyGravity: boolean;
  38468. /**
  38469. * Define the current direction the camera is moving to.
  38470. */
  38471. cameraDirection: Vector3;
  38472. /**
  38473. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38474. * This overrides and empties cameraRotation.
  38475. */
  38476. rotationQuaternion: Quaternion;
  38477. /**
  38478. * Track Roll to maintain the wanted Rolling when looking around.
  38479. */
  38480. _trackRoll: number;
  38481. /**
  38482. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38483. */
  38484. rollCorrect: number;
  38485. /**
  38486. * Mimic a banked turn, Rolling the camera when Yawing.
  38487. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38488. */
  38489. bankedTurn: boolean;
  38490. /**
  38491. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38492. */
  38493. bankedTurnLimit: number;
  38494. /**
  38495. * Value of 0 disables the banked Roll.
  38496. * Value of 1 is equal to the Yaw angle in radians.
  38497. */
  38498. bankedTurnMultiplier: number;
  38499. /**
  38500. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38501. */
  38502. inputs: FlyCameraInputsManager;
  38503. /**
  38504. * Gets the input sensibility for mouse input.
  38505. * Higher values reduce sensitivity.
  38506. */
  38507. /**
  38508. * Sets the input sensibility for a mouse input.
  38509. * Higher values reduce sensitivity.
  38510. */
  38511. angularSensibility: number;
  38512. /**
  38513. * Get the keys for camera movement forward.
  38514. */
  38515. /**
  38516. * Set the keys for camera movement forward.
  38517. */
  38518. keysForward: number[];
  38519. /**
  38520. * Get the keys for camera movement backward.
  38521. */
  38522. keysBackward: number[];
  38523. /**
  38524. * Get the keys for camera movement up.
  38525. */
  38526. /**
  38527. * Set the keys for camera movement up.
  38528. */
  38529. keysUp: number[];
  38530. /**
  38531. * Get the keys for camera movement down.
  38532. */
  38533. /**
  38534. * Set the keys for camera movement down.
  38535. */
  38536. keysDown: number[];
  38537. /**
  38538. * Get the keys for camera movement left.
  38539. */
  38540. /**
  38541. * Set the keys for camera movement left.
  38542. */
  38543. keysLeft: number[];
  38544. /**
  38545. * Set the keys for camera movement right.
  38546. */
  38547. /**
  38548. * Set the keys for camera movement right.
  38549. */
  38550. keysRight: number[];
  38551. /**
  38552. * Event raised when the camera collides with a mesh in the scene.
  38553. */
  38554. onCollide: (collidedMesh: AbstractMesh) => void;
  38555. private _collider;
  38556. private _needMoveForGravity;
  38557. private _oldPosition;
  38558. private _diffPosition;
  38559. private _newPosition;
  38560. /** @hidden */
  38561. _localDirection: Vector3;
  38562. /** @hidden */
  38563. _transformedDirection: Vector3;
  38564. /**
  38565. * Instantiates a FlyCamera.
  38566. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38567. * such as in a 3D Space Shooter or a Flight Simulator.
  38568. * @param name Define the name of the camera in the scene.
  38569. * @param position Define the starting position of the camera in the scene.
  38570. * @param scene Define the scene the camera belongs to.
  38571. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38572. */
  38573. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38574. /**
  38575. * Attach a control to the HTML DOM element.
  38576. * @param element Defines the element that listens to the input events.
  38577. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38578. */
  38579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38580. /**
  38581. * Detach a control from the HTML DOM element.
  38582. * The camera will stop reacting to that input.
  38583. * @param element Defines the element that listens to the input events.
  38584. */
  38585. detachControl(element: HTMLElement): void;
  38586. private _collisionMask;
  38587. /**
  38588. * Get the mask that the camera ignores in collision events.
  38589. */
  38590. /**
  38591. * Set the mask that the camera ignores in collision events.
  38592. */
  38593. collisionMask: number;
  38594. /** @hidden */
  38595. _collideWithWorld(displacement: Vector3): void;
  38596. /** @hidden */
  38597. private _onCollisionPositionChange;
  38598. /** @hidden */
  38599. _checkInputs(): void;
  38600. /** @hidden */
  38601. _decideIfNeedsToMove(): boolean;
  38602. /** @hidden */
  38603. _updatePosition(): void;
  38604. /**
  38605. * Restore the Roll to its target value at the rate specified.
  38606. * @param rate - Higher means slower restoring.
  38607. * @hidden
  38608. */
  38609. restoreRoll(rate: number): void;
  38610. /**
  38611. * Destroy the camera and release the current resources held by it.
  38612. */
  38613. dispose(): void;
  38614. /**
  38615. * Get the current object class name.
  38616. * @returns the class name.
  38617. */
  38618. getClassName(): string;
  38619. }
  38620. }
  38621. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38622. import { Nullable } from "babylonjs/types";
  38623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38624. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38625. /**
  38626. * Listen to keyboard events to control the camera.
  38627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38628. */
  38629. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38630. /**
  38631. * Defines the camera the input is attached to.
  38632. */
  38633. camera: FlyCamera;
  38634. /**
  38635. * The list of keyboard keys used to control the forward move of the camera.
  38636. */
  38637. keysForward: number[];
  38638. /**
  38639. * The list of keyboard keys used to control the backward move of the camera.
  38640. */
  38641. keysBackward: number[];
  38642. /**
  38643. * The list of keyboard keys used to control the forward move of the camera.
  38644. */
  38645. keysUp: number[];
  38646. /**
  38647. * The list of keyboard keys used to control the backward move of the camera.
  38648. */
  38649. keysDown: number[];
  38650. /**
  38651. * The list of keyboard keys used to control the right strafe move of the camera.
  38652. */
  38653. keysRight: number[];
  38654. /**
  38655. * The list of keyboard keys used to control the left strafe move of the camera.
  38656. */
  38657. keysLeft: number[];
  38658. private _keys;
  38659. private _onCanvasBlurObserver;
  38660. private _onKeyboardObserver;
  38661. private _engine;
  38662. private _scene;
  38663. /**
  38664. * Attach the input controls to a specific dom element to get the input from.
  38665. * @param element Defines the element the controls should be listened from
  38666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38667. */
  38668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38669. /**
  38670. * Detach the current controls from the specified dom element.
  38671. * @param element Defines the element to stop listening the inputs from
  38672. */
  38673. detachControl(element: Nullable<HTMLElement>): void;
  38674. /**
  38675. * Gets the class name of the current intput.
  38676. * @returns the class name
  38677. */
  38678. getClassName(): string;
  38679. /** @hidden */
  38680. _onLostFocus(e: FocusEvent): void;
  38681. /**
  38682. * Get the friendly name associated with the input class.
  38683. * @returns the input friendly name
  38684. */
  38685. getSimpleName(): string;
  38686. /**
  38687. * Update the current camera state depending on the inputs that have been used this frame.
  38688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38689. */
  38690. checkInputs(): void;
  38691. }
  38692. }
  38693. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38694. import { Nullable } from "babylonjs/types";
  38695. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38696. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38697. /**
  38698. * Manage the mouse wheel inputs to control a follow camera.
  38699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38700. */
  38701. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38702. /**
  38703. * Defines the camera the input is attached to.
  38704. */
  38705. camera: FollowCamera;
  38706. /**
  38707. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38708. */
  38709. axisControlRadius: boolean;
  38710. /**
  38711. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38712. */
  38713. axisControlHeight: boolean;
  38714. /**
  38715. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38716. */
  38717. axisControlRotation: boolean;
  38718. /**
  38719. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38720. * relation to mouseWheel events.
  38721. */
  38722. wheelPrecision: number;
  38723. /**
  38724. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38725. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38726. */
  38727. wheelDeltaPercentage: number;
  38728. private _wheel;
  38729. private _observer;
  38730. /**
  38731. * Attach the input controls to a specific dom element to get the input from.
  38732. * @param element Defines the element the controls should be listened from
  38733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38734. */
  38735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38736. /**
  38737. * Detach the current controls from the specified dom element.
  38738. * @param element Defines the element to stop listening the inputs from
  38739. */
  38740. detachControl(element: Nullable<HTMLElement>): void;
  38741. /**
  38742. * Gets the class name of the current intput.
  38743. * @returns the class name
  38744. */
  38745. getClassName(): string;
  38746. /**
  38747. * Get the friendly name associated with the input class.
  38748. * @returns the input friendly name
  38749. */
  38750. getSimpleName(): string;
  38751. }
  38752. }
  38753. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38754. import { Nullable } from "babylonjs/types";
  38755. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38756. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38757. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38758. /**
  38759. * Manage the pointers inputs to control an follow camera.
  38760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38761. */
  38762. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38763. /**
  38764. * Defines the camera the input is attached to.
  38765. */
  38766. camera: FollowCamera;
  38767. /**
  38768. * Gets the class name of the current input.
  38769. * @returns the class name
  38770. */
  38771. getClassName(): string;
  38772. /**
  38773. * Defines the pointer angular sensibility along the X axis or how fast is
  38774. * the camera rotating.
  38775. * A negative number will reverse the axis direction.
  38776. */
  38777. angularSensibilityX: number;
  38778. /**
  38779. * Defines the pointer angular sensibility along the Y axis or how fast is
  38780. * the camera rotating.
  38781. * A negative number will reverse the axis direction.
  38782. */
  38783. angularSensibilityY: number;
  38784. /**
  38785. * Defines the pointer pinch precision or how fast is the camera zooming.
  38786. * A negative number will reverse the axis direction.
  38787. */
  38788. pinchPrecision: number;
  38789. /**
  38790. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38791. * from 0.
  38792. * It defines the percentage of current camera.radius to use as delta when
  38793. * pinch zoom is used.
  38794. */
  38795. pinchDeltaPercentage: number;
  38796. /**
  38797. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38798. */
  38799. axisXControlRadius: boolean;
  38800. /**
  38801. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38802. */
  38803. axisXControlHeight: boolean;
  38804. /**
  38805. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38806. */
  38807. axisXControlRotation: boolean;
  38808. /**
  38809. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38810. */
  38811. axisYControlRadius: boolean;
  38812. /**
  38813. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38814. */
  38815. axisYControlHeight: boolean;
  38816. /**
  38817. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38818. */
  38819. axisYControlRotation: boolean;
  38820. /**
  38821. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38822. */
  38823. axisPinchControlRadius: boolean;
  38824. /**
  38825. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38826. */
  38827. axisPinchControlHeight: boolean;
  38828. /**
  38829. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38830. */
  38831. axisPinchControlRotation: boolean;
  38832. /**
  38833. * Log error messages if basic misconfiguration has occurred.
  38834. */
  38835. warningEnable: boolean;
  38836. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38837. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38838. private _warningCounter;
  38839. private _warning;
  38840. }
  38841. }
  38842. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38843. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38844. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38845. /**
  38846. * Default Inputs manager for the FollowCamera.
  38847. * It groups all the default supported inputs for ease of use.
  38848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38849. */
  38850. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38851. /**
  38852. * Instantiates a new FollowCameraInputsManager.
  38853. * @param camera Defines the camera the inputs belong to
  38854. */
  38855. constructor(camera: FollowCamera);
  38856. /**
  38857. * Add keyboard input support to the input manager.
  38858. * @returns the current input manager
  38859. */
  38860. addKeyboard(): FollowCameraInputsManager;
  38861. /**
  38862. * Add mouse wheel input support to the input manager.
  38863. * @returns the current input manager
  38864. */
  38865. addMouseWheel(): FollowCameraInputsManager;
  38866. /**
  38867. * Add pointers input support to the input manager.
  38868. * @returns the current input manager
  38869. */
  38870. addPointers(): FollowCameraInputsManager;
  38871. /**
  38872. * Add orientation input support to the input manager.
  38873. * @returns the current input manager
  38874. */
  38875. addVRDeviceOrientation(): FollowCameraInputsManager;
  38876. }
  38877. }
  38878. declare module "babylonjs/Cameras/followCamera" {
  38879. import { Nullable } from "babylonjs/types";
  38880. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38881. import { Scene } from "babylonjs/scene";
  38882. import { Vector3 } from "babylonjs/Maths/math.vector";
  38883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38884. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38885. /**
  38886. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38887. * an arc rotate version arcFollowCamera are available.
  38888. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38889. */
  38890. export class FollowCamera extends TargetCamera {
  38891. /**
  38892. * Distance the follow camera should follow an object at
  38893. */
  38894. radius: number;
  38895. /**
  38896. * Minimum allowed distance of the camera to the axis of rotation
  38897. * (The camera can not get closer).
  38898. * This can help limiting how the Camera is able to move in the scene.
  38899. */
  38900. lowerRadiusLimit: Nullable<number>;
  38901. /**
  38902. * Maximum allowed distance of the camera to the axis of rotation
  38903. * (The camera can not get further).
  38904. * This can help limiting how the Camera is able to move in the scene.
  38905. */
  38906. upperRadiusLimit: Nullable<number>;
  38907. /**
  38908. * Define a rotation offset between the camera and the object it follows
  38909. */
  38910. rotationOffset: number;
  38911. /**
  38912. * Minimum allowed angle to camera position relative to target object.
  38913. * This can help limiting how the Camera is able to move in the scene.
  38914. */
  38915. lowerRotationOffsetLimit: Nullable<number>;
  38916. /**
  38917. * Maximum allowed angle to camera position relative to target object.
  38918. * This can help limiting how the Camera is able to move in the scene.
  38919. */
  38920. upperRotationOffsetLimit: Nullable<number>;
  38921. /**
  38922. * Define a height offset between the camera and the object it follows.
  38923. * It can help following an object from the top (like a car chaing a plane)
  38924. */
  38925. heightOffset: number;
  38926. /**
  38927. * Minimum allowed height of camera position relative to target object.
  38928. * This can help limiting how the Camera is able to move in the scene.
  38929. */
  38930. lowerHeightOffsetLimit: Nullable<number>;
  38931. /**
  38932. * Maximum allowed height of camera position relative to target object.
  38933. * This can help limiting how the Camera is able to move in the scene.
  38934. */
  38935. upperHeightOffsetLimit: Nullable<number>;
  38936. /**
  38937. * Define how fast the camera can accelerate to follow it s target.
  38938. */
  38939. cameraAcceleration: number;
  38940. /**
  38941. * Define the speed limit of the camera following an object.
  38942. */
  38943. maxCameraSpeed: number;
  38944. /**
  38945. * Define the target of the camera.
  38946. */
  38947. lockedTarget: Nullable<AbstractMesh>;
  38948. /**
  38949. * Defines the input associated with the camera.
  38950. */
  38951. inputs: FollowCameraInputsManager;
  38952. /**
  38953. * Instantiates the follow camera.
  38954. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38955. * @param name Define the name of the camera in the scene
  38956. * @param position Define the position of the camera
  38957. * @param scene Define the scene the camera belong to
  38958. * @param lockedTarget Define the target of the camera
  38959. */
  38960. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38961. private _follow;
  38962. /**
  38963. * Attached controls to the current camera.
  38964. * @param element Defines the element the controls should be listened from
  38965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38966. */
  38967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38968. /**
  38969. * Detach the current controls from the camera.
  38970. * The camera will stop reacting to inputs.
  38971. * @param element Defines the element to stop listening the inputs from
  38972. */
  38973. detachControl(element: HTMLElement): void;
  38974. /** @hidden */
  38975. _checkInputs(): void;
  38976. private _checkLimits;
  38977. /**
  38978. * Gets the camera class name.
  38979. * @returns the class name
  38980. */
  38981. getClassName(): string;
  38982. }
  38983. /**
  38984. * Arc Rotate version of the follow camera.
  38985. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38986. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38987. */
  38988. export class ArcFollowCamera extends TargetCamera {
  38989. /** The longitudinal angle of the camera */
  38990. alpha: number;
  38991. /** The latitudinal angle of the camera */
  38992. beta: number;
  38993. /** The radius of the camera from its target */
  38994. radius: number;
  38995. /** Define the camera target (the messh it should follow) */
  38996. target: Nullable<AbstractMesh>;
  38997. private _cartesianCoordinates;
  38998. /**
  38999. * Instantiates a new ArcFollowCamera
  39000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39001. * @param name Define the name of the camera
  39002. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39003. * @param beta Define the rotation angle of the camera around the elevation axis
  39004. * @param radius Define the radius of the camera from its target point
  39005. * @param target Define the target of the camera
  39006. * @param scene Define the scene the camera belongs to
  39007. */
  39008. constructor(name: string,
  39009. /** The longitudinal angle of the camera */
  39010. alpha: number,
  39011. /** The latitudinal angle of the camera */
  39012. beta: number,
  39013. /** The radius of the camera from its target */
  39014. radius: number,
  39015. /** Define the camera target (the messh it should follow) */
  39016. target: Nullable<AbstractMesh>, scene: Scene);
  39017. private _follow;
  39018. /** @hidden */
  39019. _checkInputs(): void;
  39020. /**
  39021. * Returns the class name of the object.
  39022. * It is mostly used internally for serialization purposes.
  39023. */
  39024. getClassName(): string;
  39025. }
  39026. }
  39027. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39028. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39029. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39030. import { Nullable } from "babylonjs/types";
  39031. /**
  39032. * Manage the keyboard inputs to control the movement of a follow camera.
  39033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39034. */
  39035. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39036. /**
  39037. * Defines the camera the input is attached to.
  39038. */
  39039. camera: FollowCamera;
  39040. /**
  39041. * Defines the list of key codes associated with the up action (increase heightOffset)
  39042. */
  39043. keysHeightOffsetIncr: number[];
  39044. /**
  39045. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39046. */
  39047. keysHeightOffsetDecr: number[];
  39048. /**
  39049. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39050. */
  39051. keysHeightOffsetModifierAlt: boolean;
  39052. /**
  39053. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39054. */
  39055. keysHeightOffsetModifierCtrl: boolean;
  39056. /**
  39057. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39058. */
  39059. keysHeightOffsetModifierShift: boolean;
  39060. /**
  39061. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39062. */
  39063. keysRotationOffsetIncr: number[];
  39064. /**
  39065. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39066. */
  39067. keysRotationOffsetDecr: number[];
  39068. /**
  39069. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39070. */
  39071. keysRotationOffsetModifierAlt: boolean;
  39072. /**
  39073. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39074. */
  39075. keysRotationOffsetModifierCtrl: boolean;
  39076. /**
  39077. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39078. */
  39079. keysRotationOffsetModifierShift: boolean;
  39080. /**
  39081. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39082. */
  39083. keysRadiusIncr: number[];
  39084. /**
  39085. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39086. */
  39087. keysRadiusDecr: number[];
  39088. /**
  39089. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39090. */
  39091. keysRadiusModifierAlt: boolean;
  39092. /**
  39093. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39094. */
  39095. keysRadiusModifierCtrl: boolean;
  39096. /**
  39097. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39098. */
  39099. keysRadiusModifierShift: boolean;
  39100. /**
  39101. * Defines the rate of change of heightOffset.
  39102. */
  39103. heightSensibility: number;
  39104. /**
  39105. * Defines the rate of change of rotationOffset.
  39106. */
  39107. rotationSensibility: number;
  39108. /**
  39109. * Defines the rate of change of radius.
  39110. */
  39111. radiusSensibility: number;
  39112. private _keys;
  39113. private _ctrlPressed;
  39114. private _altPressed;
  39115. private _shiftPressed;
  39116. private _onCanvasBlurObserver;
  39117. private _onKeyboardObserver;
  39118. private _engine;
  39119. private _scene;
  39120. /**
  39121. * Attach the input controls to a specific dom element to get the input from.
  39122. * @param element Defines the element the controls should be listened from
  39123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39124. */
  39125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39126. /**
  39127. * Detach the current controls from the specified dom element.
  39128. * @param element Defines the element to stop listening the inputs from
  39129. */
  39130. detachControl(element: Nullable<HTMLElement>): void;
  39131. /**
  39132. * Update the current camera state depending on the inputs that have been used this frame.
  39133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39134. */
  39135. checkInputs(): void;
  39136. /**
  39137. * Gets the class name of the current input.
  39138. * @returns the class name
  39139. */
  39140. getClassName(): string;
  39141. /**
  39142. * Get the friendly name associated with the input class.
  39143. * @returns the input friendly name
  39144. */
  39145. getSimpleName(): string;
  39146. /**
  39147. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39148. * allow modification of the heightOffset value.
  39149. */
  39150. private _modifierHeightOffset;
  39151. /**
  39152. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39153. * allow modification of the rotationOffset value.
  39154. */
  39155. private _modifierRotationOffset;
  39156. /**
  39157. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39158. * allow modification of the radius value.
  39159. */
  39160. private _modifierRadius;
  39161. }
  39162. }
  39163. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39164. import { Nullable } from "babylonjs/types";
  39165. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39166. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39167. import { Observable } from "babylonjs/Misc/observable";
  39168. module "babylonjs/Cameras/freeCameraInputsManager" {
  39169. interface FreeCameraInputsManager {
  39170. /**
  39171. * @hidden
  39172. */
  39173. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39174. /**
  39175. * Add orientation input support to the input manager.
  39176. * @returns the current input manager
  39177. */
  39178. addDeviceOrientation(): FreeCameraInputsManager;
  39179. }
  39180. }
  39181. /**
  39182. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39183. * Screen rotation is taken into account.
  39184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39185. */
  39186. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39187. private _camera;
  39188. private _screenOrientationAngle;
  39189. private _constantTranform;
  39190. private _screenQuaternion;
  39191. private _alpha;
  39192. private _beta;
  39193. private _gamma;
  39194. /**
  39195. * Can be used to detect if a device orientation sensor is availible on a device
  39196. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39197. * @returns a promise that will resolve on orientation change
  39198. */
  39199. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39200. /**
  39201. * @hidden
  39202. */
  39203. _onDeviceOrientationChangedObservable: Observable<void>;
  39204. /**
  39205. * Instantiates a new input
  39206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39207. */
  39208. constructor();
  39209. /**
  39210. * Define the camera controlled by the input.
  39211. */
  39212. camera: FreeCamera;
  39213. /**
  39214. * Attach the input controls to a specific dom element to get the input from.
  39215. * @param element Defines the element the controls should be listened from
  39216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39217. */
  39218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39219. private _orientationChanged;
  39220. private _deviceOrientation;
  39221. /**
  39222. * Detach the current controls from the specified dom element.
  39223. * @param element Defines the element to stop listening the inputs from
  39224. */
  39225. detachControl(element: Nullable<HTMLElement>): void;
  39226. /**
  39227. * Update the current camera state depending on the inputs that have been used this frame.
  39228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39229. */
  39230. checkInputs(): void;
  39231. /**
  39232. * Gets the class name of the current intput.
  39233. * @returns the class name
  39234. */
  39235. getClassName(): string;
  39236. /**
  39237. * Get the friendly name associated with the input class.
  39238. * @returns the input friendly name
  39239. */
  39240. getSimpleName(): string;
  39241. }
  39242. }
  39243. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39244. import { Nullable } from "babylonjs/types";
  39245. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39246. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39247. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39248. /**
  39249. * Manage the gamepad inputs to control a free camera.
  39250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39251. */
  39252. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39253. /**
  39254. * Define the camera the input is attached to.
  39255. */
  39256. camera: FreeCamera;
  39257. /**
  39258. * Define the Gamepad controlling the input
  39259. */
  39260. gamepad: Nullable<Gamepad>;
  39261. /**
  39262. * Defines the gamepad rotation sensiblity.
  39263. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39264. */
  39265. gamepadAngularSensibility: number;
  39266. /**
  39267. * Defines the gamepad move sensiblity.
  39268. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39269. */
  39270. gamepadMoveSensibility: number;
  39271. private _onGamepadConnectedObserver;
  39272. private _onGamepadDisconnectedObserver;
  39273. private _cameraTransform;
  39274. private _deltaTransform;
  39275. private _vector3;
  39276. private _vector2;
  39277. /**
  39278. * Attach the input controls to a specific dom element to get the input from.
  39279. * @param element Defines the element the controls should be listened from
  39280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39281. */
  39282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39283. /**
  39284. * Detach the current controls from the specified dom element.
  39285. * @param element Defines the element to stop listening the inputs from
  39286. */
  39287. detachControl(element: Nullable<HTMLElement>): void;
  39288. /**
  39289. * Update the current camera state depending on the inputs that have been used this frame.
  39290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39291. */
  39292. checkInputs(): void;
  39293. /**
  39294. * Gets the class name of the current intput.
  39295. * @returns the class name
  39296. */
  39297. getClassName(): string;
  39298. /**
  39299. * Get the friendly name associated with the input class.
  39300. * @returns the input friendly name
  39301. */
  39302. getSimpleName(): string;
  39303. }
  39304. }
  39305. declare module "babylonjs/Misc/virtualJoystick" {
  39306. import { Nullable } from "babylonjs/types";
  39307. import { Vector3 } from "babylonjs/Maths/math.vector";
  39308. /**
  39309. * Defines the potential axis of a Joystick
  39310. */
  39311. export enum JoystickAxis {
  39312. /** X axis */
  39313. X = 0,
  39314. /** Y axis */
  39315. Y = 1,
  39316. /** Z axis */
  39317. Z = 2
  39318. }
  39319. /**
  39320. * Class used to define virtual joystick (used in touch mode)
  39321. */
  39322. export class VirtualJoystick {
  39323. /**
  39324. * Gets or sets a boolean indicating that left and right values must be inverted
  39325. */
  39326. reverseLeftRight: boolean;
  39327. /**
  39328. * Gets or sets a boolean indicating that up and down values must be inverted
  39329. */
  39330. reverseUpDown: boolean;
  39331. /**
  39332. * Gets the offset value for the position (ie. the change of the position value)
  39333. */
  39334. deltaPosition: Vector3;
  39335. /**
  39336. * Gets a boolean indicating if the virtual joystick was pressed
  39337. */
  39338. pressed: boolean;
  39339. /**
  39340. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39341. */
  39342. static Canvas: Nullable<HTMLCanvasElement>;
  39343. private static _globalJoystickIndex;
  39344. private static vjCanvasContext;
  39345. private static vjCanvasWidth;
  39346. private static vjCanvasHeight;
  39347. private static halfWidth;
  39348. private _action;
  39349. private _axisTargetedByLeftAndRight;
  39350. private _axisTargetedByUpAndDown;
  39351. private _joystickSensibility;
  39352. private _inversedSensibility;
  39353. private _joystickPointerID;
  39354. private _joystickColor;
  39355. private _joystickPointerPos;
  39356. private _joystickPreviousPointerPos;
  39357. private _joystickPointerStartPos;
  39358. private _deltaJoystickVector;
  39359. private _leftJoystick;
  39360. private _touches;
  39361. private _onPointerDownHandlerRef;
  39362. private _onPointerMoveHandlerRef;
  39363. private _onPointerUpHandlerRef;
  39364. private _onResize;
  39365. /**
  39366. * Creates a new virtual joystick
  39367. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39368. */
  39369. constructor(leftJoystick?: boolean);
  39370. /**
  39371. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39372. * @param newJoystickSensibility defines the new sensibility
  39373. */
  39374. setJoystickSensibility(newJoystickSensibility: number): void;
  39375. private _onPointerDown;
  39376. private _onPointerMove;
  39377. private _onPointerUp;
  39378. /**
  39379. * Change the color of the virtual joystick
  39380. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39381. */
  39382. setJoystickColor(newColor: string): void;
  39383. /**
  39384. * Defines a callback to call when the joystick is touched
  39385. * @param action defines the callback
  39386. */
  39387. setActionOnTouch(action: () => any): void;
  39388. /**
  39389. * Defines which axis you'd like to control for left & right
  39390. * @param axis defines the axis to use
  39391. */
  39392. setAxisForLeftRight(axis: JoystickAxis): void;
  39393. /**
  39394. * Defines which axis you'd like to control for up & down
  39395. * @param axis defines the axis to use
  39396. */
  39397. setAxisForUpDown(axis: JoystickAxis): void;
  39398. private _drawVirtualJoystick;
  39399. /**
  39400. * Release internal HTML canvas
  39401. */
  39402. releaseCanvas(): void;
  39403. }
  39404. }
  39405. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39406. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39407. import { Nullable } from "babylonjs/types";
  39408. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39409. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39410. module "babylonjs/Cameras/freeCameraInputsManager" {
  39411. interface FreeCameraInputsManager {
  39412. /**
  39413. * Add virtual joystick input support to the input manager.
  39414. * @returns the current input manager
  39415. */
  39416. addVirtualJoystick(): FreeCameraInputsManager;
  39417. }
  39418. }
  39419. /**
  39420. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39422. */
  39423. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39424. /**
  39425. * Defines the camera the input is attached to.
  39426. */
  39427. camera: FreeCamera;
  39428. private _leftjoystick;
  39429. private _rightjoystick;
  39430. /**
  39431. * Gets the left stick of the virtual joystick.
  39432. * @returns The virtual Joystick
  39433. */
  39434. getLeftJoystick(): VirtualJoystick;
  39435. /**
  39436. * Gets the right stick of the virtual joystick.
  39437. * @returns The virtual Joystick
  39438. */
  39439. getRightJoystick(): VirtualJoystick;
  39440. /**
  39441. * Update the current camera state depending on the inputs that have been used this frame.
  39442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39443. */
  39444. checkInputs(): void;
  39445. /**
  39446. * Attach the input controls to a specific dom element to get the input from.
  39447. * @param element Defines the element the controls should be listened from
  39448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39449. */
  39450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39451. /**
  39452. * Detach the current controls from the specified dom element.
  39453. * @param element Defines the element to stop listening the inputs from
  39454. */
  39455. detachControl(element: Nullable<HTMLElement>): void;
  39456. /**
  39457. * Gets the class name of the current intput.
  39458. * @returns the class name
  39459. */
  39460. getClassName(): string;
  39461. /**
  39462. * Get the friendly name associated with the input class.
  39463. * @returns the input friendly name
  39464. */
  39465. getSimpleName(): string;
  39466. }
  39467. }
  39468. declare module "babylonjs/Cameras/Inputs/index" {
  39469. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39470. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39471. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39472. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39473. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39474. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39475. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39476. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39477. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39478. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39479. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39480. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39481. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39482. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39483. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39484. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39485. }
  39486. declare module "babylonjs/Cameras/touchCamera" {
  39487. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39488. import { Scene } from "babylonjs/scene";
  39489. import { Vector3 } from "babylonjs/Maths/math.vector";
  39490. /**
  39491. * This represents a FPS type of camera controlled by touch.
  39492. * This is like a universal camera minus the Gamepad controls.
  39493. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39494. */
  39495. export class TouchCamera extends FreeCamera {
  39496. /**
  39497. * Defines the touch sensibility for rotation.
  39498. * The higher the faster.
  39499. */
  39500. touchAngularSensibility: number;
  39501. /**
  39502. * Defines the touch sensibility for move.
  39503. * The higher the faster.
  39504. */
  39505. touchMoveSensibility: number;
  39506. /**
  39507. * Instantiates a new touch camera.
  39508. * This represents a FPS type of camera controlled by touch.
  39509. * This is like a universal camera minus the Gamepad controls.
  39510. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39511. * @param name Define the name of the camera in the scene
  39512. * @param position Define the start position of the camera in the scene
  39513. * @param scene Define the scene the camera belongs to
  39514. */
  39515. constructor(name: string, position: Vector3, scene: Scene);
  39516. /**
  39517. * Gets the current object class name.
  39518. * @return the class name
  39519. */
  39520. getClassName(): string;
  39521. /** @hidden */
  39522. _setupInputs(): void;
  39523. }
  39524. }
  39525. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39526. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39527. import { Scene } from "babylonjs/scene";
  39528. import { Vector3 } from "babylonjs/Maths/math.vector";
  39529. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39530. import { Axis } from "babylonjs/Maths/math.axis";
  39531. /**
  39532. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39533. * being tilted forward or back and left or right.
  39534. */
  39535. export class DeviceOrientationCamera extends FreeCamera {
  39536. private _initialQuaternion;
  39537. private _quaternionCache;
  39538. private _tmpDragQuaternion;
  39539. private _disablePointerInputWhenUsingDeviceOrientation;
  39540. /**
  39541. * Creates a new device orientation camera
  39542. * @param name The name of the camera
  39543. * @param position The start position camera
  39544. * @param scene The scene the camera belongs to
  39545. */
  39546. constructor(name: string, position: Vector3, scene: Scene);
  39547. /**
  39548. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39549. */
  39550. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39551. private _dragFactor;
  39552. /**
  39553. * Enabled turning on the y axis when the orientation sensor is active
  39554. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39555. */
  39556. enableHorizontalDragging(dragFactor?: number): void;
  39557. /**
  39558. * Gets the current instance class name ("DeviceOrientationCamera").
  39559. * This helps avoiding instanceof at run time.
  39560. * @returns the class name
  39561. */
  39562. getClassName(): string;
  39563. /**
  39564. * @hidden
  39565. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39566. */
  39567. _checkInputs(): void;
  39568. /**
  39569. * Reset the camera to its default orientation on the specified axis only.
  39570. * @param axis The axis to reset
  39571. */
  39572. resetToCurrentRotation(axis?: Axis): void;
  39573. }
  39574. }
  39575. declare module "babylonjs/Gamepads/xboxGamepad" {
  39576. import { Observable } from "babylonjs/Misc/observable";
  39577. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39578. /**
  39579. * Defines supported buttons for XBox360 compatible gamepads
  39580. */
  39581. export enum Xbox360Button {
  39582. /** A */
  39583. A = 0,
  39584. /** B */
  39585. B = 1,
  39586. /** X */
  39587. X = 2,
  39588. /** Y */
  39589. Y = 3,
  39590. /** Start */
  39591. Start = 4,
  39592. /** Back */
  39593. Back = 5,
  39594. /** Left button */
  39595. LB = 6,
  39596. /** Right button */
  39597. RB = 7,
  39598. /** Left stick */
  39599. LeftStick = 8,
  39600. /** Right stick */
  39601. RightStick = 9
  39602. }
  39603. /** Defines values for XBox360 DPad */
  39604. export enum Xbox360Dpad {
  39605. /** Up */
  39606. Up = 0,
  39607. /** Down */
  39608. Down = 1,
  39609. /** Left */
  39610. Left = 2,
  39611. /** Right */
  39612. Right = 3
  39613. }
  39614. /**
  39615. * Defines a XBox360 gamepad
  39616. */
  39617. export class Xbox360Pad extends Gamepad {
  39618. private _leftTrigger;
  39619. private _rightTrigger;
  39620. private _onlefttriggerchanged;
  39621. private _onrighttriggerchanged;
  39622. private _onbuttondown;
  39623. private _onbuttonup;
  39624. private _ondpaddown;
  39625. private _ondpadup;
  39626. /** Observable raised when a button is pressed */
  39627. onButtonDownObservable: Observable<Xbox360Button>;
  39628. /** Observable raised when a button is released */
  39629. onButtonUpObservable: Observable<Xbox360Button>;
  39630. /** Observable raised when a pad is pressed */
  39631. onPadDownObservable: Observable<Xbox360Dpad>;
  39632. /** Observable raised when a pad is released */
  39633. onPadUpObservable: Observable<Xbox360Dpad>;
  39634. private _buttonA;
  39635. private _buttonB;
  39636. private _buttonX;
  39637. private _buttonY;
  39638. private _buttonBack;
  39639. private _buttonStart;
  39640. private _buttonLB;
  39641. private _buttonRB;
  39642. private _buttonLeftStick;
  39643. private _buttonRightStick;
  39644. private _dPadUp;
  39645. private _dPadDown;
  39646. private _dPadLeft;
  39647. private _dPadRight;
  39648. private _isXboxOnePad;
  39649. /**
  39650. * Creates a new XBox360 gamepad object
  39651. * @param id defines the id of this gamepad
  39652. * @param index defines its index
  39653. * @param gamepad defines the internal HTML gamepad object
  39654. * @param xboxOne defines if it is a XBox One gamepad
  39655. */
  39656. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39657. /**
  39658. * Defines the callback to call when left trigger is pressed
  39659. * @param callback defines the callback to use
  39660. */
  39661. onlefttriggerchanged(callback: (value: number) => void): void;
  39662. /**
  39663. * Defines the callback to call when right trigger is pressed
  39664. * @param callback defines the callback to use
  39665. */
  39666. onrighttriggerchanged(callback: (value: number) => void): void;
  39667. /**
  39668. * Gets the left trigger value
  39669. */
  39670. /**
  39671. * Sets the left trigger value
  39672. */
  39673. leftTrigger: number;
  39674. /**
  39675. * Gets the right trigger value
  39676. */
  39677. /**
  39678. * Sets the right trigger value
  39679. */
  39680. rightTrigger: number;
  39681. /**
  39682. * Defines the callback to call when a button is pressed
  39683. * @param callback defines the callback to use
  39684. */
  39685. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39686. /**
  39687. * Defines the callback to call when a button is released
  39688. * @param callback defines the callback to use
  39689. */
  39690. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39691. /**
  39692. * Defines the callback to call when a pad is pressed
  39693. * @param callback defines the callback to use
  39694. */
  39695. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39696. /**
  39697. * Defines the callback to call when a pad is released
  39698. * @param callback defines the callback to use
  39699. */
  39700. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39701. private _setButtonValue;
  39702. private _setDPadValue;
  39703. /**
  39704. * Gets the value of the `A` button
  39705. */
  39706. /**
  39707. * Sets the value of the `A` button
  39708. */
  39709. buttonA: number;
  39710. /**
  39711. * Gets the value of the `B` button
  39712. */
  39713. /**
  39714. * Sets the value of the `B` button
  39715. */
  39716. buttonB: number;
  39717. /**
  39718. * Gets the value of the `X` button
  39719. */
  39720. /**
  39721. * Sets the value of the `X` button
  39722. */
  39723. buttonX: number;
  39724. /**
  39725. * Gets the value of the `Y` button
  39726. */
  39727. /**
  39728. * Sets the value of the `Y` button
  39729. */
  39730. buttonY: number;
  39731. /**
  39732. * Gets the value of the `Start` button
  39733. */
  39734. /**
  39735. * Sets the value of the `Start` button
  39736. */
  39737. buttonStart: number;
  39738. /**
  39739. * Gets the value of the `Back` button
  39740. */
  39741. /**
  39742. * Sets the value of the `Back` button
  39743. */
  39744. buttonBack: number;
  39745. /**
  39746. * Gets the value of the `Left` button
  39747. */
  39748. /**
  39749. * Sets the value of the `Left` button
  39750. */
  39751. buttonLB: number;
  39752. /**
  39753. * Gets the value of the `Right` button
  39754. */
  39755. /**
  39756. * Sets the value of the `Right` button
  39757. */
  39758. buttonRB: number;
  39759. /**
  39760. * Gets the value of the Left joystick
  39761. */
  39762. /**
  39763. * Sets the value of the Left joystick
  39764. */
  39765. buttonLeftStick: number;
  39766. /**
  39767. * Gets the value of the Right joystick
  39768. */
  39769. /**
  39770. * Sets the value of the Right joystick
  39771. */
  39772. buttonRightStick: number;
  39773. /**
  39774. * Gets the value of D-pad up
  39775. */
  39776. /**
  39777. * Sets the value of D-pad up
  39778. */
  39779. dPadUp: number;
  39780. /**
  39781. * Gets the value of D-pad down
  39782. */
  39783. /**
  39784. * Sets the value of D-pad down
  39785. */
  39786. dPadDown: number;
  39787. /**
  39788. * Gets the value of D-pad left
  39789. */
  39790. /**
  39791. * Sets the value of D-pad left
  39792. */
  39793. dPadLeft: number;
  39794. /**
  39795. * Gets the value of D-pad right
  39796. */
  39797. /**
  39798. * Sets the value of D-pad right
  39799. */
  39800. dPadRight: number;
  39801. /**
  39802. * Force the gamepad to synchronize with device values
  39803. */
  39804. update(): void;
  39805. /**
  39806. * Disposes the gamepad
  39807. */
  39808. dispose(): void;
  39809. }
  39810. }
  39811. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39812. import { Observable } from "babylonjs/Misc/observable";
  39813. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39814. /**
  39815. * Defines supported buttons for DualShock compatible gamepads
  39816. */
  39817. export enum DualShockButton {
  39818. /** Cross */
  39819. Cross = 0,
  39820. /** Circle */
  39821. Circle = 1,
  39822. /** Square */
  39823. Square = 2,
  39824. /** Triangle */
  39825. Triangle = 3,
  39826. /** Options */
  39827. Options = 4,
  39828. /** Share */
  39829. Share = 5,
  39830. /** L1 */
  39831. L1 = 6,
  39832. /** R1 */
  39833. R1 = 7,
  39834. /** Left stick */
  39835. LeftStick = 8,
  39836. /** Right stick */
  39837. RightStick = 9
  39838. }
  39839. /** Defines values for DualShock DPad */
  39840. export enum DualShockDpad {
  39841. /** Up */
  39842. Up = 0,
  39843. /** Down */
  39844. Down = 1,
  39845. /** Left */
  39846. Left = 2,
  39847. /** Right */
  39848. Right = 3
  39849. }
  39850. /**
  39851. * Defines a DualShock gamepad
  39852. */
  39853. export class DualShockPad extends Gamepad {
  39854. private _leftTrigger;
  39855. private _rightTrigger;
  39856. private _onlefttriggerchanged;
  39857. private _onrighttriggerchanged;
  39858. private _onbuttondown;
  39859. private _onbuttonup;
  39860. private _ondpaddown;
  39861. private _ondpadup;
  39862. /** Observable raised when a button is pressed */
  39863. onButtonDownObservable: Observable<DualShockButton>;
  39864. /** Observable raised when a button is released */
  39865. onButtonUpObservable: Observable<DualShockButton>;
  39866. /** Observable raised when a pad is pressed */
  39867. onPadDownObservable: Observable<DualShockDpad>;
  39868. /** Observable raised when a pad is released */
  39869. onPadUpObservable: Observable<DualShockDpad>;
  39870. private _buttonCross;
  39871. private _buttonCircle;
  39872. private _buttonSquare;
  39873. private _buttonTriangle;
  39874. private _buttonShare;
  39875. private _buttonOptions;
  39876. private _buttonL1;
  39877. private _buttonR1;
  39878. private _buttonLeftStick;
  39879. private _buttonRightStick;
  39880. private _dPadUp;
  39881. private _dPadDown;
  39882. private _dPadLeft;
  39883. private _dPadRight;
  39884. /**
  39885. * Creates a new DualShock gamepad object
  39886. * @param id defines the id of this gamepad
  39887. * @param index defines its index
  39888. * @param gamepad defines the internal HTML gamepad object
  39889. */
  39890. constructor(id: string, index: number, gamepad: any);
  39891. /**
  39892. * Defines the callback to call when left trigger is pressed
  39893. * @param callback defines the callback to use
  39894. */
  39895. onlefttriggerchanged(callback: (value: number) => void): void;
  39896. /**
  39897. * Defines the callback to call when right trigger is pressed
  39898. * @param callback defines the callback to use
  39899. */
  39900. onrighttriggerchanged(callback: (value: number) => void): void;
  39901. /**
  39902. * Gets the left trigger value
  39903. */
  39904. /**
  39905. * Sets the left trigger value
  39906. */
  39907. leftTrigger: number;
  39908. /**
  39909. * Gets the right trigger value
  39910. */
  39911. /**
  39912. * Sets the right trigger value
  39913. */
  39914. rightTrigger: number;
  39915. /**
  39916. * Defines the callback to call when a button is pressed
  39917. * @param callback defines the callback to use
  39918. */
  39919. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39920. /**
  39921. * Defines the callback to call when a button is released
  39922. * @param callback defines the callback to use
  39923. */
  39924. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39925. /**
  39926. * Defines the callback to call when a pad is pressed
  39927. * @param callback defines the callback to use
  39928. */
  39929. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39930. /**
  39931. * Defines the callback to call when a pad is released
  39932. * @param callback defines the callback to use
  39933. */
  39934. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39935. private _setButtonValue;
  39936. private _setDPadValue;
  39937. /**
  39938. * Gets the value of the `Cross` button
  39939. */
  39940. /**
  39941. * Sets the value of the `Cross` button
  39942. */
  39943. buttonCross: number;
  39944. /**
  39945. * Gets the value of the `Circle` button
  39946. */
  39947. /**
  39948. * Sets the value of the `Circle` button
  39949. */
  39950. buttonCircle: number;
  39951. /**
  39952. * Gets the value of the `Square` button
  39953. */
  39954. /**
  39955. * Sets the value of the `Square` button
  39956. */
  39957. buttonSquare: number;
  39958. /**
  39959. * Gets the value of the `Triangle` button
  39960. */
  39961. /**
  39962. * Sets the value of the `Triangle` button
  39963. */
  39964. buttonTriangle: number;
  39965. /**
  39966. * Gets the value of the `Options` button
  39967. */
  39968. /**
  39969. * Sets the value of the `Options` button
  39970. */
  39971. buttonOptions: number;
  39972. /**
  39973. * Gets the value of the `Share` button
  39974. */
  39975. /**
  39976. * Sets the value of the `Share` button
  39977. */
  39978. buttonShare: number;
  39979. /**
  39980. * Gets the value of the `L1` button
  39981. */
  39982. /**
  39983. * Sets the value of the `L1` button
  39984. */
  39985. buttonL1: number;
  39986. /**
  39987. * Gets the value of the `R1` button
  39988. */
  39989. /**
  39990. * Sets the value of the `R1` button
  39991. */
  39992. buttonR1: number;
  39993. /**
  39994. * Gets the value of the Left joystick
  39995. */
  39996. /**
  39997. * Sets the value of the Left joystick
  39998. */
  39999. buttonLeftStick: number;
  40000. /**
  40001. * Gets the value of the Right joystick
  40002. */
  40003. /**
  40004. * Sets the value of the Right joystick
  40005. */
  40006. buttonRightStick: number;
  40007. /**
  40008. * Gets the value of D-pad up
  40009. */
  40010. /**
  40011. * Sets the value of D-pad up
  40012. */
  40013. dPadUp: number;
  40014. /**
  40015. * Gets the value of D-pad down
  40016. */
  40017. /**
  40018. * Sets the value of D-pad down
  40019. */
  40020. dPadDown: number;
  40021. /**
  40022. * Gets the value of D-pad left
  40023. */
  40024. /**
  40025. * Sets the value of D-pad left
  40026. */
  40027. dPadLeft: number;
  40028. /**
  40029. * Gets the value of D-pad right
  40030. */
  40031. /**
  40032. * Sets the value of D-pad right
  40033. */
  40034. dPadRight: number;
  40035. /**
  40036. * Force the gamepad to synchronize with device values
  40037. */
  40038. update(): void;
  40039. /**
  40040. * Disposes the gamepad
  40041. */
  40042. dispose(): void;
  40043. }
  40044. }
  40045. declare module "babylonjs/Gamepads/gamepadManager" {
  40046. import { Observable } from "babylonjs/Misc/observable";
  40047. import { Nullable } from "babylonjs/types";
  40048. import { Scene } from "babylonjs/scene";
  40049. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40050. /**
  40051. * Manager for handling gamepads
  40052. */
  40053. export class GamepadManager {
  40054. private _scene?;
  40055. private _babylonGamepads;
  40056. private _oneGamepadConnected;
  40057. /** @hidden */
  40058. _isMonitoring: boolean;
  40059. private _gamepadEventSupported;
  40060. private _gamepadSupport;
  40061. /**
  40062. * observable to be triggered when the gamepad controller has been connected
  40063. */
  40064. onGamepadConnectedObservable: Observable<Gamepad>;
  40065. /**
  40066. * observable to be triggered when the gamepad controller has been disconnected
  40067. */
  40068. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40069. private _onGamepadConnectedEvent;
  40070. private _onGamepadDisconnectedEvent;
  40071. /**
  40072. * Initializes the gamepad manager
  40073. * @param _scene BabylonJS scene
  40074. */
  40075. constructor(_scene?: Scene | undefined);
  40076. /**
  40077. * The gamepads in the game pad manager
  40078. */
  40079. readonly gamepads: Gamepad[];
  40080. /**
  40081. * Get the gamepad controllers based on type
  40082. * @param type The type of gamepad controller
  40083. * @returns Nullable gamepad
  40084. */
  40085. getGamepadByType(type?: number): Nullable<Gamepad>;
  40086. /**
  40087. * Disposes the gamepad manager
  40088. */
  40089. dispose(): void;
  40090. private _addNewGamepad;
  40091. private _startMonitoringGamepads;
  40092. private _stopMonitoringGamepads;
  40093. /** @hidden */
  40094. _checkGamepadsStatus(): void;
  40095. private _updateGamepadObjects;
  40096. }
  40097. }
  40098. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40099. import { Nullable } from "babylonjs/types";
  40100. import { Scene } from "babylonjs/scene";
  40101. import { ISceneComponent } from "babylonjs/sceneComponent";
  40102. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40103. module "babylonjs/scene" {
  40104. interface Scene {
  40105. /** @hidden */
  40106. _gamepadManager: Nullable<GamepadManager>;
  40107. /**
  40108. * Gets the gamepad manager associated with the scene
  40109. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40110. */
  40111. gamepadManager: GamepadManager;
  40112. }
  40113. }
  40114. module "babylonjs/Cameras/freeCameraInputsManager" {
  40115. /**
  40116. * Interface representing a free camera inputs manager
  40117. */
  40118. interface FreeCameraInputsManager {
  40119. /**
  40120. * Adds gamepad input support to the FreeCameraInputsManager.
  40121. * @returns the FreeCameraInputsManager
  40122. */
  40123. addGamepad(): FreeCameraInputsManager;
  40124. }
  40125. }
  40126. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40127. /**
  40128. * Interface representing an arc rotate camera inputs manager
  40129. */
  40130. interface ArcRotateCameraInputsManager {
  40131. /**
  40132. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40133. * @returns the camera inputs manager
  40134. */
  40135. addGamepad(): ArcRotateCameraInputsManager;
  40136. }
  40137. }
  40138. /**
  40139. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40140. */
  40141. export class GamepadSystemSceneComponent implements ISceneComponent {
  40142. /**
  40143. * The component name helpfull to identify the component in the list of scene components.
  40144. */
  40145. readonly name: string;
  40146. /**
  40147. * The scene the component belongs to.
  40148. */
  40149. scene: Scene;
  40150. /**
  40151. * Creates a new instance of the component for the given scene
  40152. * @param scene Defines the scene to register the component in
  40153. */
  40154. constructor(scene: Scene);
  40155. /**
  40156. * Registers the component in a given scene
  40157. */
  40158. register(): void;
  40159. /**
  40160. * Rebuilds the elements related to this component in case of
  40161. * context lost for instance.
  40162. */
  40163. rebuild(): void;
  40164. /**
  40165. * Disposes the component and the associated ressources
  40166. */
  40167. dispose(): void;
  40168. private _beforeCameraUpdate;
  40169. }
  40170. }
  40171. declare module "babylonjs/Cameras/universalCamera" {
  40172. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40173. import { Scene } from "babylonjs/scene";
  40174. import { Vector3 } from "babylonjs/Maths/math.vector";
  40175. import "babylonjs/Gamepads/gamepadSceneComponent";
  40176. /**
  40177. * 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,
  40178. * which still works and will still be found in many Playgrounds.
  40179. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40180. */
  40181. export class UniversalCamera extends TouchCamera {
  40182. /**
  40183. * Defines the gamepad rotation sensiblity.
  40184. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40185. */
  40186. gamepadAngularSensibility: number;
  40187. /**
  40188. * Defines the gamepad move sensiblity.
  40189. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40190. */
  40191. gamepadMoveSensibility: number;
  40192. /**
  40193. * 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,
  40194. * which still works and will still be found in many Playgrounds.
  40195. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40196. * @param name Define the name of the camera in the scene
  40197. * @param position Define the start position of the camera in the scene
  40198. * @param scene Define the scene the camera belongs to
  40199. */
  40200. constructor(name: string, position: Vector3, scene: Scene);
  40201. /**
  40202. * Gets the current object class name.
  40203. * @return the class name
  40204. */
  40205. getClassName(): string;
  40206. }
  40207. }
  40208. declare module "babylonjs/Cameras/gamepadCamera" {
  40209. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40210. import { Scene } from "babylonjs/scene";
  40211. import { Vector3 } from "babylonjs/Maths/math.vector";
  40212. /**
  40213. * This represents a FPS type of camera. This is only here for back compat purpose.
  40214. * Please use the UniversalCamera instead as both are identical.
  40215. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40216. */
  40217. export class GamepadCamera extends UniversalCamera {
  40218. /**
  40219. * Instantiates a new Gamepad Camera
  40220. * This represents a FPS type of camera. This is only here for back compat purpose.
  40221. * Please use the UniversalCamera instead as both are identical.
  40222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40223. * @param name Define the name of the camera in the scene
  40224. * @param position Define the start position of the camera in the scene
  40225. * @param scene Define the scene the camera belongs to
  40226. */
  40227. constructor(name: string, position: Vector3, scene: Scene);
  40228. /**
  40229. * Gets the current object class name.
  40230. * @return the class name
  40231. */
  40232. getClassName(): string;
  40233. }
  40234. }
  40235. declare module "babylonjs/Shaders/pass.fragment" {
  40236. /** @hidden */
  40237. export var passPixelShader: {
  40238. name: string;
  40239. shader: string;
  40240. };
  40241. }
  40242. declare module "babylonjs/Shaders/passCube.fragment" {
  40243. /** @hidden */
  40244. export var passCubePixelShader: {
  40245. name: string;
  40246. shader: string;
  40247. };
  40248. }
  40249. declare module "babylonjs/PostProcesses/passPostProcess" {
  40250. import { Nullable } from "babylonjs/types";
  40251. import { Camera } from "babylonjs/Cameras/camera";
  40252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40253. import { Engine } from "babylonjs/Engines/engine";
  40254. import "babylonjs/Shaders/pass.fragment";
  40255. import "babylonjs/Shaders/passCube.fragment";
  40256. /**
  40257. * PassPostProcess which produces an output the same as it's input
  40258. */
  40259. export class PassPostProcess extends PostProcess {
  40260. /**
  40261. * Creates the PassPostProcess
  40262. * @param name The name of the effect.
  40263. * @param options The required width/height ratio to downsize to before computing the render pass.
  40264. * @param camera The camera to apply the render pass to.
  40265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40266. * @param engine The engine which the post process will be applied. (default: current engine)
  40267. * @param reusable If the post process can be reused on the same frame. (default: false)
  40268. * @param textureType The type of texture to be used when performing the post processing.
  40269. * @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)
  40270. */
  40271. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40272. }
  40273. /**
  40274. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40275. */
  40276. export class PassCubePostProcess extends PostProcess {
  40277. private _face;
  40278. /**
  40279. * Gets or sets the cube face to display.
  40280. * * 0 is +X
  40281. * * 1 is -X
  40282. * * 2 is +Y
  40283. * * 3 is -Y
  40284. * * 4 is +Z
  40285. * * 5 is -Z
  40286. */
  40287. face: number;
  40288. /**
  40289. * Creates the PassCubePostProcess
  40290. * @param name The name of the effect.
  40291. * @param options The required width/height ratio to downsize to before computing the render pass.
  40292. * @param camera The camera to apply the render pass to.
  40293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40294. * @param engine The engine which the post process will be applied. (default: current engine)
  40295. * @param reusable If the post process can be reused on the same frame. (default: false)
  40296. * @param textureType The type of texture to be used when performing the post processing.
  40297. * @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)
  40298. */
  40299. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40300. }
  40301. }
  40302. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40303. /** @hidden */
  40304. export var anaglyphPixelShader: {
  40305. name: string;
  40306. shader: string;
  40307. };
  40308. }
  40309. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40310. import { Engine } from "babylonjs/Engines/engine";
  40311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40312. import { Camera } from "babylonjs/Cameras/camera";
  40313. import "babylonjs/Shaders/anaglyph.fragment";
  40314. /**
  40315. * Postprocess used to generate anaglyphic rendering
  40316. */
  40317. export class AnaglyphPostProcess extends PostProcess {
  40318. private _passedProcess;
  40319. /**
  40320. * Creates a new AnaglyphPostProcess
  40321. * @param name defines postprocess name
  40322. * @param options defines creation options or target ratio scale
  40323. * @param rigCameras defines cameras using this postprocess
  40324. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40325. * @param engine defines hosting engine
  40326. * @param reusable defines if the postprocess will be reused multiple times per frame
  40327. */
  40328. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40329. }
  40330. }
  40331. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40332. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40333. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40334. import { Scene } from "babylonjs/scene";
  40335. import { Vector3 } from "babylonjs/Maths/math.vector";
  40336. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40337. /**
  40338. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40340. */
  40341. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40342. /**
  40343. * Creates a new AnaglyphArcRotateCamera
  40344. * @param name defines camera name
  40345. * @param alpha defines alpha angle (in radians)
  40346. * @param beta defines beta angle (in radians)
  40347. * @param radius defines radius
  40348. * @param target defines camera target
  40349. * @param interaxialDistance defines distance between each color axis
  40350. * @param scene defines the hosting scene
  40351. */
  40352. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40353. /**
  40354. * Gets camera class name
  40355. * @returns AnaglyphArcRotateCamera
  40356. */
  40357. getClassName(): string;
  40358. }
  40359. }
  40360. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40361. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40362. import { Scene } from "babylonjs/scene";
  40363. import { Vector3 } from "babylonjs/Maths/math.vector";
  40364. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40365. /**
  40366. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40367. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40368. */
  40369. export class AnaglyphFreeCamera extends FreeCamera {
  40370. /**
  40371. * Creates a new AnaglyphFreeCamera
  40372. * @param name defines camera name
  40373. * @param position defines initial position
  40374. * @param interaxialDistance defines distance between each color axis
  40375. * @param scene defines the hosting scene
  40376. */
  40377. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40378. /**
  40379. * Gets camera class name
  40380. * @returns AnaglyphFreeCamera
  40381. */
  40382. getClassName(): string;
  40383. }
  40384. }
  40385. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40386. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40387. import { Scene } from "babylonjs/scene";
  40388. import { Vector3 } from "babylonjs/Maths/math.vector";
  40389. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40390. /**
  40391. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40392. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40393. */
  40394. export class AnaglyphGamepadCamera extends GamepadCamera {
  40395. /**
  40396. * Creates a new AnaglyphGamepadCamera
  40397. * @param name defines camera name
  40398. * @param position defines initial position
  40399. * @param interaxialDistance defines distance between each color axis
  40400. * @param scene defines the hosting scene
  40401. */
  40402. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40403. /**
  40404. * Gets camera class name
  40405. * @returns AnaglyphGamepadCamera
  40406. */
  40407. getClassName(): string;
  40408. }
  40409. }
  40410. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40411. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40412. import { Scene } from "babylonjs/scene";
  40413. import { Vector3 } from "babylonjs/Maths/math.vector";
  40414. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40415. /**
  40416. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40417. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40418. */
  40419. export class AnaglyphUniversalCamera extends UniversalCamera {
  40420. /**
  40421. * Creates a new AnaglyphUniversalCamera
  40422. * @param name defines camera name
  40423. * @param position defines initial position
  40424. * @param interaxialDistance defines distance between each color axis
  40425. * @param scene defines the hosting scene
  40426. */
  40427. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40428. /**
  40429. * Gets camera class name
  40430. * @returns AnaglyphUniversalCamera
  40431. */
  40432. getClassName(): string;
  40433. }
  40434. }
  40435. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40436. /** @hidden */
  40437. export var stereoscopicInterlacePixelShader: {
  40438. name: string;
  40439. shader: string;
  40440. };
  40441. }
  40442. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40443. import { Camera } from "babylonjs/Cameras/camera";
  40444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40445. import { Engine } from "babylonjs/Engines/engine";
  40446. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40447. /**
  40448. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40449. */
  40450. export class StereoscopicInterlacePostProcess extends PostProcess {
  40451. private _stepSize;
  40452. private _passedProcess;
  40453. /**
  40454. * Initializes a StereoscopicInterlacePostProcess
  40455. * @param name The name of the effect.
  40456. * @param rigCameras The rig cameras to be appled to the post process
  40457. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40459. * @param engine The engine which the post process will be applied. (default: current engine)
  40460. * @param reusable If the post process can be reused on the same frame. (default: false)
  40461. */
  40462. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40463. }
  40464. }
  40465. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40466. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40467. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40468. import { Scene } from "babylonjs/scene";
  40469. import { Vector3 } from "babylonjs/Maths/math.vector";
  40470. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40471. /**
  40472. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40473. * @see http://doc.babylonjs.com/features/cameras
  40474. */
  40475. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40476. /**
  40477. * Creates a new StereoscopicArcRotateCamera
  40478. * @param name defines camera name
  40479. * @param alpha defines alpha angle (in radians)
  40480. * @param beta defines beta angle (in radians)
  40481. * @param radius defines radius
  40482. * @param target defines camera target
  40483. * @param interaxialDistance defines distance between each color axis
  40484. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40485. * @param scene defines the hosting scene
  40486. */
  40487. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40488. /**
  40489. * Gets camera class name
  40490. * @returns StereoscopicArcRotateCamera
  40491. */
  40492. getClassName(): string;
  40493. }
  40494. }
  40495. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40496. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40497. import { Scene } from "babylonjs/scene";
  40498. import { Vector3 } from "babylonjs/Maths/math.vector";
  40499. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40500. /**
  40501. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40502. * @see http://doc.babylonjs.com/features/cameras
  40503. */
  40504. export class StereoscopicFreeCamera extends FreeCamera {
  40505. /**
  40506. * Creates a new StereoscopicFreeCamera
  40507. * @param name defines camera name
  40508. * @param position defines initial position
  40509. * @param interaxialDistance defines distance between each color axis
  40510. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40511. * @param scene defines the hosting scene
  40512. */
  40513. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40514. /**
  40515. * Gets camera class name
  40516. * @returns StereoscopicFreeCamera
  40517. */
  40518. getClassName(): string;
  40519. }
  40520. }
  40521. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40522. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40523. import { Scene } from "babylonjs/scene";
  40524. import { Vector3 } from "babylonjs/Maths/math.vector";
  40525. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40526. /**
  40527. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40528. * @see http://doc.babylonjs.com/features/cameras
  40529. */
  40530. export class StereoscopicGamepadCamera extends GamepadCamera {
  40531. /**
  40532. * Creates a new StereoscopicGamepadCamera
  40533. * @param name defines camera name
  40534. * @param position defines initial position
  40535. * @param interaxialDistance defines distance between each color axis
  40536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40537. * @param scene defines the hosting scene
  40538. */
  40539. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40540. /**
  40541. * Gets camera class name
  40542. * @returns StereoscopicGamepadCamera
  40543. */
  40544. getClassName(): string;
  40545. }
  40546. }
  40547. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40548. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40549. import { Scene } from "babylonjs/scene";
  40550. import { Vector3 } from "babylonjs/Maths/math.vector";
  40551. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40552. /**
  40553. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40554. * @see http://doc.babylonjs.com/features/cameras
  40555. */
  40556. export class StereoscopicUniversalCamera extends UniversalCamera {
  40557. /**
  40558. * Creates a new StereoscopicUniversalCamera
  40559. * @param name defines camera name
  40560. * @param position defines initial position
  40561. * @param interaxialDistance defines distance between each color axis
  40562. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40563. * @param scene defines the hosting scene
  40564. */
  40565. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40566. /**
  40567. * Gets camera class name
  40568. * @returns StereoscopicUniversalCamera
  40569. */
  40570. getClassName(): string;
  40571. }
  40572. }
  40573. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40574. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40575. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40576. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40577. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40578. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40579. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40580. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40581. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40582. }
  40583. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40584. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40585. import { Scene } from "babylonjs/scene";
  40586. import { Vector3 } from "babylonjs/Maths/math.vector";
  40587. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40588. /**
  40589. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40590. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40591. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40592. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40593. */
  40594. export class VirtualJoysticksCamera extends FreeCamera {
  40595. /**
  40596. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40597. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40598. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40599. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40600. * @param name Define the name of the camera in the scene
  40601. * @param position Define the start position of the camera in the scene
  40602. * @param scene Define the scene the camera belongs to
  40603. */
  40604. constructor(name: string, position: Vector3, scene: Scene);
  40605. /**
  40606. * Gets the current object class name.
  40607. * @return the class name
  40608. */
  40609. getClassName(): string;
  40610. }
  40611. }
  40612. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40613. import { Matrix } from "babylonjs/Maths/math.vector";
  40614. /**
  40615. * This represents all the required metrics to create a VR camera.
  40616. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40617. */
  40618. export class VRCameraMetrics {
  40619. /**
  40620. * Define the horizontal resolution off the screen.
  40621. */
  40622. hResolution: number;
  40623. /**
  40624. * Define the vertical resolution off the screen.
  40625. */
  40626. vResolution: number;
  40627. /**
  40628. * Define the horizontal screen size.
  40629. */
  40630. hScreenSize: number;
  40631. /**
  40632. * Define the vertical screen size.
  40633. */
  40634. vScreenSize: number;
  40635. /**
  40636. * Define the vertical screen center position.
  40637. */
  40638. vScreenCenter: number;
  40639. /**
  40640. * Define the distance of the eyes to the screen.
  40641. */
  40642. eyeToScreenDistance: number;
  40643. /**
  40644. * Define the distance between both lenses
  40645. */
  40646. lensSeparationDistance: number;
  40647. /**
  40648. * Define the distance between both viewer's eyes.
  40649. */
  40650. interpupillaryDistance: number;
  40651. /**
  40652. * Define the distortion factor of the VR postprocess.
  40653. * Please, touch with care.
  40654. */
  40655. distortionK: number[];
  40656. /**
  40657. * Define the chromatic aberration correction factors for the VR post process.
  40658. */
  40659. chromaAbCorrection: number[];
  40660. /**
  40661. * Define the scale factor of the post process.
  40662. * The smaller the better but the slower.
  40663. */
  40664. postProcessScaleFactor: number;
  40665. /**
  40666. * Define an offset for the lens center.
  40667. */
  40668. lensCenterOffset: number;
  40669. /**
  40670. * Define if the current vr camera should compensate the distortion of the lense or not.
  40671. */
  40672. compensateDistortion: boolean;
  40673. /**
  40674. * Defines if multiview should be enabled when rendering (Default: false)
  40675. */
  40676. multiviewEnabled: boolean;
  40677. /**
  40678. * Gets the rendering aspect ratio based on the provided resolutions.
  40679. */
  40680. readonly aspectRatio: number;
  40681. /**
  40682. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40683. */
  40684. readonly aspectRatioFov: number;
  40685. /**
  40686. * @hidden
  40687. */
  40688. readonly leftHMatrix: Matrix;
  40689. /**
  40690. * @hidden
  40691. */
  40692. readonly rightHMatrix: Matrix;
  40693. /**
  40694. * @hidden
  40695. */
  40696. readonly leftPreViewMatrix: Matrix;
  40697. /**
  40698. * @hidden
  40699. */
  40700. readonly rightPreViewMatrix: Matrix;
  40701. /**
  40702. * Get the default VRMetrics based on the most generic setup.
  40703. * @returns the default vr metrics
  40704. */
  40705. static GetDefault(): VRCameraMetrics;
  40706. }
  40707. }
  40708. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40709. /** @hidden */
  40710. export var vrDistortionCorrectionPixelShader: {
  40711. name: string;
  40712. shader: string;
  40713. };
  40714. }
  40715. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40716. import { Camera } from "babylonjs/Cameras/camera";
  40717. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40718. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40719. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40720. /**
  40721. * VRDistortionCorrectionPostProcess used for mobile VR
  40722. */
  40723. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40724. private _isRightEye;
  40725. private _distortionFactors;
  40726. private _postProcessScaleFactor;
  40727. private _lensCenterOffset;
  40728. private _scaleIn;
  40729. private _scaleFactor;
  40730. private _lensCenter;
  40731. /**
  40732. * Initializes the VRDistortionCorrectionPostProcess
  40733. * @param name The name of the effect.
  40734. * @param camera The camera to apply the render pass to.
  40735. * @param isRightEye If this is for the right eye distortion
  40736. * @param vrMetrics All the required metrics for the VR camera
  40737. */
  40738. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40739. }
  40740. }
  40741. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40742. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40743. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40744. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40745. import { Scene } from "babylonjs/scene";
  40746. import { Vector3 } from "babylonjs/Maths/math.vector";
  40747. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40748. import "babylonjs/Cameras/RigModes/vrRigMode";
  40749. /**
  40750. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40751. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40752. */
  40753. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40754. /**
  40755. * Creates a new VRDeviceOrientationArcRotateCamera
  40756. * @param name defines camera name
  40757. * @param alpha defines the camera rotation along the logitudinal axis
  40758. * @param beta defines the camera rotation along the latitudinal axis
  40759. * @param radius defines the camera distance from its target
  40760. * @param target defines the camera target
  40761. * @param scene defines the scene the camera belongs to
  40762. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40763. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40764. */
  40765. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40766. /**
  40767. * Gets camera class name
  40768. * @returns VRDeviceOrientationArcRotateCamera
  40769. */
  40770. getClassName(): string;
  40771. }
  40772. }
  40773. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40774. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40775. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40776. import { Scene } from "babylonjs/scene";
  40777. import { Vector3 } from "babylonjs/Maths/math.vector";
  40778. import "babylonjs/Cameras/RigModes/vrRigMode";
  40779. /**
  40780. * Camera used to simulate VR rendering (based on FreeCamera)
  40781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40782. */
  40783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40784. /**
  40785. * Creates a new VRDeviceOrientationFreeCamera
  40786. * @param name defines camera name
  40787. * @param position defines the start position of the camera
  40788. * @param scene defines the scene the camera belongs to
  40789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40791. */
  40792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40793. /**
  40794. * Gets camera class name
  40795. * @returns VRDeviceOrientationFreeCamera
  40796. */
  40797. getClassName(): string;
  40798. }
  40799. }
  40800. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40801. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40802. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40803. import { Scene } from "babylonjs/scene";
  40804. import { Vector3 } from "babylonjs/Maths/math.vector";
  40805. import "babylonjs/Gamepads/gamepadSceneComponent";
  40806. /**
  40807. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40808. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40809. */
  40810. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40811. /**
  40812. * Creates a new VRDeviceOrientationGamepadCamera
  40813. * @param name defines camera name
  40814. * @param position defines the start position of the camera
  40815. * @param scene defines the scene the camera belongs to
  40816. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40817. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40818. */
  40819. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40820. /**
  40821. * Gets camera class name
  40822. * @returns VRDeviceOrientationGamepadCamera
  40823. */
  40824. getClassName(): string;
  40825. }
  40826. }
  40827. declare module "babylonjs/Materials/pushMaterial" {
  40828. import { Nullable } from "babylonjs/types";
  40829. import { Scene } from "babylonjs/scene";
  40830. import { Matrix } from "babylonjs/Maths/math.vector";
  40831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40832. import { Mesh } from "babylonjs/Meshes/mesh";
  40833. import { Material } from "babylonjs/Materials/material";
  40834. import { Effect } from "babylonjs/Materials/effect";
  40835. /**
  40836. * Base class of materials working in push mode in babylon JS
  40837. * @hidden
  40838. */
  40839. export class PushMaterial extends Material {
  40840. protected _activeEffect: Effect;
  40841. protected _normalMatrix: Matrix;
  40842. /**
  40843. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40844. * This means that the material can keep using a previous shader while a new one is being compiled.
  40845. * This is mostly used when shader parallel compilation is supported (true by default)
  40846. */
  40847. allowShaderHotSwapping: boolean;
  40848. constructor(name: string, scene: Scene);
  40849. getEffect(): Effect;
  40850. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40851. /**
  40852. * Binds the given world matrix to the active effect
  40853. *
  40854. * @param world the matrix to bind
  40855. */
  40856. bindOnlyWorldMatrix(world: Matrix): void;
  40857. /**
  40858. * Binds the given normal matrix to the active effect
  40859. *
  40860. * @param normalMatrix the matrix to bind
  40861. */
  40862. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40863. bind(world: Matrix, mesh?: Mesh): void;
  40864. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40865. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40866. }
  40867. }
  40868. declare module "babylonjs/Materials/materialFlags" {
  40869. /**
  40870. * This groups all the flags used to control the materials channel.
  40871. */
  40872. export class MaterialFlags {
  40873. private static _DiffuseTextureEnabled;
  40874. /**
  40875. * Are diffuse textures enabled in the application.
  40876. */
  40877. static DiffuseTextureEnabled: boolean;
  40878. private static _AmbientTextureEnabled;
  40879. /**
  40880. * Are ambient textures enabled in the application.
  40881. */
  40882. static AmbientTextureEnabled: boolean;
  40883. private static _OpacityTextureEnabled;
  40884. /**
  40885. * Are opacity textures enabled in the application.
  40886. */
  40887. static OpacityTextureEnabled: boolean;
  40888. private static _ReflectionTextureEnabled;
  40889. /**
  40890. * Are reflection textures enabled in the application.
  40891. */
  40892. static ReflectionTextureEnabled: boolean;
  40893. private static _EmissiveTextureEnabled;
  40894. /**
  40895. * Are emissive textures enabled in the application.
  40896. */
  40897. static EmissiveTextureEnabled: boolean;
  40898. private static _SpecularTextureEnabled;
  40899. /**
  40900. * Are specular textures enabled in the application.
  40901. */
  40902. static SpecularTextureEnabled: boolean;
  40903. private static _BumpTextureEnabled;
  40904. /**
  40905. * Are bump textures enabled in the application.
  40906. */
  40907. static BumpTextureEnabled: boolean;
  40908. private static _LightmapTextureEnabled;
  40909. /**
  40910. * Are lightmap textures enabled in the application.
  40911. */
  40912. static LightmapTextureEnabled: boolean;
  40913. private static _RefractionTextureEnabled;
  40914. /**
  40915. * Are refraction textures enabled in the application.
  40916. */
  40917. static RefractionTextureEnabled: boolean;
  40918. private static _ColorGradingTextureEnabled;
  40919. /**
  40920. * Are color grading textures enabled in the application.
  40921. */
  40922. static ColorGradingTextureEnabled: boolean;
  40923. private static _FresnelEnabled;
  40924. /**
  40925. * Are fresnels enabled in the application.
  40926. */
  40927. static FresnelEnabled: boolean;
  40928. private static _ClearCoatTextureEnabled;
  40929. /**
  40930. * Are clear coat textures enabled in the application.
  40931. */
  40932. static ClearCoatTextureEnabled: boolean;
  40933. private static _ClearCoatBumpTextureEnabled;
  40934. /**
  40935. * Are clear coat bump textures enabled in the application.
  40936. */
  40937. static ClearCoatBumpTextureEnabled: boolean;
  40938. private static _ClearCoatTintTextureEnabled;
  40939. /**
  40940. * Are clear coat tint textures enabled in the application.
  40941. */
  40942. static ClearCoatTintTextureEnabled: boolean;
  40943. private static _SheenTextureEnabled;
  40944. /**
  40945. * Are sheen textures enabled in the application.
  40946. */
  40947. static SheenTextureEnabled: boolean;
  40948. private static _AnisotropicTextureEnabled;
  40949. /**
  40950. * Are anisotropic textures enabled in the application.
  40951. */
  40952. static AnisotropicTextureEnabled: boolean;
  40953. private static _ThicknessTextureEnabled;
  40954. /**
  40955. * Are thickness textures enabled in the application.
  40956. */
  40957. static ThicknessTextureEnabled: boolean;
  40958. }
  40959. }
  40960. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40961. /** @hidden */
  40962. export var defaultFragmentDeclaration: {
  40963. name: string;
  40964. shader: string;
  40965. };
  40966. }
  40967. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40968. /** @hidden */
  40969. export var defaultUboDeclaration: {
  40970. name: string;
  40971. shader: string;
  40972. };
  40973. }
  40974. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40975. /** @hidden */
  40976. export var lightFragmentDeclaration: {
  40977. name: string;
  40978. shader: string;
  40979. };
  40980. }
  40981. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40982. /** @hidden */
  40983. export var lightUboDeclaration: {
  40984. name: string;
  40985. shader: string;
  40986. };
  40987. }
  40988. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40989. /** @hidden */
  40990. export var lightsFragmentFunctions: {
  40991. name: string;
  40992. shader: string;
  40993. };
  40994. }
  40995. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40996. /** @hidden */
  40997. export var shadowsFragmentFunctions: {
  40998. name: string;
  40999. shader: string;
  41000. };
  41001. }
  41002. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41003. /** @hidden */
  41004. export var fresnelFunction: {
  41005. name: string;
  41006. shader: string;
  41007. };
  41008. }
  41009. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41010. /** @hidden */
  41011. export var reflectionFunction: {
  41012. name: string;
  41013. shader: string;
  41014. };
  41015. }
  41016. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41017. /** @hidden */
  41018. export var bumpFragmentFunctions: {
  41019. name: string;
  41020. shader: string;
  41021. };
  41022. }
  41023. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41024. /** @hidden */
  41025. export var logDepthDeclaration: {
  41026. name: string;
  41027. shader: string;
  41028. };
  41029. }
  41030. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41031. /** @hidden */
  41032. export var bumpFragment: {
  41033. name: string;
  41034. shader: string;
  41035. };
  41036. }
  41037. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41038. /** @hidden */
  41039. export var depthPrePass: {
  41040. name: string;
  41041. shader: string;
  41042. };
  41043. }
  41044. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41045. /** @hidden */
  41046. export var lightFragment: {
  41047. name: string;
  41048. shader: string;
  41049. };
  41050. }
  41051. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41052. /** @hidden */
  41053. export var logDepthFragment: {
  41054. name: string;
  41055. shader: string;
  41056. };
  41057. }
  41058. declare module "babylonjs/Shaders/default.fragment" {
  41059. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41060. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41061. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41062. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41063. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41064. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41065. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41066. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41067. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41068. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41069. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41070. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41071. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41072. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41073. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41075. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41076. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41077. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41078. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41079. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41080. /** @hidden */
  41081. export var defaultPixelShader: {
  41082. name: string;
  41083. shader: string;
  41084. };
  41085. }
  41086. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41087. /** @hidden */
  41088. export var defaultVertexDeclaration: {
  41089. name: string;
  41090. shader: string;
  41091. };
  41092. }
  41093. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41094. /** @hidden */
  41095. export var bumpVertexDeclaration: {
  41096. name: string;
  41097. shader: string;
  41098. };
  41099. }
  41100. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41101. /** @hidden */
  41102. export var bumpVertex: {
  41103. name: string;
  41104. shader: string;
  41105. };
  41106. }
  41107. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41108. /** @hidden */
  41109. export var fogVertex: {
  41110. name: string;
  41111. shader: string;
  41112. };
  41113. }
  41114. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41115. /** @hidden */
  41116. export var shadowsVertex: {
  41117. name: string;
  41118. shader: string;
  41119. };
  41120. }
  41121. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41122. /** @hidden */
  41123. export var pointCloudVertex: {
  41124. name: string;
  41125. shader: string;
  41126. };
  41127. }
  41128. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41129. /** @hidden */
  41130. export var logDepthVertex: {
  41131. name: string;
  41132. shader: string;
  41133. };
  41134. }
  41135. declare module "babylonjs/Shaders/default.vertex" {
  41136. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41137. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41138. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41139. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41140. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41141. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41142. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41144. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41145. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41146. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41147. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41148. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41149. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41150. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41151. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41152. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41153. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41154. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41155. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41156. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41157. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41158. /** @hidden */
  41159. export var defaultVertexShader: {
  41160. name: string;
  41161. shader: string;
  41162. };
  41163. }
  41164. declare module "babylonjs/Materials/standardMaterial" {
  41165. import { SmartArray } from "babylonjs/Misc/smartArray";
  41166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41167. import { Nullable } from "babylonjs/types";
  41168. import { Scene } from "babylonjs/scene";
  41169. import { Matrix } from "babylonjs/Maths/math.vector";
  41170. import { Color3 } from "babylonjs/Maths/math.color";
  41171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41173. import { Mesh } from "babylonjs/Meshes/mesh";
  41174. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41175. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41176. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41177. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41178. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41181. import "babylonjs/Shaders/default.fragment";
  41182. import "babylonjs/Shaders/default.vertex";
  41183. /** @hidden */
  41184. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41185. MAINUV1: boolean;
  41186. MAINUV2: boolean;
  41187. DIFFUSE: boolean;
  41188. DIFFUSEDIRECTUV: number;
  41189. AMBIENT: boolean;
  41190. AMBIENTDIRECTUV: number;
  41191. OPACITY: boolean;
  41192. OPACITYDIRECTUV: number;
  41193. OPACITYRGB: boolean;
  41194. REFLECTION: boolean;
  41195. EMISSIVE: boolean;
  41196. EMISSIVEDIRECTUV: number;
  41197. SPECULAR: boolean;
  41198. SPECULARDIRECTUV: number;
  41199. BUMP: boolean;
  41200. BUMPDIRECTUV: number;
  41201. PARALLAX: boolean;
  41202. PARALLAXOCCLUSION: boolean;
  41203. SPECULAROVERALPHA: boolean;
  41204. CLIPPLANE: boolean;
  41205. CLIPPLANE2: boolean;
  41206. CLIPPLANE3: boolean;
  41207. CLIPPLANE4: boolean;
  41208. ALPHATEST: boolean;
  41209. DEPTHPREPASS: boolean;
  41210. ALPHAFROMDIFFUSE: boolean;
  41211. POINTSIZE: boolean;
  41212. FOG: boolean;
  41213. SPECULARTERM: boolean;
  41214. DIFFUSEFRESNEL: boolean;
  41215. OPACITYFRESNEL: boolean;
  41216. REFLECTIONFRESNEL: boolean;
  41217. REFRACTIONFRESNEL: boolean;
  41218. EMISSIVEFRESNEL: boolean;
  41219. FRESNEL: boolean;
  41220. NORMAL: boolean;
  41221. UV1: boolean;
  41222. UV2: boolean;
  41223. VERTEXCOLOR: boolean;
  41224. VERTEXALPHA: boolean;
  41225. NUM_BONE_INFLUENCERS: number;
  41226. BonesPerMesh: number;
  41227. BONETEXTURE: boolean;
  41228. INSTANCES: boolean;
  41229. GLOSSINESS: boolean;
  41230. ROUGHNESS: boolean;
  41231. EMISSIVEASILLUMINATION: boolean;
  41232. LINKEMISSIVEWITHDIFFUSE: boolean;
  41233. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41234. LIGHTMAP: boolean;
  41235. LIGHTMAPDIRECTUV: number;
  41236. OBJECTSPACE_NORMALMAP: boolean;
  41237. USELIGHTMAPASSHADOWMAP: boolean;
  41238. REFLECTIONMAP_3D: boolean;
  41239. REFLECTIONMAP_SPHERICAL: boolean;
  41240. REFLECTIONMAP_PLANAR: boolean;
  41241. REFLECTIONMAP_CUBIC: boolean;
  41242. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41243. REFLECTIONMAP_PROJECTION: boolean;
  41244. REFLECTIONMAP_SKYBOX: boolean;
  41245. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41246. REFLECTIONMAP_EXPLICIT: boolean;
  41247. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41248. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41249. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41250. INVERTCUBICMAP: boolean;
  41251. LOGARITHMICDEPTH: boolean;
  41252. REFRACTION: boolean;
  41253. REFRACTIONMAP_3D: boolean;
  41254. REFLECTIONOVERALPHA: boolean;
  41255. TWOSIDEDLIGHTING: boolean;
  41256. SHADOWFLOAT: boolean;
  41257. MORPHTARGETS: boolean;
  41258. MORPHTARGETS_NORMAL: boolean;
  41259. MORPHTARGETS_TANGENT: boolean;
  41260. MORPHTARGETS_UV: boolean;
  41261. NUM_MORPH_INFLUENCERS: number;
  41262. NONUNIFORMSCALING: boolean;
  41263. PREMULTIPLYALPHA: boolean;
  41264. IMAGEPROCESSING: boolean;
  41265. VIGNETTE: boolean;
  41266. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41267. VIGNETTEBLENDMODEOPAQUE: boolean;
  41268. TONEMAPPING: boolean;
  41269. TONEMAPPING_ACES: boolean;
  41270. CONTRAST: boolean;
  41271. COLORCURVES: boolean;
  41272. COLORGRADING: boolean;
  41273. COLORGRADING3D: boolean;
  41274. SAMPLER3DGREENDEPTH: boolean;
  41275. SAMPLER3DBGRMAP: boolean;
  41276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41277. MULTIVIEW: boolean;
  41278. /**
  41279. * If the reflection texture on this material is in linear color space
  41280. * @hidden
  41281. */
  41282. IS_REFLECTION_LINEAR: boolean;
  41283. /**
  41284. * If the refraction texture on this material is in linear color space
  41285. * @hidden
  41286. */
  41287. IS_REFRACTION_LINEAR: boolean;
  41288. EXPOSURE: boolean;
  41289. constructor();
  41290. setReflectionMode(modeToEnable: string): void;
  41291. }
  41292. /**
  41293. * This is the default material used in Babylon. It is the best trade off between quality
  41294. * and performances.
  41295. * @see http://doc.babylonjs.com/babylon101/materials
  41296. */
  41297. export class StandardMaterial extends PushMaterial {
  41298. private _diffuseTexture;
  41299. /**
  41300. * The basic texture of the material as viewed under a light.
  41301. */
  41302. diffuseTexture: Nullable<BaseTexture>;
  41303. private _ambientTexture;
  41304. /**
  41305. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41306. */
  41307. ambientTexture: Nullable<BaseTexture>;
  41308. private _opacityTexture;
  41309. /**
  41310. * Define the transparency of the material from a texture.
  41311. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41312. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41313. */
  41314. opacityTexture: Nullable<BaseTexture>;
  41315. private _reflectionTexture;
  41316. /**
  41317. * Define the texture used to display the reflection.
  41318. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41319. */
  41320. reflectionTexture: Nullable<BaseTexture>;
  41321. private _emissiveTexture;
  41322. /**
  41323. * Define texture of the material as if self lit.
  41324. * This will be mixed in the final result even in the absence of light.
  41325. */
  41326. emissiveTexture: Nullable<BaseTexture>;
  41327. private _specularTexture;
  41328. /**
  41329. * Define how the color and intensity of the highlight given by the light in the material.
  41330. */
  41331. specularTexture: Nullable<BaseTexture>;
  41332. private _bumpTexture;
  41333. /**
  41334. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41335. * 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.
  41336. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41337. */
  41338. bumpTexture: Nullable<BaseTexture>;
  41339. private _lightmapTexture;
  41340. /**
  41341. * Complex lighting can be computationally expensive to compute at runtime.
  41342. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41343. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41344. */
  41345. lightmapTexture: Nullable<BaseTexture>;
  41346. private _refractionTexture;
  41347. /**
  41348. * Define the texture used to display the refraction.
  41349. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41350. */
  41351. refractionTexture: Nullable<BaseTexture>;
  41352. /**
  41353. * The color of the material lit by the environmental background lighting.
  41354. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41355. */
  41356. ambientColor: Color3;
  41357. /**
  41358. * The basic color of the material as viewed under a light.
  41359. */
  41360. diffuseColor: Color3;
  41361. /**
  41362. * Define how the color and intensity of the highlight given by the light in the material.
  41363. */
  41364. specularColor: Color3;
  41365. /**
  41366. * Define the color of the material as if self lit.
  41367. * This will be mixed in the final result even in the absence of light.
  41368. */
  41369. emissiveColor: Color3;
  41370. /**
  41371. * Defines how sharp are the highlights in the material.
  41372. * The bigger the value the sharper giving a more glossy feeling to the result.
  41373. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41374. */
  41375. specularPower: number;
  41376. private _useAlphaFromDiffuseTexture;
  41377. /**
  41378. * Does the transparency come from the diffuse texture alpha channel.
  41379. */
  41380. useAlphaFromDiffuseTexture: boolean;
  41381. private _useEmissiveAsIllumination;
  41382. /**
  41383. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41384. */
  41385. useEmissiveAsIllumination: boolean;
  41386. private _linkEmissiveWithDiffuse;
  41387. /**
  41388. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41389. * the emissive level when the final color is close to one.
  41390. */
  41391. linkEmissiveWithDiffuse: boolean;
  41392. private _useSpecularOverAlpha;
  41393. /**
  41394. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41395. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41396. */
  41397. useSpecularOverAlpha: boolean;
  41398. private _useReflectionOverAlpha;
  41399. /**
  41400. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41401. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41402. */
  41403. useReflectionOverAlpha: boolean;
  41404. private _disableLighting;
  41405. /**
  41406. * Does lights from the scene impacts this material.
  41407. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41408. */
  41409. disableLighting: boolean;
  41410. private _useObjectSpaceNormalMap;
  41411. /**
  41412. * Allows using an object space normal map (instead of tangent space).
  41413. */
  41414. useObjectSpaceNormalMap: boolean;
  41415. private _useParallax;
  41416. /**
  41417. * Is parallax enabled or not.
  41418. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41419. */
  41420. useParallax: boolean;
  41421. private _useParallaxOcclusion;
  41422. /**
  41423. * Is parallax occlusion enabled or not.
  41424. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41425. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41426. */
  41427. useParallaxOcclusion: boolean;
  41428. /**
  41429. * 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.
  41430. */
  41431. parallaxScaleBias: number;
  41432. private _roughness;
  41433. /**
  41434. * Helps to define how blurry the reflections should appears in the material.
  41435. */
  41436. roughness: number;
  41437. /**
  41438. * In case of refraction, define the value of the index of refraction.
  41439. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41440. */
  41441. indexOfRefraction: number;
  41442. /**
  41443. * Invert the refraction texture alongside the y axis.
  41444. * It can be useful with procedural textures or probe for instance.
  41445. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41446. */
  41447. invertRefractionY: boolean;
  41448. /**
  41449. * Defines the alpha limits in alpha test mode.
  41450. */
  41451. alphaCutOff: number;
  41452. private _useLightmapAsShadowmap;
  41453. /**
  41454. * In case of light mapping, define whether the map contains light or shadow informations.
  41455. */
  41456. useLightmapAsShadowmap: boolean;
  41457. private _diffuseFresnelParameters;
  41458. /**
  41459. * Define the diffuse fresnel parameters of the material.
  41460. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41461. */
  41462. diffuseFresnelParameters: FresnelParameters;
  41463. private _opacityFresnelParameters;
  41464. /**
  41465. * Define the opacity fresnel parameters of the material.
  41466. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41467. */
  41468. opacityFresnelParameters: FresnelParameters;
  41469. private _reflectionFresnelParameters;
  41470. /**
  41471. * Define the reflection fresnel parameters of the material.
  41472. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41473. */
  41474. reflectionFresnelParameters: FresnelParameters;
  41475. private _refractionFresnelParameters;
  41476. /**
  41477. * Define the refraction fresnel parameters of the material.
  41478. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41479. */
  41480. refractionFresnelParameters: FresnelParameters;
  41481. private _emissiveFresnelParameters;
  41482. /**
  41483. * Define the emissive fresnel parameters of the material.
  41484. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41485. */
  41486. emissiveFresnelParameters: FresnelParameters;
  41487. private _useReflectionFresnelFromSpecular;
  41488. /**
  41489. * If true automatically deducts the fresnels values from the material specularity.
  41490. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41491. */
  41492. useReflectionFresnelFromSpecular: boolean;
  41493. private _useGlossinessFromSpecularMapAlpha;
  41494. /**
  41495. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41496. */
  41497. useGlossinessFromSpecularMapAlpha: boolean;
  41498. private _maxSimultaneousLights;
  41499. /**
  41500. * Defines the maximum number of lights that can be used in the material
  41501. */
  41502. maxSimultaneousLights: number;
  41503. private _invertNormalMapX;
  41504. /**
  41505. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41506. */
  41507. invertNormalMapX: boolean;
  41508. private _invertNormalMapY;
  41509. /**
  41510. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41511. */
  41512. invertNormalMapY: boolean;
  41513. private _twoSidedLighting;
  41514. /**
  41515. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41516. */
  41517. twoSidedLighting: boolean;
  41518. /**
  41519. * Default configuration related to image processing available in the standard Material.
  41520. */
  41521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41522. /**
  41523. * Gets the image processing configuration used either in this material.
  41524. */
  41525. /**
  41526. * Sets the Default image processing configuration used either in the this material.
  41527. *
  41528. * If sets to null, the scene one is in use.
  41529. */
  41530. imageProcessingConfiguration: ImageProcessingConfiguration;
  41531. /**
  41532. * Keep track of the image processing observer to allow dispose and replace.
  41533. */
  41534. private _imageProcessingObserver;
  41535. /**
  41536. * Attaches a new image processing configuration to the Standard Material.
  41537. * @param configuration
  41538. */
  41539. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41540. /**
  41541. * Gets wether the color curves effect is enabled.
  41542. */
  41543. /**
  41544. * Sets wether the color curves effect is enabled.
  41545. */
  41546. cameraColorCurvesEnabled: boolean;
  41547. /**
  41548. * Gets wether the color grading effect is enabled.
  41549. */
  41550. /**
  41551. * Gets wether the color grading effect is enabled.
  41552. */
  41553. cameraColorGradingEnabled: boolean;
  41554. /**
  41555. * Gets wether tonemapping is enabled or not.
  41556. */
  41557. /**
  41558. * Sets wether tonemapping is enabled or not
  41559. */
  41560. cameraToneMappingEnabled: boolean;
  41561. /**
  41562. * The camera exposure used on this material.
  41563. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41564. * This corresponds to a photographic exposure.
  41565. */
  41566. /**
  41567. * The camera exposure used on this material.
  41568. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41569. * This corresponds to a photographic exposure.
  41570. */
  41571. cameraExposure: number;
  41572. /**
  41573. * Gets The camera contrast used on this material.
  41574. */
  41575. /**
  41576. * Sets The camera contrast used on this material.
  41577. */
  41578. cameraContrast: number;
  41579. /**
  41580. * Gets the Color Grading 2D Lookup Texture.
  41581. */
  41582. /**
  41583. * Sets the Color Grading 2D Lookup Texture.
  41584. */
  41585. cameraColorGradingTexture: Nullable<BaseTexture>;
  41586. /**
  41587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41589. * 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;
  41590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41591. */
  41592. /**
  41593. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41594. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41595. * 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;
  41596. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41597. */
  41598. cameraColorCurves: Nullable<ColorCurves>;
  41599. /**
  41600. * Custom callback helping to override the default shader used in the material.
  41601. */
  41602. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41603. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41604. protected _worldViewProjectionMatrix: Matrix;
  41605. protected _globalAmbientColor: Color3;
  41606. protected _useLogarithmicDepth: boolean;
  41607. protected _rebuildInParallel: boolean;
  41608. /**
  41609. * Instantiates a new standard material.
  41610. * This is the default material used in Babylon. It is the best trade off between quality
  41611. * and performances.
  41612. * @see http://doc.babylonjs.com/babylon101/materials
  41613. * @param name Define the name of the material in the scene
  41614. * @param scene Define the scene the material belong to
  41615. */
  41616. constructor(name: string, scene: Scene);
  41617. /**
  41618. * Gets a boolean indicating that current material needs to register RTT
  41619. */
  41620. readonly hasRenderTargetTextures: boolean;
  41621. /**
  41622. * Gets the current class name of the material e.g. "StandardMaterial"
  41623. * Mainly use in serialization.
  41624. * @returns the class name
  41625. */
  41626. getClassName(): string;
  41627. /**
  41628. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41629. * You can try switching to logarithmic depth.
  41630. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41631. */
  41632. useLogarithmicDepth: boolean;
  41633. /**
  41634. * Specifies if the material will require alpha blending
  41635. * @returns a boolean specifying if alpha blending is needed
  41636. */
  41637. needAlphaBlending(): boolean;
  41638. /**
  41639. * Specifies if this material should be rendered in alpha test mode
  41640. * @returns a boolean specifying if an alpha test is needed.
  41641. */
  41642. needAlphaTesting(): boolean;
  41643. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41644. /**
  41645. * Get the texture used for alpha test purpose.
  41646. * @returns the diffuse texture in case of the standard material.
  41647. */
  41648. getAlphaTestTexture(): Nullable<BaseTexture>;
  41649. /**
  41650. * Get if the submesh is ready to be used and all its information available.
  41651. * Child classes can use it to update shaders
  41652. * @param mesh defines the mesh to check
  41653. * @param subMesh defines which submesh to check
  41654. * @param useInstances specifies that instances should be used
  41655. * @returns a boolean indicating that the submesh is ready or not
  41656. */
  41657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41658. /**
  41659. * Builds the material UBO layouts.
  41660. * Used internally during the effect preparation.
  41661. */
  41662. buildUniformLayout(): void;
  41663. /**
  41664. * Unbinds the material from the mesh
  41665. */
  41666. unbind(): void;
  41667. /**
  41668. * Binds the submesh to this material by preparing the effect and shader to draw
  41669. * @param world defines the world transformation matrix
  41670. * @param mesh defines the mesh containing the submesh
  41671. * @param subMesh defines the submesh to bind the material to
  41672. */
  41673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41674. /**
  41675. * Get the list of animatables in the material.
  41676. * @returns the list of animatables object used in the material
  41677. */
  41678. getAnimatables(): IAnimatable[];
  41679. /**
  41680. * Gets the active textures from the material
  41681. * @returns an array of textures
  41682. */
  41683. getActiveTextures(): BaseTexture[];
  41684. /**
  41685. * Specifies if the material uses a texture
  41686. * @param texture defines the texture to check against the material
  41687. * @returns a boolean specifying if the material uses the texture
  41688. */
  41689. hasTexture(texture: BaseTexture): boolean;
  41690. /**
  41691. * Disposes the material
  41692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41694. */
  41695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41696. /**
  41697. * Makes a duplicate of the material, and gives it a new name
  41698. * @param name defines the new name for the duplicated material
  41699. * @returns the cloned material
  41700. */
  41701. clone(name: string): StandardMaterial;
  41702. /**
  41703. * Serializes this material in a JSON representation
  41704. * @returns the serialized material object
  41705. */
  41706. serialize(): any;
  41707. /**
  41708. * Creates a standard material from parsed material data
  41709. * @param source defines the JSON representation of the material
  41710. * @param scene defines the hosting scene
  41711. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41712. * @returns a new standard material
  41713. */
  41714. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41715. /**
  41716. * Are diffuse textures enabled in the application.
  41717. */
  41718. static DiffuseTextureEnabled: boolean;
  41719. /**
  41720. * Are ambient textures enabled in the application.
  41721. */
  41722. static AmbientTextureEnabled: boolean;
  41723. /**
  41724. * Are opacity textures enabled in the application.
  41725. */
  41726. static OpacityTextureEnabled: boolean;
  41727. /**
  41728. * Are reflection textures enabled in the application.
  41729. */
  41730. static ReflectionTextureEnabled: boolean;
  41731. /**
  41732. * Are emissive textures enabled in the application.
  41733. */
  41734. static EmissiveTextureEnabled: boolean;
  41735. /**
  41736. * Are specular textures enabled in the application.
  41737. */
  41738. static SpecularTextureEnabled: boolean;
  41739. /**
  41740. * Are bump textures enabled in the application.
  41741. */
  41742. static BumpTextureEnabled: boolean;
  41743. /**
  41744. * Are lightmap textures enabled in the application.
  41745. */
  41746. static LightmapTextureEnabled: boolean;
  41747. /**
  41748. * Are refraction textures enabled in the application.
  41749. */
  41750. static RefractionTextureEnabled: boolean;
  41751. /**
  41752. * Are color grading textures enabled in the application.
  41753. */
  41754. static ColorGradingTextureEnabled: boolean;
  41755. /**
  41756. * Are fresnels enabled in the application.
  41757. */
  41758. static FresnelEnabled: boolean;
  41759. }
  41760. }
  41761. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41762. import { Scene } from "babylonjs/scene";
  41763. import { Texture } from "babylonjs/Materials/Textures/texture";
  41764. /**
  41765. * A class extending Texture allowing drawing on a texture
  41766. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41767. */
  41768. export class DynamicTexture extends Texture {
  41769. private _generateMipMaps;
  41770. private _canvas;
  41771. private _context;
  41772. private _engine;
  41773. /**
  41774. * Creates a DynamicTexture
  41775. * @param name defines the name of the texture
  41776. * @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
  41777. * @param scene defines the scene where you want the texture
  41778. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41779. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41780. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41781. */
  41782. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41783. /**
  41784. * Get the current class name of the texture useful for serialization or dynamic coding.
  41785. * @returns "DynamicTexture"
  41786. */
  41787. getClassName(): string;
  41788. /**
  41789. * Gets the current state of canRescale
  41790. */
  41791. readonly canRescale: boolean;
  41792. private _recreate;
  41793. /**
  41794. * Scales the texture
  41795. * @param ratio the scale factor to apply to both width and height
  41796. */
  41797. scale(ratio: number): void;
  41798. /**
  41799. * Resizes the texture
  41800. * @param width the new width
  41801. * @param height the new height
  41802. */
  41803. scaleTo(width: number, height: number): void;
  41804. /**
  41805. * Gets the context of the canvas used by the texture
  41806. * @returns the canvas context of the dynamic texture
  41807. */
  41808. getContext(): CanvasRenderingContext2D;
  41809. /**
  41810. * Clears the texture
  41811. */
  41812. clear(): void;
  41813. /**
  41814. * Updates the texture
  41815. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41816. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41817. */
  41818. update(invertY?: boolean, premulAlpha?: boolean): void;
  41819. /**
  41820. * Draws text onto the texture
  41821. * @param text defines the text to be drawn
  41822. * @param x defines the placement of the text from the left
  41823. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41824. * @param font defines the font to be used with font-style, font-size, font-name
  41825. * @param color defines the color used for the text
  41826. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41827. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41828. * @param update defines whether texture is immediately update (default is true)
  41829. */
  41830. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41831. /**
  41832. * Clones the texture
  41833. * @returns the clone of the texture.
  41834. */
  41835. clone(): DynamicTexture;
  41836. /**
  41837. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41838. * @returns a serialized dynamic texture object
  41839. */
  41840. serialize(): any;
  41841. /** @hidden */
  41842. _rebuild(): void;
  41843. }
  41844. }
  41845. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41846. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41848. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41849. /** @hidden */
  41850. export var imageProcessingPixelShader: {
  41851. name: string;
  41852. shader: string;
  41853. };
  41854. }
  41855. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41856. import { Nullable } from "babylonjs/types";
  41857. import { Color4 } from "babylonjs/Maths/math.color";
  41858. import { Camera } from "babylonjs/Cameras/camera";
  41859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41861. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41863. import { Engine } from "babylonjs/Engines/engine";
  41864. import "babylonjs/Shaders/imageProcessing.fragment";
  41865. import "babylonjs/Shaders/postprocess.vertex";
  41866. /**
  41867. * ImageProcessingPostProcess
  41868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41869. */
  41870. export class ImageProcessingPostProcess extends PostProcess {
  41871. /**
  41872. * Default configuration related to image processing available in the PBR Material.
  41873. */
  41874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41875. /**
  41876. * Gets the image processing configuration used either in this material.
  41877. */
  41878. /**
  41879. * Sets the Default image processing configuration used either in the this material.
  41880. *
  41881. * If sets to null, the scene one is in use.
  41882. */
  41883. imageProcessingConfiguration: ImageProcessingConfiguration;
  41884. /**
  41885. * Keep track of the image processing observer to allow dispose and replace.
  41886. */
  41887. private _imageProcessingObserver;
  41888. /**
  41889. * Attaches a new image processing configuration to the PBR Material.
  41890. * @param configuration
  41891. */
  41892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41893. /**
  41894. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41895. */
  41896. /**
  41897. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41898. */
  41899. colorCurves: Nullable<ColorCurves>;
  41900. /**
  41901. * Gets wether the color curves effect is enabled.
  41902. */
  41903. /**
  41904. * Sets wether the color curves effect is enabled.
  41905. */
  41906. colorCurvesEnabled: boolean;
  41907. /**
  41908. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41909. */
  41910. /**
  41911. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41912. */
  41913. colorGradingTexture: Nullable<BaseTexture>;
  41914. /**
  41915. * Gets wether the color grading effect is enabled.
  41916. */
  41917. /**
  41918. * Gets wether the color grading effect is enabled.
  41919. */
  41920. colorGradingEnabled: boolean;
  41921. /**
  41922. * Gets exposure used in the effect.
  41923. */
  41924. /**
  41925. * Sets exposure used in the effect.
  41926. */
  41927. exposure: number;
  41928. /**
  41929. * Gets wether tonemapping is enabled or not.
  41930. */
  41931. /**
  41932. * Sets wether tonemapping is enabled or not
  41933. */
  41934. toneMappingEnabled: boolean;
  41935. /**
  41936. * Gets the type of tone mapping effect.
  41937. */
  41938. /**
  41939. * Sets the type of tone mapping effect.
  41940. */
  41941. toneMappingType: number;
  41942. /**
  41943. * Gets contrast used in the effect.
  41944. */
  41945. /**
  41946. * Sets contrast used in the effect.
  41947. */
  41948. contrast: number;
  41949. /**
  41950. * Gets Vignette stretch size.
  41951. */
  41952. /**
  41953. * Sets Vignette stretch size.
  41954. */
  41955. vignetteStretch: number;
  41956. /**
  41957. * Gets Vignette centre X Offset.
  41958. */
  41959. /**
  41960. * Sets Vignette centre X Offset.
  41961. */
  41962. vignetteCentreX: number;
  41963. /**
  41964. * Gets Vignette centre Y Offset.
  41965. */
  41966. /**
  41967. * Sets Vignette centre Y Offset.
  41968. */
  41969. vignetteCentreY: number;
  41970. /**
  41971. * Gets Vignette weight or intensity of the vignette effect.
  41972. */
  41973. /**
  41974. * Sets Vignette weight or intensity of the vignette effect.
  41975. */
  41976. vignetteWeight: number;
  41977. /**
  41978. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41979. * if vignetteEnabled is set to true.
  41980. */
  41981. /**
  41982. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41983. * if vignetteEnabled is set to true.
  41984. */
  41985. vignetteColor: Color4;
  41986. /**
  41987. * Gets Camera field of view used by the Vignette effect.
  41988. */
  41989. /**
  41990. * Sets Camera field of view used by the Vignette effect.
  41991. */
  41992. vignetteCameraFov: number;
  41993. /**
  41994. * Gets the vignette blend mode allowing different kind of effect.
  41995. */
  41996. /**
  41997. * Sets the vignette blend mode allowing different kind of effect.
  41998. */
  41999. vignetteBlendMode: number;
  42000. /**
  42001. * Gets wether the vignette effect is enabled.
  42002. */
  42003. /**
  42004. * Sets wether the vignette effect is enabled.
  42005. */
  42006. vignetteEnabled: boolean;
  42007. private _fromLinearSpace;
  42008. /**
  42009. * Gets wether the input of the processing is in Gamma or Linear Space.
  42010. */
  42011. /**
  42012. * Sets wether the input of the processing is in Gamma or Linear Space.
  42013. */
  42014. fromLinearSpace: boolean;
  42015. /**
  42016. * Defines cache preventing GC.
  42017. */
  42018. private _defines;
  42019. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42020. /**
  42021. * "ImageProcessingPostProcess"
  42022. * @returns "ImageProcessingPostProcess"
  42023. */
  42024. getClassName(): string;
  42025. protected _updateParameters(): void;
  42026. dispose(camera?: Camera): void;
  42027. }
  42028. }
  42029. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42030. import { Scene } from "babylonjs/scene";
  42031. import { Color3 } from "babylonjs/Maths/math.color";
  42032. import { Mesh } from "babylonjs/Meshes/mesh";
  42033. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42034. import { Nullable } from "babylonjs/types";
  42035. /**
  42036. * Class containing static functions to help procedurally build meshes
  42037. */
  42038. export class GroundBuilder {
  42039. /**
  42040. * Creates a ground mesh
  42041. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42042. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42044. * @param name defines the name of the mesh
  42045. * @param options defines the options used to create the mesh
  42046. * @param scene defines the hosting scene
  42047. * @returns the ground mesh
  42048. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42049. */
  42050. static CreateGround(name: string, options: {
  42051. width?: number;
  42052. height?: number;
  42053. subdivisions?: number;
  42054. subdivisionsX?: number;
  42055. subdivisionsY?: number;
  42056. updatable?: boolean;
  42057. }, scene: any): Mesh;
  42058. /**
  42059. * Creates a tiled ground mesh
  42060. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42061. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42062. * * 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
  42063. * * 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
  42064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42065. * @param name defines the name of the mesh
  42066. * @param options defines the options used to create the mesh
  42067. * @param scene defines the hosting scene
  42068. * @returns the tiled ground mesh
  42069. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42070. */
  42071. static CreateTiledGround(name: string, options: {
  42072. xmin: number;
  42073. zmin: number;
  42074. xmax: number;
  42075. zmax: number;
  42076. subdivisions?: {
  42077. w: number;
  42078. h: number;
  42079. };
  42080. precision?: {
  42081. w: number;
  42082. h: number;
  42083. };
  42084. updatable?: boolean;
  42085. }, scene?: Nullable<Scene>): Mesh;
  42086. /**
  42087. * Creates a ground mesh from a height map
  42088. * * The parameter `url` sets the URL of the height map image resource.
  42089. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42090. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42091. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42092. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42093. * * 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.
  42094. * * 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).
  42095. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42097. * @param name defines the name of the mesh
  42098. * @param url defines the url to the height map
  42099. * @param options defines the options used to create the mesh
  42100. * @param scene defines the hosting scene
  42101. * @returns the ground mesh
  42102. * @see https://doc.babylonjs.com/babylon101/height_map
  42103. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42104. */
  42105. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42106. width?: number;
  42107. height?: number;
  42108. subdivisions?: number;
  42109. minHeight?: number;
  42110. maxHeight?: number;
  42111. colorFilter?: Color3;
  42112. alphaFilter?: number;
  42113. updatable?: boolean;
  42114. onReady?: (mesh: GroundMesh) => void;
  42115. }, scene?: Nullable<Scene>): GroundMesh;
  42116. }
  42117. }
  42118. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42119. import { Vector4 } from "babylonjs/Maths/math.vector";
  42120. import { Mesh } from "babylonjs/Meshes/mesh";
  42121. /**
  42122. * Class containing static functions to help procedurally build meshes
  42123. */
  42124. export class TorusBuilder {
  42125. /**
  42126. * Creates a torus mesh
  42127. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42128. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42129. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42133. * @param name defines the name of the mesh
  42134. * @param options defines the options used to create the mesh
  42135. * @param scene defines the hosting scene
  42136. * @returns the torus mesh
  42137. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42138. */
  42139. static CreateTorus(name: string, options: {
  42140. diameter?: number;
  42141. thickness?: number;
  42142. tessellation?: number;
  42143. updatable?: boolean;
  42144. sideOrientation?: number;
  42145. frontUVs?: Vector4;
  42146. backUVs?: Vector4;
  42147. }, scene: any): Mesh;
  42148. }
  42149. }
  42150. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42151. import { Vector4 } from "babylonjs/Maths/math.vector";
  42152. import { Color4 } from "babylonjs/Maths/math.color";
  42153. import { Mesh } from "babylonjs/Meshes/mesh";
  42154. /**
  42155. * Class containing static functions to help procedurally build meshes
  42156. */
  42157. export class CylinderBuilder {
  42158. /**
  42159. * Creates a cylinder or a cone mesh
  42160. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42161. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42162. * * 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.
  42163. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42164. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42165. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42166. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42167. * * 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).
  42168. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42169. * * 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).
  42170. * * 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
  42171. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42172. * * 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
  42173. * * 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.
  42174. * * If `enclose` is false, a ring surface is one element.
  42175. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42176. * * 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
  42177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42180. * @param name defines the name of the mesh
  42181. * @param options defines the options used to create the mesh
  42182. * @param scene defines the hosting scene
  42183. * @returns the cylinder mesh
  42184. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42185. */
  42186. static CreateCylinder(name: string, options: {
  42187. height?: number;
  42188. diameterTop?: number;
  42189. diameterBottom?: number;
  42190. diameter?: number;
  42191. tessellation?: number;
  42192. subdivisions?: number;
  42193. arc?: number;
  42194. faceColors?: Color4[];
  42195. faceUV?: Vector4[];
  42196. updatable?: boolean;
  42197. hasRings?: boolean;
  42198. enclose?: boolean;
  42199. cap?: number;
  42200. sideOrientation?: number;
  42201. frontUVs?: Vector4;
  42202. backUVs?: Vector4;
  42203. }, scene: any): Mesh;
  42204. }
  42205. }
  42206. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42207. import { Observable } from "babylonjs/Misc/observable";
  42208. import { Nullable } from "babylonjs/types";
  42209. import { Camera } from "babylonjs/Cameras/camera";
  42210. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42211. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42212. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42213. import { Scene } from "babylonjs/scene";
  42214. import { Vector3 } from "babylonjs/Maths/math.vector";
  42215. import { Color3 } from "babylonjs/Maths/math.color";
  42216. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42218. import { Mesh } from "babylonjs/Meshes/mesh";
  42219. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42220. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42221. import "babylonjs/Meshes/Builders/groundBuilder";
  42222. import "babylonjs/Meshes/Builders/torusBuilder";
  42223. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42224. import "babylonjs/Gamepads/gamepadSceneComponent";
  42225. import "babylonjs/Animations/animatable";
  42226. /**
  42227. * Options to modify the vr teleportation behavior.
  42228. */
  42229. export interface VRTeleportationOptions {
  42230. /**
  42231. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42232. */
  42233. floorMeshName?: string;
  42234. /**
  42235. * A list of meshes to be used as the teleportation floor. (default: empty)
  42236. */
  42237. floorMeshes?: Mesh[];
  42238. }
  42239. /**
  42240. * Options to modify the vr experience helper's behavior.
  42241. */
  42242. export interface VRExperienceHelperOptions extends WebVROptions {
  42243. /**
  42244. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42245. */
  42246. createDeviceOrientationCamera?: boolean;
  42247. /**
  42248. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42249. */
  42250. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42251. /**
  42252. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42253. */
  42254. laserToggle?: boolean;
  42255. /**
  42256. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42257. */
  42258. floorMeshes?: Mesh[];
  42259. /**
  42260. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42261. */
  42262. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42263. }
  42264. /**
  42265. * Event containing information after VR has been entered
  42266. */
  42267. export class OnAfterEnteringVRObservableEvent {
  42268. /**
  42269. * If entering vr was successful
  42270. */
  42271. success: boolean;
  42272. }
  42273. /**
  42274. * Helps to quickly add VR support to an existing scene.
  42275. * See http://doc.babylonjs.com/how_to/webvr_helper
  42276. */
  42277. export class VRExperienceHelper {
  42278. /** Options to modify the vr experience helper's behavior. */
  42279. webVROptions: VRExperienceHelperOptions;
  42280. private _scene;
  42281. private _position;
  42282. private _btnVR;
  42283. private _btnVRDisplayed;
  42284. private _webVRsupported;
  42285. private _webVRready;
  42286. private _webVRrequesting;
  42287. private _webVRpresenting;
  42288. private _hasEnteredVR;
  42289. private _fullscreenVRpresenting;
  42290. private _canvas;
  42291. private _webVRCamera;
  42292. private _vrDeviceOrientationCamera;
  42293. private _deviceOrientationCamera;
  42294. private _existingCamera;
  42295. private _onKeyDown;
  42296. private _onVrDisplayPresentChange;
  42297. private _onVRDisplayChanged;
  42298. private _onVRRequestPresentStart;
  42299. private _onVRRequestPresentComplete;
  42300. /**
  42301. * 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)
  42302. */
  42303. enableGazeEvenWhenNoPointerLock: boolean;
  42304. /**
  42305. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42306. */
  42307. exitVROnDoubleTap: boolean;
  42308. /**
  42309. * Observable raised right before entering VR.
  42310. */
  42311. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42312. /**
  42313. * Observable raised when entering VR has completed.
  42314. */
  42315. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42316. /**
  42317. * Observable raised when exiting VR.
  42318. */
  42319. onExitingVRObservable: Observable<VRExperienceHelper>;
  42320. /**
  42321. * Observable raised when controller mesh is loaded.
  42322. */
  42323. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42324. /** Return this.onEnteringVRObservable
  42325. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42326. */
  42327. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42328. /** Return this.onExitingVRObservable
  42329. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42330. */
  42331. readonly onExitingVR: Observable<VRExperienceHelper>;
  42332. /** Return this.onControllerMeshLoadedObservable
  42333. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42334. */
  42335. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42336. private _rayLength;
  42337. private _useCustomVRButton;
  42338. private _teleportationRequested;
  42339. private _teleportActive;
  42340. private _floorMeshName;
  42341. private _floorMeshesCollection;
  42342. private _rotationAllowed;
  42343. private _teleportBackwardsVector;
  42344. private _teleportationTarget;
  42345. private _isDefaultTeleportationTarget;
  42346. private _postProcessMove;
  42347. private _teleportationFillColor;
  42348. private _teleportationBorderColor;
  42349. private _rotationAngle;
  42350. private _haloCenter;
  42351. private _cameraGazer;
  42352. private _padSensibilityUp;
  42353. private _padSensibilityDown;
  42354. private _leftController;
  42355. private _rightController;
  42356. /**
  42357. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42358. */
  42359. onNewMeshSelected: Observable<AbstractMesh>;
  42360. /**
  42361. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42362. * This observable will provide the mesh and the controller used to select the mesh
  42363. */
  42364. onMeshSelectedWithController: Observable<{
  42365. mesh: AbstractMesh;
  42366. controller: WebVRController;
  42367. }>;
  42368. /**
  42369. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42370. */
  42371. onNewMeshPicked: Observable<PickingInfo>;
  42372. private _circleEase;
  42373. /**
  42374. * Observable raised before camera teleportation
  42375. */
  42376. onBeforeCameraTeleport: Observable<Vector3>;
  42377. /**
  42378. * Observable raised after camera teleportation
  42379. */
  42380. onAfterCameraTeleport: Observable<Vector3>;
  42381. /**
  42382. * Observable raised when current selected mesh gets unselected
  42383. */
  42384. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42385. private _raySelectionPredicate;
  42386. /**
  42387. * To be optionaly changed by user to define custom ray selection
  42388. */
  42389. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42390. /**
  42391. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42392. */
  42393. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42394. /**
  42395. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42396. */
  42397. teleportationEnabled: boolean;
  42398. private _defaultHeight;
  42399. private _teleportationInitialized;
  42400. private _interactionsEnabled;
  42401. private _interactionsRequested;
  42402. private _displayGaze;
  42403. private _displayLaserPointer;
  42404. /**
  42405. * The mesh used to display where the user is going to teleport.
  42406. */
  42407. /**
  42408. * Sets the mesh to be used to display where the user is going to teleport.
  42409. */
  42410. teleportationTarget: Mesh;
  42411. /**
  42412. * 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
  42413. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42414. * See http://doc.babylonjs.com/resources/baking_transformations
  42415. */
  42416. gazeTrackerMesh: Mesh;
  42417. /**
  42418. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42419. */
  42420. updateGazeTrackerScale: boolean;
  42421. /**
  42422. * If the gaze trackers color should be updated when selecting meshes
  42423. */
  42424. updateGazeTrackerColor: boolean;
  42425. /**
  42426. * The gaze tracking mesh corresponding to the left controller
  42427. */
  42428. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42429. /**
  42430. * The gaze tracking mesh corresponding to the right controller
  42431. */
  42432. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42433. /**
  42434. * If the ray of the gaze should be displayed.
  42435. */
  42436. /**
  42437. * Sets if the ray of the gaze should be displayed.
  42438. */
  42439. displayGaze: boolean;
  42440. /**
  42441. * If the ray of the LaserPointer should be displayed.
  42442. */
  42443. /**
  42444. * Sets if the ray of the LaserPointer should be displayed.
  42445. */
  42446. displayLaserPointer: boolean;
  42447. /**
  42448. * The deviceOrientationCamera used as the camera when not in VR.
  42449. */
  42450. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42451. /**
  42452. * Based on the current WebVR support, returns the current VR camera used.
  42453. */
  42454. readonly currentVRCamera: Nullable<Camera>;
  42455. /**
  42456. * The webVRCamera which is used when in VR.
  42457. */
  42458. readonly webVRCamera: WebVRFreeCamera;
  42459. /**
  42460. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42461. */
  42462. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42463. /**
  42464. * The html button that is used to trigger entering into VR.
  42465. */
  42466. readonly vrButton: Nullable<HTMLButtonElement>;
  42467. private readonly _teleportationRequestInitiated;
  42468. /**
  42469. * Defines wether or not Pointer lock should be requested when switching to
  42470. * full screen.
  42471. */
  42472. requestPointerLockOnFullScreen: boolean;
  42473. /**
  42474. * Instantiates a VRExperienceHelper.
  42475. * Helps to quickly add VR support to an existing scene.
  42476. * @param scene The scene the VRExperienceHelper belongs to.
  42477. * @param webVROptions Options to modify the vr experience helper's behavior.
  42478. */
  42479. constructor(scene: Scene,
  42480. /** Options to modify the vr experience helper's behavior. */
  42481. webVROptions?: VRExperienceHelperOptions);
  42482. private _onDefaultMeshLoaded;
  42483. private _onResize;
  42484. private _onFullscreenChange;
  42485. /**
  42486. * Gets a value indicating if we are currently in VR mode.
  42487. */
  42488. readonly isInVRMode: boolean;
  42489. private onVrDisplayPresentChange;
  42490. private onVRDisplayChanged;
  42491. private moveButtonToBottomRight;
  42492. private displayVRButton;
  42493. private updateButtonVisibility;
  42494. private _cachedAngularSensibility;
  42495. /**
  42496. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42497. * Otherwise, will use the fullscreen API.
  42498. */
  42499. enterVR(): void;
  42500. /**
  42501. * Attempt to exit VR, or fullscreen.
  42502. */
  42503. exitVR(): void;
  42504. /**
  42505. * The position of the vr experience helper.
  42506. */
  42507. /**
  42508. * Sets the position of the vr experience helper.
  42509. */
  42510. position: Vector3;
  42511. /**
  42512. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42513. */
  42514. enableInteractions(): void;
  42515. private readonly _noControllerIsActive;
  42516. private beforeRender;
  42517. private _isTeleportationFloor;
  42518. /**
  42519. * Adds a floor mesh to be used for teleportation.
  42520. * @param floorMesh the mesh to be used for teleportation.
  42521. */
  42522. addFloorMesh(floorMesh: Mesh): void;
  42523. /**
  42524. * Removes a floor mesh from being used for teleportation.
  42525. * @param floorMesh the mesh to be removed.
  42526. */
  42527. removeFloorMesh(floorMesh: Mesh): void;
  42528. /**
  42529. * Enables interactions and teleportation using the VR controllers and gaze.
  42530. * @param vrTeleportationOptions options to modify teleportation behavior.
  42531. */
  42532. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42533. private _onNewGamepadConnected;
  42534. private _tryEnableInteractionOnController;
  42535. private _onNewGamepadDisconnected;
  42536. private _enableInteractionOnController;
  42537. private _checkTeleportWithRay;
  42538. private _checkRotate;
  42539. private _checkTeleportBackwards;
  42540. private _enableTeleportationOnController;
  42541. private _createTeleportationCircles;
  42542. private _displayTeleportationTarget;
  42543. private _hideTeleportationTarget;
  42544. private _rotateCamera;
  42545. private _moveTeleportationSelectorTo;
  42546. private _workingVector;
  42547. private _workingQuaternion;
  42548. private _workingMatrix;
  42549. /**
  42550. * Teleports the users feet to the desired location
  42551. * @param location The location where the user's feet should be placed
  42552. */
  42553. teleportCamera(location: Vector3): void;
  42554. private _convertNormalToDirectionOfRay;
  42555. private _castRayAndSelectObject;
  42556. private _notifySelectedMeshUnselected;
  42557. /**
  42558. * Sets the color of the laser ray from the vr controllers.
  42559. * @param color new color for the ray.
  42560. */
  42561. changeLaserColor(color: Color3): void;
  42562. /**
  42563. * Sets the color of the ray from the vr headsets gaze.
  42564. * @param color new color for the ray.
  42565. */
  42566. changeGazeColor(color: Color3): void;
  42567. /**
  42568. * Exits VR and disposes of the vr experience helper
  42569. */
  42570. dispose(): void;
  42571. /**
  42572. * Gets the name of the VRExperienceHelper class
  42573. * @returns "VRExperienceHelper"
  42574. */
  42575. getClassName(): string;
  42576. }
  42577. }
  42578. declare module "babylonjs/Cameras/VR/index" {
  42579. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42580. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42581. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42582. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42583. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42584. export * from "babylonjs/Cameras/VR/webVRCamera";
  42585. }
  42586. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42587. import { Observable } from "babylonjs/Misc/observable";
  42588. import { Nullable } from "babylonjs/types";
  42589. import { IDisposable, Scene } from "babylonjs/scene";
  42590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42591. /**
  42592. * Manages an XRSession to work with Babylon's engine
  42593. * @see https://doc.babylonjs.com/how_to/webxr
  42594. */
  42595. export class WebXRSessionManager implements IDisposable {
  42596. private scene;
  42597. /**
  42598. * Fires every time a new xrFrame arrives which can be used to update the camera
  42599. */
  42600. onXRFrameObservable: Observable<any>;
  42601. /**
  42602. * Fires when the xr session is ended either by the device or manually done
  42603. */
  42604. onXRSessionEnded: Observable<any>;
  42605. /**
  42606. * Underlying xr session
  42607. */
  42608. session: XRSession;
  42609. /**
  42610. * Type of reference space used when creating the session
  42611. */
  42612. referenceSpace: XRReferenceSpace;
  42613. /** @hidden */
  42614. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42615. /**
  42616. * Current XR frame
  42617. */
  42618. currentFrame: Nullable<XRFrame>;
  42619. private _xrNavigator;
  42620. private baseLayer;
  42621. /**
  42622. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42623. * @param scene The scene which the session should be created for
  42624. */
  42625. constructor(scene: Scene);
  42626. /**
  42627. * Initializes the manager
  42628. * After initialization enterXR can be called to start an XR session
  42629. * @returns Promise which resolves after it is initialized
  42630. */
  42631. initializeAsync(): Promise<void>;
  42632. /**
  42633. * Initializes an xr session
  42634. * @param xrSessionMode mode to initialize
  42635. * @returns a promise which will resolve once the session has been initialized
  42636. */
  42637. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42638. /**
  42639. * Sets the reference space on the xr session
  42640. * @param referenceSpace space to set
  42641. * @returns a promise that will resolve once the reference space has been set
  42642. */
  42643. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42644. /**
  42645. * Updates the render state of the session
  42646. * @param state state to set
  42647. * @returns a promise that resolves once the render state has been updated
  42648. */
  42649. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42650. /**
  42651. * Starts rendering to the xr layer
  42652. * @returns a promise that will resolve once rendering has started
  42653. */
  42654. startRenderingToXRAsync(): Promise<void>;
  42655. /**
  42656. * Stops the xrSession and restores the renderloop
  42657. * @returns Promise which resolves after it exits XR
  42658. */
  42659. exitXRAsync(): Promise<unknown>;
  42660. /**
  42661. * Checks if a session would be supported for the creation options specified
  42662. * @param sessionMode session mode to check if supported eg. immersive-vr
  42663. * @returns true if supported
  42664. */
  42665. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42666. /**
  42667. * @hidden
  42668. * Converts the render layer of xrSession to a render target
  42669. * @param session session to create render target for
  42670. * @param scene scene the new render target should be created for
  42671. */
  42672. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42673. /**
  42674. * Disposes of the session manager
  42675. */
  42676. dispose(): void;
  42677. }
  42678. }
  42679. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42680. import { Scene } from "babylonjs/scene";
  42681. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42682. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42683. /**
  42684. * WebXR Camera which holds the views for the xrSession
  42685. * @see https://doc.babylonjs.com/how_to/webxr
  42686. */
  42687. export class WebXRCamera extends FreeCamera {
  42688. private static _TmpMatrix;
  42689. /**
  42690. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42691. * @param name the name of the camera
  42692. * @param scene the scene to add the camera to
  42693. */
  42694. constructor(name: string, scene: Scene);
  42695. private _updateNumberOfRigCameras;
  42696. /** @hidden */
  42697. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42698. /**
  42699. * Updates the cameras position from the current pose information of the XR session
  42700. * @param xrSessionManager the session containing pose information
  42701. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42702. */
  42703. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42704. }
  42705. }
  42706. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42707. import { Nullable } from "babylonjs/types";
  42708. import { IDisposable } from "babylonjs/scene";
  42709. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42710. /**
  42711. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42712. */
  42713. export class WebXRManagedOutputCanvas implements IDisposable {
  42714. private helper;
  42715. private _canvas;
  42716. /**
  42717. * xrpresent context of the canvas which can be used to display/mirror xr content
  42718. */
  42719. canvasContext: WebGLRenderingContext;
  42720. /**
  42721. * xr layer for the canvas
  42722. */
  42723. xrLayer: Nullable<XRWebGLLayer>;
  42724. /**
  42725. * Initializes the xr layer for the session
  42726. * @param xrSession xr session
  42727. * @returns a promise that will resolve once the XR Layer has been created
  42728. */
  42729. initializeXRLayerAsync(xrSession: any): any;
  42730. /**
  42731. * Initializes the canvas to be added/removed upon entering/exiting xr
  42732. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42733. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42734. */
  42735. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42736. /**
  42737. * Disposes of the object
  42738. */
  42739. dispose(): void;
  42740. private _setManagedOutputCanvas;
  42741. private _addCanvas;
  42742. private _removeCanvas;
  42743. }
  42744. }
  42745. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42746. import { Observable } from "babylonjs/Misc/observable";
  42747. import { IDisposable, Scene } from "babylonjs/scene";
  42748. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42750. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42751. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42752. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42753. /**
  42754. * States of the webXR experience
  42755. */
  42756. export enum WebXRState {
  42757. /**
  42758. * Transitioning to being in XR mode
  42759. */
  42760. ENTERING_XR = 0,
  42761. /**
  42762. * Transitioning to non XR mode
  42763. */
  42764. EXITING_XR = 1,
  42765. /**
  42766. * In XR mode and presenting
  42767. */
  42768. IN_XR = 2,
  42769. /**
  42770. * Not entered XR mode
  42771. */
  42772. NOT_IN_XR = 3
  42773. }
  42774. /**
  42775. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42776. * @see https://doc.babylonjs.com/how_to/webxr
  42777. */
  42778. export class WebXRExperienceHelper implements IDisposable {
  42779. private scene;
  42780. /**
  42781. * 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
  42782. */
  42783. container: AbstractMesh;
  42784. /**
  42785. * Camera used to render xr content
  42786. */
  42787. camera: WebXRCamera;
  42788. /**
  42789. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42790. */
  42791. state: WebXRState;
  42792. private _setState;
  42793. private static _TmpVector;
  42794. /**
  42795. * Fires when the state of the experience helper has changed
  42796. */
  42797. onStateChangedObservable: Observable<WebXRState>;
  42798. /** Session manager used to keep track of xr session */
  42799. sessionManager: WebXRSessionManager;
  42800. private _nonVRCamera;
  42801. private _originalSceneAutoClear;
  42802. private _supported;
  42803. /**
  42804. * Creates the experience helper
  42805. * @param scene the scene to attach the experience helper to
  42806. * @returns a promise for the experience helper
  42807. */
  42808. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42809. /**
  42810. * Creates a WebXRExperienceHelper
  42811. * @param scene The scene the helper should be created in
  42812. */
  42813. private constructor();
  42814. /**
  42815. * Exits XR mode and returns the scene to its original state
  42816. * @returns promise that resolves after xr mode has exited
  42817. */
  42818. exitXRAsync(): Promise<unknown>;
  42819. /**
  42820. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42821. * @param sessionCreationOptions options for the XR session
  42822. * @param referenceSpaceType frame of reference of the XR session
  42823. * @param outputCanvas the output canvas that will be used to enter XR mode
  42824. * @returns promise that resolves after xr mode has entered
  42825. */
  42826. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42827. /**
  42828. * Updates the global position of the camera by moving the camera's container
  42829. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42830. * @param position The desired global position of the camera
  42831. */
  42832. setPositionOfCameraUsingContainer(position: Vector3): void;
  42833. /**
  42834. * Rotates the xr camera by rotating the camera's container around the camera's position
  42835. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42836. * @param rotation the desired quaternion rotation to apply to the camera
  42837. */
  42838. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42839. /**
  42840. * Disposes of the experience helper
  42841. */
  42842. dispose(): void;
  42843. }
  42844. }
  42845. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42846. import { Nullable } from "babylonjs/types";
  42847. import { Observable } from "babylonjs/Misc/observable";
  42848. import { IDisposable, Scene } from "babylonjs/scene";
  42849. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42850. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42851. /**
  42852. * Button which can be used to enter a different mode of XR
  42853. */
  42854. export class WebXREnterExitUIButton {
  42855. /** button element */
  42856. element: HTMLElement;
  42857. /** XR initialization options for the button */
  42858. sessionMode: XRSessionMode;
  42859. /** Reference space type */
  42860. referenceSpaceType: XRReferenceSpaceType;
  42861. /**
  42862. * Creates a WebXREnterExitUIButton
  42863. * @param element button element
  42864. * @param sessionMode XR initialization session mode
  42865. * @param referenceSpaceType the type of reference space to be used
  42866. */
  42867. constructor(
  42868. /** button element */
  42869. element: HTMLElement,
  42870. /** XR initialization options for the button */
  42871. sessionMode: XRSessionMode,
  42872. /** Reference space type */
  42873. referenceSpaceType: XRReferenceSpaceType);
  42874. /**
  42875. * Overwritable function which can be used to update the button's visuals when the state changes
  42876. * @param activeButton the current active button in the UI
  42877. */
  42878. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42879. }
  42880. /**
  42881. * Options to create the webXR UI
  42882. */
  42883. export class WebXREnterExitUIOptions {
  42884. /**
  42885. * Context to enter xr with
  42886. */
  42887. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42888. /**
  42889. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42890. */
  42891. customButtons?: Array<WebXREnterExitUIButton>;
  42892. }
  42893. /**
  42894. * UI to allow the user to enter/exit XR mode
  42895. */
  42896. export class WebXREnterExitUI implements IDisposable {
  42897. private scene;
  42898. private _overlay;
  42899. private _buttons;
  42900. private _activeButton;
  42901. /**
  42902. * Fired every time the active button is changed.
  42903. *
  42904. * When xr is entered via a button that launches xr that button will be the callback parameter
  42905. *
  42906. * When exiting xr the callback parameter will be null)
  42907. */
  42908. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42909. /**
  42910. * Creates UI to allow the user to enter/exit XR mode
  42911. * @param scene the scene to add the ui to
  42912. * @param helper the xr experience helper to enter/exit xr with
  42913. * @param options options to configure the UI
  42914. * @returns the created ui
  42915. */
  42916. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42917. private constructor();
  42918. private _updateButtons;
  42919. /**
  42920. * Disposes of the object
  42921. */
  42922. dispose(): void;
  42923. }
  42924. }
  42925. declare module "babylonjs/Cameras/XR/webXRController" {
  42926. import { Nullable } from "babylonjs/types";
  42927. import { Observable } from "babylonjs/Misc/observable";
  42928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42929. import { Ray } from "babylonjs/Culling/ray";
  42930. import { Scene } from "babylonjs/scene";
  42931. /**
  42932. * Represents an XR input
  42933. */
  42934. export class WebXRController {
  42935. private scene;
  42936. /** The underlying input source for the controller */
  42937. inputSource: XRInputSource;
  42938. private parentContainer;
  42939. /**
  42940. * 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
  42941. */
  42942. grip?: AbstractMesh;
  42943. /**
  42944. * Pointer which can be used to select objects or attach a visible laser to
  42945. */
  42946. pointer: AbstractMesh;
  42947. /**
  42948. * Event that fires when the controller is removed/disposed
  42949. */
  42950. onDisposeObservable: Observable<{}>;
  42951. private _tmpMatrix;
  42952. private _tmpQuaternion;
  42953. private _tmpVector;
  42954. /**
  42955. * Creates the controller
  42956. * @see https://doc.babylonjs.com/how_to/webxr
  42957. * @param scene the scene which the controller should be associated to
  42958. * @param inputSource the underlying input source for the controller
  42959. * @param parentContainer parent that the controller meshes should be children of
  42960. */
  42961. constructor(scene: Scene,
  42962. /** The underlying input source for the controller */
  42963. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42964. /**
  42965. * Updates the controller pose based on the given XRFrame
  42966. * @param xrFrame xr frame to update the pose with
  42967. * @param referenceSpace reference space to use
  42968. */
  42969. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42970. /**
  42971. * Gets a world space ray coming from the controller
  42972. * @param result the resulting ray
  42973. */
  42974. getWorldPointerRayToRef(result: Ray): void;
  42975. /**
  42976. * Disposes of the object
  42977. */
  42978. dispose(): void;
  42979. }
  42980. }
  42981. declare module "babylonjs/Cameras/XR/webXRInput" {
  42982. import { Observable } from "babylonjs/Misc/observable";
  42983. import { IDisposable } from "babylonjs/scene";
  42984. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42985. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42986. /**
  42987. * XR input used to track XR inputs such as controllers/rays
  42988. */
  42989. export class WebXRInput implements IDisposable {
  42990. /**
  42991. * Base experience the input listens to
  42992. */
  42993. baseExperience: WebXRExperienceHelper;
  42994. /**
  42995. * XR controllers being tracked
  42996. */
  42997. controllers: Array<WebXRController>;
  42998. private _frameObserver;
  42999. private _stateObserver;
  43000. /**
  43001. * Event when a controller has been connected/added
  43002. */
  43003. onControllerAddedObservable: Observable<WebXRController>;
  43004. /**
  43005. * Event when a controller has been removed/disconnected
  43006. */
  43007. onControllerRemovedObservable: Observable<WebXRController>;
  43008. /**
  43009. * Initializes the WebXRInput
  43010. * @param baseExperience experience helper which the input should be created for
  43011. */
  43012. constructor(
  43013. /**
  43014. * Base experience the input listens to
  43015. */
  43016. baseExperience: WebXRExperienceHelper);
  43017. private _onInputSourcesChange;
  43018. private _addAndRemoveControllers;
  43019. /**
  43020. * Disposes of the object
  43021. */
  43022. dispose(): void;
  43023. }
  43024. }
  43025. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43027. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43028. /**
  43029. * Enables teleportation
  43030. */
  43031. export class WebXRControllerTeleportation {
  43032. private _teleportationFillColor;
  43033. private _teleportationBorderColor;
  43034. private _tmpRay;
  43035. private _tmpVector;
  43036. /**
  43037. * Creates a WebXRControllerTeleportation
  43038. * @param input input manager to add teleportation to
  43039. * @param floorMeshes floormeshes which can be teleported to
  43040. */
  43041. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43042. }
  43043. }
  43044. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43045. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43046. /**
  43047. * Handles pointer input automatically for the pointer of XR controllers
  43048. */
  43049. export class WebXRControllerPointerSelection {
  43050. private static _idCounter;
  43051. private _tmpRay;
  43052. /**
  43053. * Creates a WebXRControllerPointerSelection
  43054. * @param input input manager to setup pointer selection
  43055. */
  43056. constructor(input: WebXRInput);
  43057. private _convertNormalToDirectionOfRay;
  43058. private _updatePointerDistance;
  43059. }
  43060. }
  43061. declare module "babylonjs/Loading/sceneLoader" {
  43062. import { Observable } from "babylonjs/Misc/observable";
  43063. import { Nullable } from "babylonjs/types";
  43064. import { Scene } from "babylonjs/scene";
  43065. import { Engine } from "babylonjs/Engines/engine";
  43066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43067. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43068. import { AssetContainer } from "babylonjs/assetContainer";
  43069. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43070. import { Skeleton } from "babylonjs/Bones/skeleton";
  43071. /**
  43072. * Class used to represent data loading progression
  43073. */
  43074. export class SceneLoaderProgressEvent {
  43075. /** defines if data length to load can be evaluated */
  43076. readonly lengthComputable: boolean;
  43077. /** defines the loaded data length */
  43078. readonly loaded: number;
  43079. /** defines the data length to load */
  43080. readonly total: number;
  43081. /**
  43082. * Create a new progress event
  43083. * @param lengthComputable defines if data length to load can be evaluated
  43084. * @param loaded defines the loaded data length
  43085. * @param total defines the data length to load
  43086. */
  43087. constructor(
  43088. /** defines if data length to load can be evaluated */
  43089. lengthComputable: boolean,
  43090. /** defines the loaded data length */
  43091. loaded: number,
  43092. /** defines the data length to load */
  43093. total: number);
  43094. /**
  43095. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43096. * @param event defines the source event
  43097. * @returns a new SceneLoaderProgressEvent
  43098. */
  43099. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43100. }
  43101. /**
  43102. * Interface used by SceneLoader plugins to define supported file extensions
  43103. */
  43104. export interface ISceneLoaderPluginExtensions {
  43105. /**
  43106. * Defines the list of supported extensions
  43107. */
  43108. [extension: string]: {
  43109. isBinary: boolean;
  43110. };
  43111. }
  43112. /**
  43113. * Interface used by SceneLoader plugin factory
  43114. */
  43115. export interface ISceneLoaderPluginFactory {
  43116. /**
  43117. * Defines the name of the factory
  43118. */
  43119. name: string;
  43120. /**
  43121. * Function called to create a new plugin
  43122. * @return the new plugin
  43123. */
  43124. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43125. /**
  43126. * Boolean indicating if the plugin can direct load specific data
  43127. */
  43128. canDirectLoad?: (data: string) => boolean;
  43129. }
  43130. /**
  43131. * Interface used to define a SceneLoader plugin
  43132. */
  43133. export interface ISceneLoaderPlugin {
  43134. /**
  43135. * The friendly name of this plugin.
  43136. */
  43137. name: string;
  43138. /**
  43139. * The file extensions supported by this plugin.
  43140. */
  43141. extensions: string | ISceneLoaderPluginExtensions;
  43142. /**
  43143. * Import meshes into a scene.
  43144. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43145. * @param scene The scene to import into
  43146. * @param data The data to import
  43147. * @param rootUrl The root url for scene and resources
  43148. * @param meshes The meshes array to import into
  43149. * @param particleSystems The particle systems array to import into
  43150. * @param skeletons The skeletons array to import into
  43151. * @param onError The callback when import fails
  43152. * @returns True if successful or false otherwise
  43153. */
  43154. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43155. /**
  43156. * Load into a scene.
  43157. * @param scene The scene to load into
  43158. * @param data The data to import
  43159. * @param rootUrl The root url for scene and resources
  43160. * @param onError The callback when import fails
  43161. * @returns true if successful or false otherwise
  43162. */
  43163. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43164. /**
  43165. * The callback that returns true if the data can be directly loaded.
  43166. */
  43167. canDirectLoad?: (data: string) => boolean;
  43168. /**
  43169. * The callback that allows custom handling of the root url based on the response url.
  43170. */
  43171. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43172. /**
  43173. * Load into an asset container.
  43174. * @param scene The scene to load into
  43175. * @param data The data to import
  43176. * @param rootUrl The root url for scene and resources
  43177. * @param onError The callback when import fails
  43178. * @returns The loaded asset container
  43179. */
  43180. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43181. }
  43182. /**
  43183. * Interface used to define an async SceneLoader plugin
  43184. */
  43185. export interface ISceneLoaderPluginAsync {
  43186. /**
  43187. * The friendly name of this plugin.
  43188. */
  43189. name: string;
  43190. /**
  43191. * The file extensions supported by this plugin.
  43192. */
  43193. extensions: string | ISceneLoaderPluginExtensions;
  43194. /**
  43195. * Import meshes into a scene.
  43196. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43197. * @param scene The scene to import into
  43198. * @param data The data to import
  43199. * @param rootUrl The root url for scene and resources
  43200. * @param onProgress The callback when the load progresses
  43201. * @param fileName Defines the name of the file to load
  43202. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43203. */
  43204. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43205. meshes: AbstractMesh[];
  43206. particleSystems: IParticleSystem[];
  43207. skeletons: Skeleton[];
  43208. animationGroups: AnimationGroup[];
  43209. }>;
  43210. /**
  43211. * Load into a scene.
  43212. * @param scene The scene to load into
  43213. * @param data The data to import
  43214. * @param rootUrl The root url for scene and resources
  43215. * @param onProgress The callback when the load progresses
  43216. * @param fileName Defines the name of the file to load
  43217. * @returns Nothing
  43218. */
  43219. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43220. /**
  43221. * The callback that returns true if the data can be directly loaded.
  43222. */
  43223. canDirectLoad?: (data: string) => boolean;
  43224. /**
  43225. * The callback that allows custom handling of the root url based on the response url.
  43226. */
  43227. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43228. /**
  43229. * Load into an asset container.
  43230. * @param scene The scene to load into
  43231. * @param data The data to import
  43232. * @param rootUrl The root url for scene and resources
  43233. * @param onProgress The callback when the load progresses
  43234. * @param fileName Defines the name of the file to load
  43235. * @returns The loaded asset container
  43236. */
  43237. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43238. }
  43239. /**
  43240. * Class used to load scene from various file formats using registered plugins
  43241. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43242. */
  43243. export class SceneLoader {
  43244. /**
  43245. * No logging while loading
  43246. */
  43247. static readonly NO_LOGGING: number;
  43248. /**
  43249. * Minimal logging while loading
  43250. */
  43251. static readonly MINIMAL_LOGGING: number;
  43252. /**
  43253. * Summary logging while loading
  43254. */
  43255. static readonly SUMMARY_LOGGING: number;
  43256. /**
  43257. * Detailled logging while loading
  43258. */
  43259. static readonly DETAILED_LOGGING: number;
  43260. /**
  43261. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43262. */
  43263. static ForceFullSceneLoadingForIncremental: boolean;
  43264. /**
  43265. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43266. */
  43267. static ShowLoadingScreen: boolean;
  43268. /**
  43269. * Defines the current logging level (while loading the scene)
  43270. * @ignorenaming
  43271. */
  43272. static loggingLevel: number;
  43273. /**
  43274. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43275. */
  43276. static CleanBoneMatrixWeights: boolean;
  43277. /**
  43278. * Event raised when a plugin is used to load a scene
  43279. */
  43280. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43281. private static _registeredPlugins;
  43282. private static _getDefaultPlugin;
  43283. private static _getPluginForExtension;
  43284. private static _getPluginForDirectLoad;
  43285. private static _getPluginForFilename;
  43286. private static _getDirectLoad;
  43287. private static _loadData;
  43288. private static _getFileInfo;
  43289. /**
  43290. * Gets a plugin that can load the given extension
  43291. * @param extension defines the extension to load
  43292. * @returns a plugin or null if none works
  43293. */
  43294. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43295. /**
  43296. * Gets a boolean indicating that the given extension can be loaded
  43297. * @param extension defines the extension to load
  43298. * @returns true if the extension is supported
  43299. */
  43300. static IsPluginForExtensionAvailable(extension: string): boolean;
  43301. /**
  43302. * Adds a new plugin to the list of registered plugins
  43303. * @param plugin defines the plugin to add
  43304. */
  43305. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43306. /**
  43307. * Import meshes into a scene
  43308. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43309. * @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)
  43310. * @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)
  43311. * @param scene the instance of BABYLON.Scene to append to
  43312. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43313. * @param onProgress a callback with a progress event for each file being loaded
  43314. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43315. * @param pluginExtension the extension used to determine the plugin
  43316. * @returns The loaded plugin
  43317. */
  43318. 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>;
  43319. /**
  43320. * Import meshes into a scene
  43321. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43322. * @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)
  43323. * @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)
  43324. * @param scene the instance of BABYLON.Scene to append to
  43325. * @param onProgress a callback with a progress event for each file being loaded
  43326. * @param pluginExtension the extension used to determine the plugin
  43327. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43328. */
  43329. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43330. meshes: AbstractMesh[];
  43331. particleSystems: IParticleSystem[];
  43332. skeletons: Skeleton[];
  43333. animationGroups: AnimationGroup[];
  43334. }>;
  43335. /**
  43336. * Load a scene
  43337. * @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)
  43338. * @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)
  43339. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43340. * @param onSuccess a callback with the scene when import succeeds
  43341. * @param onProgress a callback with a progress event for each file being loaded
  43342. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43343. * @param pluginExtension the extension used to determine the plugin
  43344. * @returns The loaded plugin
  43345. */
  43346. 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>;
  43347. /**
  43348. * Load a scene
  43349. * @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)
  43350. * @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)
  43351. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43352. * @param onProgress a callback with a progress event for each file being loaded
  43353. * @param pluginExtension the extension used to determine the plugin
  43354. * @returns The loaded scene
  43355. */
  43356. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43357. /**
  43358. * Append a scene
  43359. * @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)
  43360. * @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)
  43361. * @param scene is the instance of BABYLON.Scene to append to
  43362. * @param onSuccess a callback with the scene when import succeeds
  43363. * @param onProgress a callback with a progress event for each file being loaded
  43364. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43365. * @param pluginExtension the extension used to determine the plugin
  43366. * @returns The loaded plugin
  43367. */
  43368. 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>;
  43369. /**
  43370. * Append a scene
  43371. * @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)
  43372. * @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)
  43373. * @param scene is the instance of BABYLON.Scene to append to
  43374. * @param onProgress a callback with a progress event for each file being loaded
  43375. * @param pluginExtension the extension used to determine the plugin
  43376. * @returns The given scene
  43377. */
  43378. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43379. /**
  43380. * Load a scene into an asset container
  43381. * @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)
  43382. * @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)
  43383. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43384. * @param onSuccess a callback with the scene when import succeeds
  43385. * @param onProgress a callback with a progress event for each file being loaded
  43386. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43387. * @param pluginExtension the extension used to determine the plugin
  43388. * @returns The loaded plugin
  43389. */
  43390. 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>;
  43391. /**
  43392. * Load a scene into an asset container
  43393. * @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)
  43394. * @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)
  43395. * @param scene is the instance of Scene to append to
  43396. * @param onProgress a callback with a progress event for each file being loaded
  43397. * @param pluginExtension the extension used to determine the plugin
  43398. * @returns The loaded asset container
  43399. */
  43400. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43401. }
  43402. }
  43403. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43404. import { Scene } from "babylonjs/scene";
  43405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43406. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43407. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43408. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43409. /**
  43410. * Generic Controller
  43411. */
  43412. export class GenericController extends WebVRController {
  43413. /**
  43414. * Base Url for the controller model.
  43415. */
  43416. static readonly MODEL_BASE_URL: string;
  43417. /**
  43418. * File name for the controller model.
  43419. */
  43420. static readonly MODEL_FILENAME: string;
  43421. /**
  43422. * Creates a new GenericController from a gamepad
  43423. * @param vrGamepad the gamepad that the controller should be created from
  43424. */
  43425. constructor(vrGamepad: any);
  43426. /**
  43427. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43428. * @param scene scene in which to add meshes
  43429. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43430. */
  43431. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43432. /**
  43433. * Called once for each button that changed state since the last frame
  43434. * @param buttonIdx Which button index changed
  43435. * @param state New state of the button
  43436. * @param changes Which properties on the state changed since last frame
  43437. */
  43438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43439. }
  43440. }
  43441. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43442. import { Observable } from "babylonjs/Misc/observable";
  43443. import { Scene } from "babylonjs/scene";
  43444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43445. import { Ray } from "babylonjs/Culling/ray";
  43446. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43447. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43448. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43449. /**
  43450. * Defines the WindowsMotionController object that the state of the windows motion controller
  43451. */
  43452. export class WindowsMotionController extends WebVRController {
  43453. /**
  43454. * The base url used to load the left and right controller models
  43455. */
  43456. static MODEL_BASE_URL: string;
  43457. /**
  43458. * The name of the left controller model file
  43459. */
  43460. static MODEL_LEFT_FILENAME: string;
  43461. /**
  43462. * The name of the right controller model file
  43463. */
  43464. static MODEL_RIGHT_FILENAME: string;
  43465. /**
  43466. * The controller name prefix for this controller type
  43467. */
  43468. static readonly GAMEPAD_ID_PREFIX: string;
  43469. /**
  43470. * The controller id pattern for this controller type
  43471. */
  43472. private static readonly GAMEPAD_ID_PATTERN;
  43473. private _loadedMeshInfo;
  43474. private readonly _mapping;
  43475. /**
  43476. * Fired when the trackpad on this controller is clicked
  43477. */
  43478. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43479. /**
  43480. * Fired when the trackpad on this controller is modified
  43481. */
  43482. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43483. /**
  43484. * The current x and y values of this controller's trackpad
  43485. */
  43486. trackpad: StickValues;
  43487. /**
  43488. * Creates a new WindowsMotionController from a gamepad
  43489. * @param vrGamepad the gamepad that the controller should be created from
  43490. */
  43491. constructor(vrGamepad: any);
  43492. /**
  43493. * Fired when the trigger on this controller is modified
  43494. */
  43495. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43496. /**
  43497. * Fired when the menu button on this controller is modified
  43498. */
  43499. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43500. /**
  43501. * Fired when the grip button on this controller is modified
  43502. */
  43503. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43504. /**
  43505. * Fired when the thumbstick button on this controller is modified
  43506. */
  43507. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43508. /**
  43509. * Fired when the touchpad button on this controller is modified
  43510. */
  43511. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43512. /**
  43513. * Fired when the touchpad values on this controller are modified
  43514. */
  43515. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43516. private _updateTrackpad;
  43517. /**
  43518. * Called once per frame by the engine.
  43519. */
  43520. update(): void;
  43521. /**
  43522. * Called once for each button that changed state since the last frame
  43523. * @param buttonIdx Which button index changed
  43524. * @param state New state of the button
  43525. * @param changes Which properties on the state changed since last frame
  43526. */
  43527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43528. /**
  43529. * Moves the buttons on the controller mesh based on their current state
  43530. * @param buttonName the name of the button to move
  43531. * @param buttonValue the value of the button which determines the buttons new position
  43532. */
  43533. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43534. /**
  43535. * Moves the axis on the controller mesh based on its current state
  43536. * @param axis the index of the axis
  43537. * @param axisValue the value of the axis which determines the meshes new position
  43538. * @hidden
  43539. */
  43540. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43541. /**
  43542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43543. * @param scene scene in which to add meshes
  43544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43545. */
  43546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43547. /**
  43548. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43549. * can be transformed by button presses and axes values, based on this._mapping.
  43550. *
  43551. * @param scene scene in which the meshes exist
  43552. * @param meshes list of meshes that make up the controller model to process
  43553. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43554. */
  43555. private processModel;
  43556. private createMeshInfo;
  43557. /**
  43558. * Gets the ray of the controller in the direction the controller is pointing
  43559. * @param length the length the resulting ray should be
  43560. * @returns a ray in the direction the controller is pointing
  43561. */
  43562. getForwardRay(length?: number): Ray;
  43563. /**
  43564. * Disposes of the controller
  43565. */
  43566. dispose(): void;
  43567. }
  43568. }
  43569. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43570. import { Observable } from "babylonjs/Misc/observable";
  43571. import { Scene } from "babylonjs/scene";
  43572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43573. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43574. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43575. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43576. /**
  43577. * Oculus Touch Controller
  43578. */
  43579. export class OculusTouchController extends WebVRController {
  43580. /**
  43581. * Base Url for the controller model.
  43582. */
  43583. static MODEL_BASE_URL: string;
  43584. /**
  43585. * File name for the left controller model.
  43586. */
  43587. static MODEL_LEFT_FILENAME: string;
  43588. /**
  43589. * File name for the right controller model.
  43590. */
  43591. static MODEL_RIGHT_FILENAME: string;
  43592. /**
  43593. * Base Url for the Quest controller model.
  43594. */
  43595. static QUEST_MODEL_BASE_URL: string;
  43596. /**
  43597. * @hidden
  43598. * If the controllers are running on a device that needs the updated Quest controller models
  43599. */
  43600. static _IsQuest: boolean;
  43601. /**
  43602. * Fired when the secondary trigger on this controller is modified
  43603. */
  43604. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43605. /**
  43606. * Fired when the thumb rest on this controller is modified
  43607. */
  43608. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43609. /**
  43610. * Creates a new OculusTouchController from a gamepad
  43611. * @param vrGamepad the gamepad that the controller should be created from
  43612. */
  43613. constructor(vrGamepad: any);
  43614. /**
  43615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43616. * @param scene scene in which to add meshes
  43617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43618. */
  43619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43620. /**
  43621. * Fired when the A button on this controller is modified
  43622. */
  43623. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43624. /**
  43625. * Fired when the B button on this controller is modified
  43626. */
  43627. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43628. /**
  43629. * Fired when the X button on this controller is modified
  43630. */
  43631. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43632. /**
  43633. * Fired when the Y button on this controller is modified
  43634. */
  43635. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43636. /**
  43637. * Called once for each button that changed state since the last frame
  43638. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43639. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43640. * 2) secondary trigger (same)
  43641. * 3) A (right) X (left), touch, pressed = value
  43642. * 4) B / Y
  43643. * 5) thumb rest
  43644. * @param buttonIdx Which button index changed
  43645. * @param state New state of the button
  43646. * @param changes Which properties on the state changed since last frame
  43647. */
  43648. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43649. }
  43650. }
  43651. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43652. import { Scene } from "babylonjs/scene";
  43653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43654. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43655. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43656. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43657. import { Observable } from "babylonjs/Misc/observable";
  43658. /**
  43659. * Vive Controller
  43660. */
  43661. export class ViveController extends WebVRController {
  43662. /**
  43663. * Base Url for the controller model.
  43664. */
  43665. static MODEL_BASE_URL: string;
  43666. /**
  43667. * File name for the controller model.
  43668. */
  43669. static MODEL_FILENAME: string;
  43670. /**
  43671. * Creates a new ViveController from a gamepad
  43672. * @param vrGamepad the gamepad that the controller should be created from
  43673. */
  43674. constructor(vrGamepad: any);
  43675. /**
  43676. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43677. * @param scene scene in which to add meshes
  43678. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43679. */
  43680. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43681. /**
  43682. * Fired when the left button on this controller is modified
  43683. */
  43684. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43685. /**
  43686. * Fired when the right button on this controller is modified
  43687. */
  43688. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43689. /**
  43690. * Fired when the menu button on this controller is modified
  43691. */
  43692. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43693. /**
  43694. * Called once for each button that changed state since the last frame
  43695. * Vive mapping:
  43696. * 0: touchpad
  43697. * 1: trigger
  43698. * 2: left AND right buttons
  43699. * 3: menu button
  43700. * @param buttonIdx Which button index changed
  43701. * @param state New state of the button
  43702. * @param changes Which properties on the state changed since last frame
  43703. */
  43704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43705. }
  43706. }
  43707. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43708. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43709. /**
  43710. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43711. */
  43712. export class WebXRControllerModelLoader {
  43713. /**
  43714. * Creates the WebXRControllerModelLoader
  43715. * @param input xr input that creates the controllers
  43716. */
  43717. constructor(input: WebXRInput);
  43718. }
  43719. }
  43720. declare module "babylonjs/Cameras/XR/index" {
  43721. export * from "babylonjs/Cameras/XR/webXRCamera";
  43722. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43723. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43724. export * from "babylonjs/Cameras/XR/webXRInput";
  43725. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43726. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43727. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43728. export * from "babylonjs/Cameras/XR/webXRController";
  43729. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43730. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43731. }
  43732. declare module "babylonjs/Cameras/RigModes/index" {
  43733. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43734. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43735. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43736. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43737. }
  43738. declare module "babylonjs/Cameras/index" {
  43739. export * from "babylonjs/Cameras/Inputs/index";
  43740. export * from "babylonjs/Cameras/cameraInputsManager";
  43741. export * from "babylonjs/Cameras/camera";
  43742. export * from "babylonjs/Cameras/targetCamera";
  43743. export * from "babylonjs/Cameras/freeCamera";
  43744. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43745. export * from "babylonjs/Cameras/touchCamera";
  43746. export * from "babylonjs/Cameras/arcRotateCamera";
  43747. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43748. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43749. export * from "babylonjs/Cameras/flyCamera";
  43750. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43751. export * from "babylonjs/Cameras/followCamera";
  43752. export * from "babylonjs/Cameras/followCameraInputsManager";
  43753. export * from "babylonjs/Cameras/gamepadCamera";
  43754. export * from "babylonjs/Cameras/Stereoscopic/index";
  43755. export * from "babylonjs/Cameras/universalCamera";
  43756. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43757. export * from "babylonjs/Cameras/VR/index";
  43758. export * from "babylonjs/Cameras/XR/index";
  43759. export * from "babylonjs/Cameras/RigModes/index";
  43760. }
  43761. declare module "babylonjs/Collisions/index" {
  43762. export * from "babylonjs/Collisions/collider";
  43763. export * from "babylonjs/Collisions/collisionCoordinator";
  43764. export * from "babylonjs/Collisions/pickingInfo";
  43765. export * from "babylonjs/Collisions/intersectionInfo";
  43766. export * from "babylonjs/Collisions/meshCollisionData";
  43767. }
  43768. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43769. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43770. import { Vector3 } from "babylonjs/Maths/math.vector";
  43771. import { Ray } from "babylonjs/Culling/ray";
  43772. import { Plane } from "babylonjs/Maths/math.plane";
  43773. /**
  43774. * Contains an array of blocks representing the octree
  43775. */
  43776. export interface IOctreeContainer<T> {
  43777. /**
  43778. * Blocks within the octree
  43779. */
  43780. blocks: Array<OctreeBlock<T>>;
  43781. }
  43782. /**
  43783. * Class used to store a cell in an octree
  43784. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43785. */
  43786. export class OctreeBlock<T> {
  43787. /**
  43788. * Gets the content of the current block
  43789. */
  43790. entries: T[];
  43791. /**
  43792. * Gets the list of block children
  43793. */
  43794. blocks: Array<OctreeBlock<T>>;
  43795. private _depth;
  43796. private _maxDepth;
  43797. private _capacity;
  43798. private _minPoint;
  43799. private _maxPoint;
  43800. private _boundingVectors;
  43801. private _creationFunc;
  43802. /**
  43803. * Creates a new block
  43804. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43805. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43806. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43807. * @param depth defines the current depth of this block in the octree
  43808. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43809. * @param creationFunc defines a callback to call when an element is added to the block
  43810. */
  43811. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43812. /**
  43813. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43814. */
  43815. readonly capacity: number;
  43816. /**
  43817. * Gets the minimum vector (in world space) of the block's bounding box
  43818. */
  43819. readonly minPoint: Vector3;
  43820. /**
  43821. * Gets the maximum vector (in world space) of the block's bounding box
  43822. */
  43823. readonly maxPoint: Vector3;
  43824. /**
  43825. * Add a new element to this block
  43826. * @param entry defines the element to add
  43827. */
  43828. addEntry(entry: T): void;
  43829. /**
  43830. * Remove an element from this block
  43831. * @param entry defines the element to remove
  43832. */
  43833. removeEntry(entry: T): void;
  43834. /**
  43835. * Add an array of elements to this block
  43836. * @param entries defines the array of elements to add
  43837. */
  43838. addEntries(entries: T[]): void;
  43839. /**
  43840. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43841. * @param frustumPlanes defines the frustum planes to test
  43842. * @param selection defines the array to store current content if selection is positive
  43843. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43844. */
  43845. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43846. /**
  43847. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43848. * @param sphereCenter defines the bounding sphere center
  43849. * @param sphereRadius defines the bounding sphere radius
  43850. * @param selection defines the array to store current content if selection is positive
  43851. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43852. */
  43853. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43854. /**
  43855. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43856. * @param ray defines the ray to test with
  43857. * @param selection defines the array to store current content if selection is positive
  43858. */
  43859. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43860. /**
  43861. * Subdivide the content into child blocks (this block will then be empty)
  43862. */
  43863. createInnerBlocks(): void;
  43864. /**
  43865. * @hidden
  43866. */
  43867. 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;
  43868. }
  43869. }
  43870. declare module "babylonjs/Culling/Octrees/octree" {
  43871. import { SmartArray } from "babylonjs/Misc/smartArray";
  43872. import { Vector3 } from "babylonjs/Maths/math.vector";
  43873. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43875. import { Ray } from "babylonjs/Culling/ray";
  43876. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43877. import { Plane } from "babylonjs/Maths/math.plane";
  43878. /**
  43879. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43880. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43881. */
  43882. export class Octree<T> {
  43883. /** 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.) */
  43884. maxDepth: number;
  43885. /**
  43886. * Blocks within the octree containing objects
  43887. */
  43888. blocks: Array<OctreeBlock<T>>;
  43889. /**
  43890. * Content stored in the octree
  43891. */
  43892. dynamicContent: T[];
  43893. private _maxBlockCapacity;
  43894. private _selectionContent;
  43895. private _creationFunc;
  43896. /**
  43897. * Creates a octree
  43898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43899. * @param creationFunc function to be used to instatiate the octree
  43900. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43901. * @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.)
  43902. */
  43903. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43904. /** 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.) */
  43905. maxDepth?: number);
  43906. /**
  43907. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43908. * @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);
  43909. * @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);
  43910. * @param entries meshes to be added to the octree blocks
  43911. */
  43912. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43913. /**
  43914. * Adds a mesh to the octree
  43915. * @param entry Mesh to add to the octree
  43916. */
  43917. addMesh(entry: T): void;
  43918. /**
  43919. * Remove an element from the octree
  43920. * @param entry defines the element to remove
  43921. */
  43922. removeMesh(entry: T): void;
  43923. /**
  43924. * Selects an array of meshes within the frustum
  43925. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43926. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43927. * @returns array of meshes within the frustum
  43928. */
  43929. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43930. /**
  43931. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43932. * @param sphereCenter defines the bounding sphere center
  43933. * @param sphereRadius defines the bounding sphere radius
  43934. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43935. * @returns an array of objects that intersect the sphere
  43936. */
  43937. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43938. /**
  43939. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43940. * @param ray defines the ray to test with
  43941. * @returns array of intersected objects
  43942. */
  43943. intersectsRay(ray: Ray): SmartArray<T>;
  43944. /**
  43945. * Adds a mesh into the octree block if it intersects the block
  43946. */
  43947. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43948. /**
  43949. * Adds a submesh into the octree block if it intersects the block
  43950. */
  43951. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43952. }
  43953. }
  43954. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43955. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43956. import { Scene } from "babylonjs/scene";
  43957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43959. import { Ray } from "babylonjs/Culling/ray";
  43960. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43961. import { Collider } from "babylonjs/Collisions/collider";
  43962. module "babylonjs/scene" {
  43963. interface Scene {
  43964. /**
  43965. * @hidden
  43966. * Backing Filed
  43967. */
  43968. _selectionOctree: Octree<AbstractMesh>;
  43969. /**
  43970. * Gets the octree used to boost mesh selection (picking)
  43971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43972. */
  43973. selectionOctree: Octree<AbstractMesh>;
  43974. /**
  43975. * Creates or updates the octree used to boost selection (picking)
  43976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43977. * @param maxCapacity defines the maximum capacity per leaf
  43978. * @param maxDepth defines the maximum depth of the octree
  43979. * @returns an octree of AbstractMesh
  43980. */
  43981. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43982. }
  43983. }
  43984. module "babylonjs/Meshes/abstractMesh" {
  43985. interface AbstractMesh {
  43986. /**
  43987. * @hidden
  43988. * Backing Field
  43989. */
  43990. _submeshesOctree: Octree<SubMesh>;
  43991. /**
  43992. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43993. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43994. * @param maxCapacity defines the maximum size of each block (64 by default)
  43995. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43996. * @returns the new octree
  43997. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43999. */
  44000. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44001. }
  44002. }
  44003. /**
  44004. * Defines the octree scene component responsible to manage any octrees
  44005. * in a given scene.
  44006. */
  44007. export class OctreeSceneComponent {
  44008. /**
  44009. * The component name help to identify the component in the list of scene components.
  44010. */
  44011. readonly name: string;
  44012. /**
  44013. * The scene the component belongs to.
  44014. */
  44015. scene: Scene;
  44016. /**
  44017. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44018. */
  44019. readonly checksIsEnabled: boolean;
  44020. /**
  44021. * Creates a new instance of the component for the given scene
  44022. * @param scene Defines the scene to register the component in
  44023. */
  44024. constructor(scene: Scene);
  44025. /**
  44026. * Registers the component in a given scene
  44027. */
  44028. register(): void;
  44029. /**
  44030. * Return the list of active meshes
  44031. * @returns the list of active meshes
  44032. */
  44033. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44034. /**
  44035. * Return the list of active sub meshes
  44036. * @param mesh The mesh to get the candidates sub meshes from
  44037. * @returns the list of active sub meshes
  44038. */
  44039. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44040. private _tempRay;
  44041. /**
  44042. * Return the list of sub meshes intersecting with a given local ray
  44043. * @param mesh defines the mesh to find the submesh for
  44044. * @param localRay defines the ray in local space
  44045. * @returns the list of intersecting sub meshes
  44046. */
  44047. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44048. /**
  44049. * Return the list of sub meshes colliding with a collider
  44050. * @param mesh defines the mesh to find the submesh for
  44051. * @param collider defines the collider to evaluate the collision against
  44052. * @returns the list of colliding sub meshes
  44053. */
  44054. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44055. /**
  44056. * Rebuilds the elements related to this component in case of
  44057. * context lost for instance.
  44058. */
  44059. rebuild(): void;
  44060. /**
  44061. * Disposes the component and the associated ressources.
  44062. */
  44063. dispose(): void;
  44064. }
  44065. }
  44066. declare module "babylonjs/Culling/Octrees/index" {
  44067. export * from "babylonjs/Culling/Octrees/octree";
  44068. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44069. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44070. }
  44071. declare module "babylonjs/Culling/index" {
  44072. export * from "babylonjs/Culling/boundingBox";
  44073. export * from "babylonjs/Culling/boundingInfo";
  44074. export * from "babylonjs/Culling/boundingSphere";
  44075. export * from "babylonjs/Culling/Octrees/index";
  44076. export * from "babylonjs/Culling/ray";
  44077. }
  44078. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44079. import { IDisposable, Scene } from "babylonjs/scene";
  44080. import { Nullable } from "babylonjs/types";
  44081. import { Observable } from "babylonjs/Misc/observable";
  44082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44083. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44084. import { Camera } from "babylonjs/Cameras/camera";
  44085. /**
  44086. * Renders a layer on top of an existing scene
  44087. */
  44088. export class UtilityLayerRenderer implements IDisposable {
  44089. /** the original scene that will be rendered on top of */
  44090. originalScene: Scene;
  44091. private _pointerCaptures;
  44092. private _lastPointerEvents;
  44093. private static _DefaultUtilityLayer;
  44094. private static _DefaultKeepDepthUtilityLayer;
  44095. private _sharedGizmoLight;
  44096. private _renderCamera;
  44097. /**
  44098. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44099. * @returns the camera that is used when rendering the utility layer
  44100. */
  44101. getRenderCamera(): Nullable<Camera>;
  44102. /**
  44103. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44104. * @param cam the camera that should be used when rendering the utility layer
  44105. */
  44106. setRenderCamera(cam: Nullable<Camera>): void;
  44107. /**
  44108. * @hidden
  44109. * Light which used by gizmos to get light shading
  44110. */
  44111. _getSharedGizmoLight(): HemisphericLight;
  44112. /**
  44113. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44114. */
  44115. pickUtilitySceneFirst: boolean;
  44116. /**
  44117. * 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)
  44118. */
  44119. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44120. /**
  44121. * 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)
  44122. */
  44123. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44124. /**
  44125. * The scene that is rendered on top of the original scene
  44126. */
  44127. utilityLayerScene: Scene;
  44128. /**
  44129. * If the utility layer should automatically be rendered on top of existing scene
  44130. */
  44131. shouldRender: boolean;
  44132. /**
  44133. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44134. */
  44135. onlyCheckPointerDownEvents: boolean;
  44136. /**
  44137. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44138. */
  44139. processAllEvents: boolean;
  44140. /**
  44141. * Observable raised when the pointer move from the utility layer scene to the main scene
  44142. */
  44143. onPointerOutObservable: Observable<number>;
  44144. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44145. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44146. private _afterRenderObserver;
  44147. private _sceneDisposeObserver;
  44148. private _originalPointerObserver;
  44149. /**
  44150. * Instantiates a UtilityLayerRenderer
  44151. * @param originalScene the original scene that will be rendered on top of
  44152. * @param handleEvents boolean indicating if the utility layer should handle events
  44153. */
  44154. constructor(
  44155. /** the original scene that will be rendered on top of */
  44156. originalScene: Scene, handleEvents?: boolean);
  44157. private _notifyObservers;
  44158. /**
  44159. * Renders the utility layers scene on top of the original scene
  44160. */
  44161. render(): void;
  44162. /**
  44163. * Disposes of the renderer
  44164. */
  44165. dispose(): void;
  44166. private _updateCamera;
  44167. }
  44168. }
  44169. declare module "babylonjs/Gizmos/gizmo" {
  44170. import { Nullable } from "babylonjs/types";
  44171. import { IDisposable } from "babylonjs/scene";
  44172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44173. import { Mesh } from "babylonjs/Meshes/mesh";
  44174. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44175. /**
  44176. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44177. */
  44178. export class Gizmo implements IDisposable {
  44179. /** The utility layer the gizmo will be added to */
  44180. gizmoLayer: UtilityLayerRenderer;
  44181. /**
  44182. * The root mesh of the gizmo
  44183. */
  44184. _rootMesh: Mesh;
  44185. private _attachedMesh;
  44186. /**
  44187. * Ratio for the scale of the gizmo (Default: 1)
  44188. */
  44189. scaleRatio: number;
  44190. /**
  44191. * If a custom mesh has been set (Default: false)
  44192. */
  44193. protected _customMeshSet: boolean;
  44194. /**
  44195. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44196. * * When set, interactions will be enabled
  44197. */
  44198. attachedMesh: Nullable<AbstractMesh>;
  44199. /**
  44200. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44201. * @param mesh The mesh to replace the default mesh of the gizmo
  44202. */
  44203. setCustomMesh(mesh: Mesh): void;
  44204. /**
  44205. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44206. */
  44207. updateGizmoRotationToMatchAttachedMesh: boolean;
  44208. /**
  44209. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44210. */
  44211. updateGizmoPositionToMatchAttachedMesh: boolean;
  44212. /**
  44213. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44214. */
  44215. updateScale: boolean;
  44216. protected _interactionsEnabled: boolean;
  44217. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44218. private _beforeRenderObserver;
  44219. private _tempVector;
  44220. /**
  44221. * Creates a gizmo
  44222. * @param gizmoLayer The utility layer the gizmo will be added to
  44223. */
  44224. constructor(
  44225. /** The utility layer the gizmo will be added to */
  44226. gizmoLayer?: UtilityLayerRenderer);
  44227. /**
  44228. * Updates the gizmo to match the attached mesh's position/rotation
  44229. */
  44230. protected _update(): void;
  44231. /**
  44232. * Disposes of the gizmo
  44233. */
  44234. dispose(): void;
  44235. }
  44236. }
  44237. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44238. import { Observable } from "babylonjs/Misc/observable";
  44239. import { Nullable } from "babylonjs/types";
  44240. import { Vector3 } from "babylonjs/Maths/math.vector";
  44241. import { Color3 } from "babylonjs/Maths/math.color";
  44242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44244. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44245. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44246. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44247. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44248. import { Scene } from "babylonjs/scene";
  44249. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44250. /**
  44251. * Single plane drag gizmo
  44252. */
  44253. export class PlaneDragGizmo extends Gizmo {
  44254. /**
  44255. * Drag behavior responsible for the gizmos dragging interactions
  44256. */
  44257. dragBehavior: PointerDragBehavior;
  44258. private _pointerObserver;
  44259. /**
  44260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44261. */
  44262. snapDistance: number;
  44263. /**
  44264. * Event that fires each time the gizmo snaps to a new location.
  44265. * * snapDistance is the the change in distance
  44266. */
  44267. onSnapObservable: Observable<{
  44268. snapDistance: number;
  44269. }>;
  44270. private _plane;
  44271. private _coloredMaterial;
  44272. private _hoverMaterial;
  44273. private _isEnabled;
  44274. private _parent;
  44275. /** @hidden */
  44276. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44277. /** @hidden */
  44278. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44279. /**
  44280. * Creates a PlaneDragGizmo
  44281. * @param gizmoLayer The utility layer the gizmo will be added to
  44282. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44283. * @param color The color of the gizmo
  44284. */
  44285. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44286. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44287. /**
  44288. * If the gizmo is enabled
  44289. */
  44290. isEnabled: boolean;
  44291. /**
  44292. * Disposes of the gizmo
  44293. */
  44294. dispose(): void;
  44295. }
  44296. }
  44297. declare module "babylonjs/Gizmos/positionGizmo" {
  44298. import { Observable } from "babylonjs/Misc/observable";
  44299. import { Nullable } from "babylonjs/types";
  44300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44301. import { Mesh } from "babylonjs/Meshes/mesh";
  44302. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44303. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44304. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44305. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44306. /**
  44307. * Gizmo that enables dragging a mesh along 3 axis
  44308. */
  44309. export class PositionGizmo extends Gizmo {
  44310. /**
  44311. * Internal gizmo used for interactions on the x axis
  44312. */
  44313. xGizmo: AxisDragGizmo;
  44314. /**
  44315. * Internal gizmo used for interactions on the y axis
  44316. */
  44317. yGizmo: AxisDragGizmo;
  44318. /**
  44319. * Internal gizmo used for interactions on the z axis
  44320. */
  44321. zGizmo: AxisDragGizmo;
  44322. /**
  44323. * Internal gizmo used for interactions on the yz plane
  44324. */
  44325. xPlaneGizmo: PlaneDragGizmo;
  44326. /**
  44327. * Internal gizmo used for interactions on the xz plane
  44328. */
  44329. yPlaneGizmo: PlaneDragGizmo;
  44330. /**
  44331. * Internal gizmo used for interactions on the xy plane
  44332. */
  44333. zPlaneGizmo: PlaneDragGizmo;
  44334. /**
  44335. * private variables
  44336. */
  44337. private _meshAttached;
  44338. private _updateGizmoRotationToMatchAttachedMesh;
  44339. private _snapDistance;
  44340. private _scaleRatio;
  44341. /** Fires an event when any of it's sub gizmos are dragged */
  44342. onDragStartObservable: Observable<unknown>;
  44343. /** Fires an event when any of it's sub gizmos are released from dragging */
  44344. onDragEndObservable: Observable<unknown>;
  44345. /**
  44346. * If set to true, planar drag is enabled
  44347. */
  44348. private _planarGizmoEnabled;
  44349. attachedMesh: Nullable<AbstractMesh>;
  44350. /**
  44351. * Creates a PositionGizmo
  44352. * @param gizmoLayer The utility layer the gizmo will be added to
  44353. */
  44354. constructor(gizmoLayer?: UtilityLayerRenderer);
  44355. /**
  44356. * If the planar drag gizmo is enabled
  44357. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44358. */
  44359. planarGizmoEnabled: boolean;
  44360. updateGizmoRotationToMatchAttachedMesh: boolean;
  44361. /**
  44362. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44363. */
  44364. snapDistance: number;
  44365. /**
  44366. * Ratio for the scale of the gizmo (Default: 1)
  44367. */
  44368. scaleRatio: number;
  44369. /**
  44370. * Disposes of the gizmo
  44371. */
  44372. dispose(): void;
  44373. /**
  44374. * CustomMeshes are not supported by this gizmo
  44375. * @param mesh The mesh to replace the default mesh of the gizmo
  44376. */
  44377. setCustomMesh(mesh: Mesh): void;
  44378. }
  44379. }
  44380. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44381. import { Observable } from "babylonjs/Misc/observable";
  44382. import { Nullable } from "babylonjs/types";
  44383. import { Vector3 } from "babylonjs/Maths/math.vector";
  44384. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44386. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44387. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44388. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44389. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44390. import { Scene } from "babylonjs/scene";
  44391. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44392. import { Color3 } from "babylonjs/Maths/math.color";
  44393. /**
  44394. * Single axis drag gizmo
  44395. */
  44396. export class AxisDragGizmo extends Gizmo {
  44397. /**
  44398. * Drag behavior responsible for the gizmos dragging interactions
  44399. */
  44400. dragBehavior: PointerDragBehavior;
  44401. private _pointerObserver;
  44402. /**
  44403. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44404. */
  44405. snapDistance: number;
  44406. /**
  44407. * Event that fires each time the gizmo snaps to a new location.
  44408. * * snapDistance is the the change in distance
  44409. */
  44410. onSnapObservable: Observable<{
  44411. snapDistance: number;
  44412. }>;
  44413. private _isEnabled;
  44414. private _parent;
  44415. private _arrow;
  44416. private _coloredMaterial;
  44417. private _hoverMaterial;
  44418. /** @hidden */
  44419. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44420. /** @hidden */
  44421. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44422. /**
  44423. * Creates an AxisDragGizmo
  44424. * @param gizmoLayer The utility layer the gizmo will be added to
  44425. * @param dragAxis The axis which the gizmo will be able to drag on
  44426. * @param color The color of the gizmo
  44427. */
  44428. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44429. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44430. /**
  44431. * If the gizmo is enabled
  44432. */
  44433. isEnabled: boolean;
  44434. /**
  44435. * Disposes of the gizmo
  44436. */
  44437. dispose(): void;
  44438. }
  44439. }
  44440. declare module "babylonjs/Debug/axesViewer" {
  44441. import { Vector3 } from "babylonjs/Maths/math.vector";
  44442. import { Nullable } from "babylonjs/types";
  44443. import { Scene } from "babylonjs/scene";
  44444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44445. /**
  44446. * The Axes viewer will show 3 axes in a specific point in space
  44447. */
  44448. export class AxesViewer {
  44449. private _xAxis;
  44450. private _yAxis;
  44451. private _zAxis;
  44452. private _scaleLinesFactor;
  44453. private _instanced;
  44454. /**
  44455. * Gets the hosting scene
  44456. */
  44457. scene: Scene;
  44458. /**
  44459. * Gets or sets a number used to scale line length
  44460. */
  44461. scaleLines: number;
  44462. /** Gets the node hierarchy used to render x-axis */
  44463. readonly xAxis: TransformNode;
  44464. /** Gets the node hierarchy used to render y-axis */
  44465. readonly yAxis: TransformNode;
  44466. /** Gets the node hierarchy used to render z-axis */
  44467. readonly zAxis: TransformNode;
  44468. /**
  44469. * Creates a new AxesViewer
  44470. * @param scene defines the hosting scene
  44471. * @param scaleLines defines a number used to scale line length (1 by default)
  44472. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44473. * @param xAxis defines the node hierarchy used to render the x-axis
  44474. * @param yAxis defines the node hierarchy used to render the y-axis
  44475. * @param zAxis defines the node hierarchy used to render the z-axis
  44476. */
  44477. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44478. /**
  44479. * Force the viewer to update
  44480. * @param position defines the position of the viewer
  44481. * @param xaxis defines the x axis of the viewer
  44482. * @param yaxis defines the y axis of the viewer
  44483. * @param zaxis defines the z axis of the viewer
  44484. */
  44485. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44486. /**
  44487. * Creates an instance of this axes viewer.
  44488. * @returns a new axes viewer with instanced meshes
  44489. */
  44490. createInstance(): AxesViewer;
  44491. /** Releases resources */
  44492. dispose(): void;
  44493. private static _SetRenderingGroupId;
  44494. }
  44495. }
  44496. declare module "babylonjs/Debug/boneAxesViewer" {
  44497. import { Nullable } from "babylonjs/types";
  44498. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44499. import { Vector3 } from "babylonjs/Maths/math.vector";
  44500. import { Mesh } from "babylonjs/Meshes/mesh";
  44501. import { Bone } from "babylonjs/Bones/bone";
  44502. import { Scene } from "babylonjs/scene";
  44503. /**
  44504. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44505. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44506. */
  44507. export class BoneAxesViewer extends AxesViewer {
  44508. /**
  44509. * Gets or sets the target mesh where to display the axes viewer
  44510. */
  44511. mesh: Nullable<Mesh>;
  44512. /**
  44513. * Gets or sets the target bone where to display the axes viewer
  44514. */
  44515. bone: Nullable<Bone>;
  44516. /** Gets current position */
  44517. pos: Vector3;
  44518. /** Gets direction of X axis */
  44519. xaxis: Vector3;
  44520. /** Gets direction of Y axis */
  44521. yaxis: Vector3;
  44522. /** Gets direction of Z axis */
  44523. zaxis: Vector3;
  44524. /**
  44525. * Creates a new BoneAxesViewer
  44526. * @param scene defines the hosting scene
  44527. * @param bone defines the target bone
  44528. * @param mesh defines the target mesh
  44529. * @param scaleLines defines a scaling factor for line length (1 by default)
  44530. */
  44531. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44532. /**
  44533. * Force the viewer to update
  44534. */
  44535. update(): void;
  44536. /** Releases resources */
  44537. dispose(): void;
  44538. }
  44539. }
  44540. declare module "babylonjs/Debug/debugLayer" {
  44541. import { Scene } from "babylonjs/scene";
  44542. /**
  44543. * Interface used to define scene explorer extensibility option
  44544. */
  44545. export interface IExplorerExtensibilityOption {
  44546. /**
  44547. * Define the option label
  44548. */
  44549. label: string;
  44550. /**
  44551. * Defines the action to execute on click
  44552. */
  44553. action: (entity: any) => void;
  44554. }
  44555. /**
  44556. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44557. */
  44558. export interface IExplorerExtensibilityGroup {
  44559. /**
  44560. * Defines a predicate to test if a given type mut be extended
  44561. */
  44562. predicate: (entity: any) => boolean;
  44563. /**
  44564. * Gets the list of options added to a type
  44565. */
  44566. entries: IExplorerExtensibilityOption[];
  44567. }
  44568. /**
  44569. * Interface used to define the options to use to create the Inspector
  44570. */
  44571. export interface IInspectorOptions {
  44572. /**
  44573. * Display in overlay mode (default: false)
  44574. */
  44575. overlay?: boolean;
  44576. /**
  44577. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44578. */
  44579. globalRoot?: HTMLElement;
  44580. /**
  44581. * Display the Scene explorer
  44582. */
  44583. showExplorer?: boolean;
  44584. /**
  44585. * Display the property inspector
  44586. */
  44587. showInspector?: boolean;
  44588. /**
  44589. * Display in embed mode (both panes on the right)
  44590. */
  44591. embedMode?: boolean;
  44592. /**
  44593. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44594. */
  44595. handleResize?: boolean;
  44596. /**
  44597. * Allow the panes to popup (default: true)
  44598. */
  44599. enablePopup?: boolean;
  44600. /**
  44601. * Allow the panes to be closed by users (default: true)
  44602. */
  44603. enableClose?: boolean;
  44604. /**
  44605. * Optional list of extensibility entries
  44606. */
  44607. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44608. /**
  44609. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44610. */
  44611. inspectorURL?: string;
  44612. }
  44613. module "babylonjs/scene" {
  44614. interface Scene {
  44615. /**
  44616. * @hidden
  44617. * Backing field
  44618. */
  44619. _debugLayer: DebugLayer;
  44620. /**
  44621. * Gets the debug layer (aka Inspector) associated with the scene
  44622. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44623. */
  44624. debugLayer: DebugLayer;
  44625. }
  44626. }
  44627. /**
  44628. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44629. * what is happening in your scene
  44630. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44631. */
  44632. export class DebugLayer {
  44633. /**
  44634. * Define the url to get the inspector script from.
  44635. * By default it uses the babylonjs CDN.
  44636. * @ignoreNaming
  44637. */
  44638. static InspectorURL: string;
  44639. private _scene;
  44640. private BJSINSPECTOR;
  44641. private _onPropertyChangedObservable?;
  44642. /**
  44643. * Observable triggered when a property is changed through the inspector.
  44644. */
  44645. readonly onPropertyChangedObservable: any;
  44646. /**
  44647. * Instantiates a new debug layer.
  44648. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44649. * what is happening in your scene
  44650. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44651. * @param scene Defines the scene to inspect
  44652. */
  44653. constructor(scene: Scene);
  44654. /** Creates the inspector window. */
  44655. private _createInspector;
  44656. /**
  44657. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44658. * @param entity defines the entity to select
  44659. * @param lineContainerTitle defines the specific block to highlight
  44660. */
  44661. select(entity: any, lineContainerTitle?: string): void;
  44662. /** Get the inspector from bundle or global */
  44663. private _getGlobalInspector;
  44664. /**
  44665. * Get if the inspector is visible or not.
  44666. * @returns true if visible otherwise, false
  44667. */
  44668. isVisible(): boolean;
  44669. /**
  44670. * Hide the inspector and close its window.
  44671. */
  44672. hide(): void;
  44673. /**
  44674. * Launch the debugLayer.
  44675. * @param config Define the configuration of the inspector
  44676. * @return a promise fulfilled when the debug layer is visible
  44677. */
  44678. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44679. }
  44680. }
  44681. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44682. import { Nullable } from "babylonjs/types";
  44683. import { Scene } from "babylonjs/scene";
  44684. import { Vector4 } from "babylonjs/Maths/math.vector";
  44685. import { Color4 } from "babylonjs/Maths/math.color";
  44686. import { Mesh } from "babylonjs/Meshes/mesh";
  44687. /**
  44688. * Class containing static functions to help procedurally build meshes
  44689. */
  44690. export class BoxBuilder {
  44691. /**
  44692. * Creates a box mesh
  44693. * * The parameter `size` sets the size (float) of each box side (default 1)
  44694. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44695. * * 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)
  44696. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44700. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44701. * @param name defines the name of the mesh
  44702. * @param options defines the options used to create the mesh
  44703. * @param scene defines the hosting scene
  44704. * @returns the box mesh
  44705. */
  44706. static CreateBox(name: string, options: {
  44707. size?: number;
  44708. width?: number;
  44709. height?: number;
  44710. depth?: number;
  44711. faceUV?: Vector4[];
  44712. faceColors?: Color4[];
  44713. sideOrientation?: number;
  44714. frontUVs?: Vector4;
  44715. backUVs?: Vector4;
  44716. wrap?: boolean;
  44717. topBaseAt?: number;
  44718. bottomBaseAt?: number;
  44719. updatable?: boolean;
  44720. }, scene?: Nullable<Scene>): Mesh;
  44721. }
  44722. }
  44723. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44724. import { Vector4 } from "babylonjs/Maths/math.vector";
  44725. import { Mesh } from "babylonjs/Meshes/mesh";
  44726. import { Scene } from "babylonjs/scene";
  44727. import { Nullable } from "babylonjs/types";
  44728. /**
  44729. * Class containing static functions to help procedurally build meshes
  44730. */
  44731. export class SphereBuilder {
  44732. /**
  44733. * Creates a sphere mesh
  44734. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44735. * * 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`)
  44736. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44737. * * 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
  44738. * * 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)
  44739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44742. * @param name defines the name of the mesh
  44743. * @param options defines the options used to create the mesh
  44744. * @param scene defines the hosting scene
  44745. * @returns the sphere mesh
  44746. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44747. */
  44748. static CreateSphere(name: string, options: {
  44749. segments?: number;
  44750. diameter?: number;
  44751. diameterX?: number;
  44752. diameterY?: number;
  44753. diameterZ?: number;
  44754. arc?: number;
  44755. slice?: number;
  44756. sideOrientation?: number;
  44757. frontUVs?: Vector4;
  44758. backUVs?: Vector4;
  44759. updatable?: boolean;
  44760. }, scene?: Nullable<Scene>): Mesh;
  44761. }
  44762. }
  44763. declare module "babylonjs/Debug/physicsViewer" {
  44764. import { Nullable } from "babylonjs/types";
  44765. import { Scene } from "babylonjs/scene";
  44766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44767. import { Mesh } from "babylonjs/Meshes/mesh";
  44768. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44769. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44770. /**
  44771. * Used to show the physics impostor around the specific mesh
  44772. */
  44773. export class PhysicsViewer {
  44774. /** @hidden */
  44775. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44776. /** @hidden */
  44777. protected _meshes: Array<Nullable<AbstractMesh>>;
  44778. /** @hidden */
  44779. protected _scene: Nullable<Scene>;
  44780. /** @hidden */
  44781. protected _numMeshes: number;
  44782. /** @hidden */
  44783. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44784. private _renderFunction;
  44785. private _utilityLayer;
  44786. private _debugBoxMesh;
  44787. private _debugSphereMesh;
  44788. private _debugCylinderMesh;
  44789. private _debugMaterial;
  44790. private _debugMeshMeshes;
  44791. /**
  44792. * Creates a new PhysicsViewer
  44793. * @param scene defines the hosting scene
  44794. */
  44795. constructor(scene: Scene);
  44796. /** @hidden */
  44797. protected _updateDebugMeshes(): void;
  44798. /**
  44799. * Renders a specified physic impostor
  44800. * @param impostor defines the impostor to render
  44801. * @param targetMesh defines the mesh represented by the impostor
  44802. * @returns the new debug mesh used to render the impostor
  44803. */
  44804. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44805. /**
  44806. * Hides a specified physic impostor
  44807. * @param impostor defines the impostor to hide
  44808. */
  44809. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44810. private _getDebugMaterial;
  44811. private _getDebugBoxMesh;
  44812. private _getDebugSphereMesh;
  44813. private _getDebugCylinderMesh;
  44814. private _getDebugMeshMesh;
  44815. private _getDebugMesh;
  44816. /** Releases all resources */
  44817. dispose(): void;
  44818. }
  44819. }
  44820. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44821. import { Vector3 } from "babylonjs/Maths/math.vector";
  44822. import { Color4 } from "babylonjs/Maths/math.color";
  44823. import { Nullable } from "babylonjs/types";
  44824. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44825. import { Scene } from "babylonjs/scene";
  44826. /**
  44827. * Class containing static functions to help procedurally build meshes
  44828. */
  44829. export class LinesBuilder {
  44830. /**
  44831. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44832. * * 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
  44833. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44834. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44835. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44836. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44837. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44838. * * 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
  44839. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44842. * @param name defines the name of the new line system
  44843. * @param options defines the options used to create the line system
  44844. * @param scene defines the hosting scene
  44845. * @returns a new line system mesh
  44846. */
  44847. static CreateLineSystem(name: string, options: {
  44848. lines: Vector3[][];
  44849. updatable?: boolean;
  44850. instance?: Nullable<LinesMesh>;
  44851. colors?: Nullable<Color4[][]>;
  44852. useVertexAlpha?: boolean;
  44853. }, scene: Nullable<Scene>): LinesMesh;
  44854. /**
  44855. * Creates a line mesh
  44856. * 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
  44857. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44858. * * The parameter `points` is an array successive Vector3
  44859. * * 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
  44860. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44861. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44862. * * When updating an instance, remember that only point positions can change, not the number of points
  44863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44865. * @param name defines the name of the new line system
  44866. * @param options defines the options used to create the line system
  44867. * @param scene defines the hosting scene
  44868. * @returns a new line mesh
  44869. */
  44870. static CreateLines(name: string, options: {
  44871. points: Vector3[];
  44872. updatable?: boolean;
  44873. instance?: Nullable<LinesMesh>;
  44874. colors?: Color4[];
  44875. useVertexAlpha?: boolean;
  44876. }, scene?: Nullable<Scene>): LinesMesh;
  44877. /**
  44878. * Creates a dashed line mesh
  44879. * * 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
  44880. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44881. * * The parameter `points` is an array successive Vector3
  44882. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44883. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44884. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44885. * * 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
  44886. * * When updating an instance, remember that only point positions can change, not the number of points
  44887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44888. * @param name defines the name of the mesh
  44889. * @param options defines the options used to create the mesh
  44890. * @param scene defines the hosting scene
  44891. * @returns the dashed line mesh
  44892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44893. */
  44894. static CreateDashedLines(name: string, options: {
  44895. points: Vector3[];
  44896. dashSize?: number;
  44897. gapSize?: number;
  44898. dashNb?: number;
  44899. updatable?: boolean;
  44900. instance?: LinesMesh;
  44901. }, scene?: Nullable<Scene>): LinesMesh;
  44902. }
  44903. }
  44904. declare module "babylonjs/Debug/rayHelper" {
  44905. import { Nullable } from "babylonjs/types";
  44906. import { Ray } from "babylonjs/Culling/ray";
  44907. import { Vector3 } from "babylonjs/Maths/math.vector";
  44908. import { Color3 } from "babylonjs/Maths/math.color";
  44909. import { Scene } from "babylonjs/scene";
  44910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44911. import "babylonjs/Meshes/Builders/linesBuilder";
  44912. /**
  44913. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44914. * in order to better appreciate the issue one might have.
  44915. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44916. */
  44917. export class RayHelper {
  44918. /**
  44919. * Defines the ray we are currently tryin to visualize.
  44920. */
  44921. ray: Nullable<Ray>;
  44922. private _renderPoints;
  44923. private _renderLine;
  44924. private _renderFunction;
  44925. private _scene;
  44926. private _updateToMeshFunction;
  44927. private _attachedToMesh;
  44928. private _meshSpaceDirection;
  44929. private _meshSpaceOrigin;
  44930. /**
  44931. * Helper function to create a colored helper in a scene in one line.
  44932. * @param ray Defines the ray we are currently tryin to visualize
  44933. * @param scene Defines the scene the ray is used in
  44934. * @param color Defines the color we want to see the ray in
  44935. * @returns The newly created ray helper.
  44936. */
  44937. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44938. /**
  44939. * Instantiate a new ray helper.
  44940. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44941. * in order to better appreciate the issue one might have.
  44942. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44943. * @param ray Defines the ray we are currently tryin to visualize
  44944. */
  44945. constructor(ray: Ray);
  44946. /**
  44947. * Shows the ray we are willing to debug.
  44948. * @param scene Defines the scene the ray needs to be rendered in
  44949. * @param color Defines the color the ray needs to be rendered in
  44950. */
  44951. show(scene: Scene, color?: Color3): void;
  44952. /**
  44953. * Hides the ray we are debugging.
  44954. */
  44955. hide(): void;
  44956. private _render;
  44957. /**
  44958. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44959. * @param mesh Defines the mesh we want the helper attached to
  44960. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44961. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44962. * @param length Defines the length of the ray
  44963. */
  44964. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44965. /**
  44966. * Detach the ray helper from the mesh it has previously been attached to.
  44967. */
  44968. detachFromMesh(): void;
  44969. private _updateToMesh;
  44970. /**
  44971. * Dispose the helper and release its associated resources.
  44972. */
  44973. dispose(): void;
  44974. }
  44975. }
  44976. declare module "babylonjs/Debug/skeletonViewer" {
  44977. import { Color3 } from "babylonjs/Maths/math.color";
  44978. import { Scene } from "babylonjs/scene";
  44979. import { Nullable } from "babylonjs/types";
  44980. import { Skeleton } from "babylonjs/Bones/skeleton";
  44981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44982. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44983. /**
  44984. * Class used to render a debug view of a given skeleton
  44985. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44986. */
  44987. export class SkeletonViewer {
  44988. /** defines the skeleton to render */
  44989. skeleton: Skeleton;
  44990. /** defines the mesh attached to the skeleton */
  44991. mesh: AbstractMesh;
  44992. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44993. autoUpdateBonesMatrices: boolean;
  44994. /** defines the rendering group id to use with the viewer */
  44995. renderingGroupId: number;
  44996. /** Gets or sets the color used to render the skeleton */
  44997. color: Color3;
  44998. private _scene;
  44999. private _debugLines;
  45000. private _debugMesh;
  45001. private _isEnabled;
  45002. private _renderFunction;
  45003. private _utilityLayer;
  45004. /**
  45005. * Returns the mesh used to render the bones
  45006. */
  45007. readonly debugMesh: Nullable<LinesMesh>;
  45008. /**
  45009. * Creates a new SkeletonViewer
  45010. * @param skeleton defines the skeleton to render
  45011. * @param mesh defines the mesh attached to the skeleton
  45012. * @param scene defines the hosting scene
  45013. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45014. * @param renderingGroupId defines the rendering group id to use with the viewer
  45015. */
  45016. constructor(
  45017. /** defines the skeleton to render */
  45018. skeleton: Skeleton,
  45019. /** defines the mesh attached to the skeleton */
  45020. mesh: AbstractMesh, scene: Scene,
  45021. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45022. autoUpdateBonesMatrices?: boolean,
  45023. /** defines the rendering group id to use with the viewer */
  45024. renderingGroupId?: number);
  45025. /** Gets or sets a boolean indicating if the viewer is enabled */
  45026. isEnabled: boolean;
  45027. private _getBonePosition;
  45028. private _getLinesForBonesWithLength;
  45029. private _getLinesForBonesNoLength;
  45030. /** Update the viewer to sync with current skeleton state */
  45031. update(): void;
  45032. /** Release associated resources */
  45033. dispose(): void;
  45034. }
  45035. }
  45036. declare module "babylonjs/Debug/index" {
  45037. export * from "babylonjs/Debug/axesViewer";
  45038. export * from "babylonjs/Debug/boneAxesViewer";
  45039. export * from "babylonjs/Debug/debugLayer";
  45040. export * from "babylonjs/Debug/physicsViewer";
  45041. export * from "babylonjs/Debug/rayHelper";
  45042. export * from "babylonjs/Debug/skeletonViewer";
  45043. }
  45044. declare module "babylonjs/Engines/nullEngine" {
  45045. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45046. import { Scene } from "babylonjs/scene";
  45047. import { Engine } from "babylonjs/Engines/engine";
  45048. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45049. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45051. import { Effect } from "babylonjs/Materials/effect";
  45052. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45053. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45054. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45055. /**
  45056. * Options to create the null engine
  45057. */
  45058. export class NullEngineOptions {
  45059. /**
  45060. * Render width (Default: 512)
  45061. */
  45062. renderWidth: number;
  45063. /**
  45064. * Render height (Default: 256)
  45065. */
  45066. renderHeight: number;
  45067. /**
  45068. * Texture size (Default: 512)
  45069. */
  45070. textureSize: number;
  45071. /**
  45072. * If delta time between frames should be constant
  45073. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45074. */
  45075. deterministicLockstep: boolean;
  45076. /**
  45077. * Maximum about of steps between frames (Default: 4)
  45078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45079. */
  45080. lockstepMaxSteps: number;
  45081. }
  45082. /**
  45083. * The null engine class provides support for headless version of babylon.js.
  45084. * This can be used in server side scenario or for testing purposes
  45085. */
  45086. export class NullEngine extends Engine {
  45087. private _options;
  45088. /**
  45089. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45090. */
  45091. isDeterministicLockStep(): boolean;
  45092. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45093. getLockstepMaxSteps(): number;
  45094. /**
  45095. * Sets hardware scaling, used to save performance if needed
  45096. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45097. */
  45098. getHardwareScalingLevel(): number;
  45099. constructor(options?: NullEngineOptions);
  45100. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45101. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45102. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45103. getRenderWidth(useScreen?: boolean): number;
  45104. getRenderHeight(useScreen?: boolean): number;
  45105. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45106. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45107. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45108. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45109. bindSamplers(effect: Effect): void;
  45110. enableEffect(effect: Effect): void;
  45111. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45112. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45113. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45114. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45115. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45116. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45117. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45118. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45119. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45120. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45121. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45122. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45123. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45124. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45125. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45126. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45127. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45128. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45129. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45130. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45131. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45132. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45133. bindBuffers(vertexBuffers: {
  45134. [key: string]: VertexBuffer;
  45135. }, indexBuffer: DataBuffer, effect: Effect): void;
  45136. wipeCaches(bruteForce?: boolean): void;
  45137. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45138. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45139. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45140. /** @hidden */
  45141. _createTexture(): WebGLTexture;
  45142. /** @hidden */
  45143. _releaseTexture(texture: InternalTexture): void;
  45144. 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;
  45145. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45146. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45147. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45148. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45149. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45150. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45151. areAllEffectsReady(): boolean;
  45152. /**
  45153. * @hidden
  45154. * Get the current error code of the webGL context
  45155. * @returns the error code
  45156. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45157. */
  45158. getError(): number;
  45159. /** @hidden */
  45160. _getUnpackAlignement(): number;
  45161. /** @hidden */
  45162. _unpackFlipY(value: boolean): void;
  45163. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45164. /**
  45165. * Updates a dynamic vertex buffer.
  45166. * @param vertexBuffer the vertex buffer to update
  45167. * @param data the data used to update the vertex buffer
  45168. * @param byteOffset the byte offset of the data (optional)
  45169. * @param byteLength the byte length of the data (optional)
  45170. */
  45171. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45172. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45173. /** @hidden */
  45174. _bindTexture(channel: number, texture: InternalTexture): void;
  45175. /** @hidden */
  45176. _releaseBuffer(buffer: DataBuffer): boolean;
  45177. releaseEffects(): void;
  45178. displayLoadingUI(): void;
  45179. hideLoadingUI(): void;
  45180. /** @hidden */
  45181. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45182. /** @hidden */
  45183. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45184. /** @hidden */
  45185. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45186. /** @hidden */
  45187. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45188. }
  45189. }
  45190. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45191. import { Nullable, int } from "babylonjs/types";
  45192. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45193. /** @hidden */
  45194. export class _OcclusionDataStorage {
  45195. /** @hidden */
  45196. occlusionInternalRetryCounter: number;
  45197. /** @hidden */
  45198. isOcclusionQueryInProgress: boolean;
  45199. /** @hidden */
  45200. isOccluded: boolean;
  45201. /** @hidden */
  45202. occlusionRetryCount: number;
  45203. /** @hidden */
  45204. occlusionType: number;
  45205. /** @hidden */
  45206. occlusionQueryAlgorithmType: number;
  45207. }
  45208. module "babylonjs/Engines/engine" {
  45209. interface Engine {
  45210. /**
  45211. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45212. * @return the new query
  45213. */
  45214. createQuery(): WebGLQuery;
  45215. /**
  45216. * Delete and release a webGL query
  45217. * @param query defines the query to delete
  45218. * @return the current engine
  45219. */
  45220. deleteQuery(query: WebGLQuery): Engine;
  45221. /**
  45222. * Check if a given query has resolved and got its value
  45223. * @param query defines the query to check
  45224. * @returns true if the query got its value
  45225. */
  45226. isQueryResultAvailable(query: WebGLQuery): boolean;
  45227. /**
  45228. * Gets the value of a given query
  45229. * @param query defines the query to check
  45230. * @returns the value of the query
  45231. */
  45232. getQueryResult(query: WebGLQuery): number;
  45233. /**
  45234. * Initiates an occlusion query
  45235. * @param algorithmType defines the algorithm to use
  45236. * @param query defines the query to use
  45237. * @returns the current engine
  45238. * @see http://doc.babylonjs.com/features/occlusionquery
  45239. */
  45240. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45241. /**
  45242. * Ends an occlusion query
  45243. * @see http://doc.babylonjs.com/features/occlusionquery
  45244. * @param algorithmType defines the algorithm to use
  45245. * @returns the current engine
  45246. */
  45247. endOcclusionQuery(algorithmType: number): Engine;
  45248. /**
  45249. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45250. * Please note that only one query can be issued at a time
  45251. * @returns a time token used to track the time span
  45252. */
  45253. startTimeQuery(): Nullable<_TimeToken>;
  45254. /**
  45255. * Ends a time query
  45256. * @param token defines the token used to measure the time span
  45257. * @returns the time spent (in ns)
  45258. */
  45259. endTimeQuery(token: _TimeToken): int;
  45260. /** @hidden */
  45261. _currentNonTimestampToken: Nullable<_TimeToken>;
  45262. /** @hidden */
  45263. _createTimeQuery(): WebGLQuery;
  45264. /** @hidden */
  45265. _deleteTimeQuery(query: WebGLQuery): void;
  45266. /** @hidden */
  45267. _getGlAlgorithmType(algorithmType: number): number;
  45268. /** @hidden */
  45269. _getTimeQueryResult(query: WebGLQuery): any;
  45270. /** @hidden */
  45271. _getTimeQueryAvailability(query: WebGLQuery): any;
  45272. }
  45273. }
  45274. module "babylonjs/Meshes/abstractMesh" {
  45275. interface AbstractMesh {
  45276. /**
  45277. * Backing filed
  45278. * @hidden
  45279. */
  45280. __occlusionDataStorage: _OcclusionDataStorage;
  45281. /**
  45282. * Access property
  45283. * @hidden
  45284. */
  45285. _occlusionDataStorage: _OcclusionDataStorage;
  45286. /**
  45287. * 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.
  45288. * The default value is -1 which means don't break the query and wait till the result
  45289. * @see http://doc.babylonjs.com/features/occlusionquery
  45290. */
  45291. occlusionRetryCount: number;
  45292. /**
  45293. * 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:
  45294. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45295. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45296. * * 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.
  45297. * @see http://doc.babylonjs.com/features/occlusionquery
  45298. */
  45299. occlusionType: number;
  45300. /**
  45301. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45302. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45303. * * 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.
  45304. * @see http://doc.babylonjs.com/features/occlusionquery
  45305. */
  45306. occlusionQueryAlgorithmType: number;
  45307. /**
  45308. * 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
  45309. * @see http://doc.babylonjs.com/features/occlusionquery
  45310. */
  45311. isOccluded: boolean;
  45312. /**
  45313. * Flag to check the progress status of the query
  45314. * @see http://doc.babylonjs.com/features/occlusionquery
  45315. */
  45316. isOcclusionQueryInProgress: boolean;
  45317. }
  45318. }
  45319. }
  45320. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45321. import { Nullable } from "babylonjs/types";
  45322. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45323. /** @hidden */
  45324. export var _forceTransformFeedbackToBundle: boolean;
  45325. module "babylonjs/Engines/engine" {
  45326. interface Engine {
  45327. /**
  45328. * Creates a webGL transform feedback object
  45329. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45330. * @returns the webGL transform feedback object
  45331. */
  45332. createTransformFeedback(): WebGLTransformFeedback;
  45333. /**
  45334. * Delete a webGL transform feedback object
  45335. * @param value defines the webGL transform feedback object to delete
  45336. */
  45337. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45338. /**
  45339. * Bind a webGL transform feedback object to the webgl context
  45340. * @param value defines the webGL transform feedback object to bind
  45341. */
  45342. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45343. /**
  45344. * Begins a transform feedback operation
  45345. * @param usePoints defines if points or triangles must be used
  45346. */
  45347. beginTransformFeedback(usePoints: boolean): void;
  45348. /**
  45349. * Ends a transform feedback operation
  45350. */
  45351. endTransformFeedback(): void;
  45352. /**
  45353. * Specify the varyings to use with transform feedback
  45354. * @param program defines the associated webGL program
  45355. * @param value defines the list of strings representing the varying names
  45356. */
  45357. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45358. /**
  45359. * Bind a webGL buffer for a transform feedback operation
  45360. * @param value defines the webGL buffer to bind
  45361. */
  45362. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45363. }
  45364. }
  45365. }
  45366. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45367. import { Scene } from "babylonjs/scene";
  45368. import { Engine } from "babylonjs/Engines/engine";
  45369. import { Texture } from "babylonjs/Materials/Textures/texture";
  45370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45371. import "babylonjs/Engines/Extensions/engine.multiRender";
  45372. /**
  45373. * Creation options of the multi render target texture.
  45374. */
  45375. export interface IMultiRenderTargetOptions {
  45376. /**
  45377. * Define if the texture needs to create mip maps after render.
  45378. */
  45379. generateMipMaps?: boolean;
  45380. /**
  45381. * Define the types of all the draw buffers we want to create
  45382. */
  45383. types?: number[];
  45384. /**
  45385. * Define the sampling modes of all the draw buffers we want to create
  45386. */
  45387. samplingModes?: number[];
  45388. /**
  45389. * Define if a depth buffer is required
  45390. */
  45391. generateDepthBuffer?: boolean;
  45392. /**
  45393. * Define if a stencil buffer is required
  45394. */
  45395. generateStencilBuffer?: boolean;
  45396. /**
  45397. * Define if a depth texture is required instead of a depth buffer
  45398. */
  45399. generateDepthTexture?: boolean;
  45400. /**
  45401. * Define the number of desired draw buffers
  45402. */
  45403. textureCount?: number;
  45404. /**
  45405. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45406. */
  45407. doNotChangeAspectRatio?: boolean;
  45408. /**
  45409. * Define the default type of the buffers we are creating
  45410. */
  45411. defaultType?: number;
  45412. }
  45413. /**
  45414. * A multi render target, like a render target provides the ability to render to a texture.
  45415. * Unlike the render target, it can render to several draw buffers in one draw.
  45416. * This is specially interesting in deferred rendering or for any effects requiring more than
  45417. * just one color from a single pass.
  45418. */
  45419. export class MultiRenderTarget extends RenderTargetTexture {
  45420. private _internalTextures;
  45421. private _textures;
  45422. private _multiRenderTargetOptions;
  45423. /**
  45424. * Get if draw buffers are currently supported by the used hardware and browser.
  45425. */
  45426. readonly isSupported: boolean;
  45427. /**
  45428. * Get the list of textures generated by the multi render target.
  45429. */
  45430. readonly textures: Texture[];
  45431. /**
  45432. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45433. */
  45434. readonly depthTexture: Texture;
  45435. /**
  45436. * Set the wrapping mode on U of all the textures we are rendering to.
  45437. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45438. */
  45439. wrapU: number;
  45440. /**
  45441. * Set the wrapping mode on V of all the textures we are rendering to.
  45442. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45443. */
  45444. wrapV: number;
  45445. /**
  45446. * Instantiate a new multi render target texture.
  45447. * A multi render target, like a render target provides the ability to render to a texture.
  45448. * Unlike the render target, it can render to several draw buffers in one draw.
  45449. * This is specially interesting in deferred rendering or for any effects requiring more than
  45450. * just one color from a single pass.
  45451. * @param name Define the name of the texture
  45452. * @param size Define the size of the buffers to render to
  45453. * @param count Define the number of target we are rendering into
  45454. * @param scene Define the scene the texture belongs to
  45455. * @param options Define the options used to create the multi render target
  45456. */
  45457. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45458. /** @hidden */
  45459. _rebuild(): void;
  45460. private _createInternalTextures;
  45461. private _createTextures;
  45462. /**
  45463. * Define the number of samples used if MSAA is enabled.
  45464. */
  45465. samples: number;
  45466. /**
  45467. * Resize all the textures in the multi render target.
  45468. * Be carrefull as it will recreate all the data in the new texture.
  45469. * @param size Define the new size
  45470. */
  45471. resize(size: any): void;
  45472. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45473. /**
  45474. * Dispose the render targets and their associated resources
  45475. */
  45476. dispose(): void;
  45477. /**
  45478. * Release all the underlying texture used as draw buffers.
  45479. */
  45480. releaseInternalTextures(): void;
  45481. }
  45482. }
  45483. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45485. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45486. import { Nullable } from "babylonjs/types";
  45487. module "babylonjs/Engines/engine" {
  45488. interface Engine {
  45489. /**
  45490. * Unbind a list of render target textures from the webGL context
  45491. * This is used only when drawBuffer extension or webGL2 are active
  45492. * @param textures defines the render target textures to unbind
  45493. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45494. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45495. */
  45496. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45497. /**
  45498. * Create a multi render target texture
  45499. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45500. * @param size defines the size of the texture
  45501. * @param options defines the creation options
  45502. * @returns the cube texture as an InternalTexture
  45503. */
  45504. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45505. /**
  45506. * Update the sample count for a given multiple render target texture
  45507. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45508. * @param textures defines the textures to update
  45509. * @param samples defines the sample count to set
  45510. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45511. */
  45512. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45513. }
  45514. }
  45515. }
  45516. declare module "babylonjs/Engines/Extensions/index" {
  45517. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45518. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45519. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45520. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45521. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45522. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45523. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45524. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45525. }
  45526. declare module "babylonjs/Engines/index" {
  45527. export * from "babylonjs/Engines/constants";
  45528. export * from "babylonjs/Engines/engine";
  45529. export * from "babylonjs/Engines/engineStore";
  45530. export * from "babylonjs/Engines/nullEngine";
  45531. export * from "babylonjs/Engines/Extensions/index";
  45532. export * from "babylonjs/Engines/IPipelineContext";
  45533. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45534. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45535. }
  45536. declare module "babylonjs/Events/clipboardEvents" {
  45537. /**
  45538. * Gather the list of clipboard event types as constants.
  45539. */
  45540. export class ClipboardEventTypes {
  45541. /**
  45542. * The clipboard event is fired when a copy command is active (pressed).
  45543. */
  45544. static readonly COPY: number;
  45545. /**
  45546. * The clipboard event is fired when a cut command is active (pressed).
  45547. */
  45548. static readonly CUT: number;
  45549. /**
  45550. * The clipboard event is fired when a paste command is active (pressed).
  45551. */
  45552. static readonly PASTE: number;
  45553. }
  45554. /**
  45555. * This class is used to store clipboard related info for the onClipboardObservable event.
  45556. */
  45557. export class ClipboardInfo {
  45558. /**
  45559. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45560. */
  45561. type: number;
  45562. /**
  45563. * Defines the related dom event
  45564. */
  45565. event: ClipboardEvent;
  45566. /**
  45567. *Creates an instance of ClipboardInfo.
  45568. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45569. * @param event Defines the related dom event
  45570. */
  45571. constructor(
  45572. /**
  45573. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45574. */
  45575. type: number,
  45576. /**
  45577. * Defines the related dom event
  45578. */
  45579. event: ClipboardEvent);
  45580. /**
  45581. * Get the clipboard event's type from the keycode.
  45582. * @param keyCode Defines the keyCode for the current keyboard event.
  45583. * @return {number}
  45584. */
  45585. static GetTypeFromCharacter(keyCode: number): number;
  45586. }
  45587. }
  45588. declare module "babylonjs/Events/index" {
  45589. export * from "babylonjs/Events/keyboardEvents";
  45590. export * from "babylonjs/Events/pointerEvents";
  45591. export * from "babylonjs/Events/clipboardEvents";
  45592. }
  45593. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45594. import { Scene } from "babylonjs/scene";
  45595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45596. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45597. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45598. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45599. /**
  45600. * Google Daydream controller
  45601. */
  45602. export class DaydreamController extends WebVRController {
  45603. /**
  45604. * Base Url for the controller model.
  45605. */
  45606. static MODEL_BASE_URL: string;
  45607. /**
  45608. * File name for the controller model.
  45609. */
  45610. static MODEL_FILENAME: string;
  45611. /**
  45612. * Gamepad Id prefix used to identify Daydream Controller.
  45613. */
  45614. static readonly GAMEPAD_ID_PREFIX: string;
  45615. /**
  45616. * Creates a new DaydreamController from a gamepad
  45617. * @param vrGamepad the gamepad that the controller should be created from
  45618. */
  45619. constructor(vrGamepad: any);
  45620. /**
  45621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45622. * @param scene scene in which to add meshes
  45623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45624. */
  45625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45626. /**
  45627. * Called once for each button that changed state since the last frame
  45628. * @param buttonIdx Which button index changed
  45629. * @param state New state of the button
  45630. * @param changes Which properties on the state changed since last frame
  45631. */
  45632. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45633. }
  45634. }
  45635. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45636. import { Scene } from "babylonjs/scene";
  45637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45638. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45639. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45640. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45641. /**
  45642. * Gear VR Controller
  45643. */
  45644. export class GearVRController extends WebVRController {
  45645. /**
  45646. * Base Url for the controller model.
  45647. */
  45648. static MODEL_BASE_URL: string;
  45649. /**
  45650. * File name for the controller model.
  45651. */
  45652. static MODEL_FILENAME: string;
  45653. /**
  45654. * Gamepad Id prefix used to identify this controller.
  45655. */
  45656. static readonly GAMEPAD_ID_PREFIX: string;
  45657. private readonly _buttonIndexToObservableNameMap;
  45658. /**
  45659. * Creates a new GearVRController from a gamepad
  45660. * @param vrGamepad the gamepad that the controller should be created from
  45661. */
  45662. constructor(vrGamepad: any);
  45663. /**
  45664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45665. * @param scene scene in which to add meshes
  45666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45667. */
  45668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45669. /**
  45670. * Called once for each button that changed state since the last frame
  45671. * @param buttonIdx Which button index changed
  45672. * @param state New state of the button
  45673. * @param changes Which properties on the state changed since last frame
  45674. */
  45675. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45676. }
  45677. }
  45678. declare module "babylonjs/Gamepads/Controllers/index" {
  45679. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45680. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45681. export * from "babylonjs/Gamepads/Controllers/genericController";
  45682. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45683. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45684. export * from "babylonjs/Gamepads/Controllers/viveController";
  45685. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45686. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45687. }
  45688. declare module "babylonjs/Gamepads/index" {
  45689. export * from "babylonjs/Gamepads/Controllers/index";
  45690. export * from "babylonjs/Gamepads/gamepad";
  45691. export * from "babylonjs/Gamepads/gamepadManager";
  45692. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45693. export * from "babylonjs/Gamepads/xboxGamepad";
  45694. export * from "babylonjs/Gamepads/dualShockGamepad";
  45695. }
  45696. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45697. import { Scene } from "babylonjs/scene";
  45698. import { Vector4 } from "babylonjs/Maths/math.vector";
  45699. import { Color4 } from "babylonjs/Maths/math.color";
  45700. import { Mesh } from "babylonjs/Meshes/mesh";
  45701. import { Nullable } from "babylonjs/types";
  45702. /**
  45703. * Class containing static functions to help procedurally build meshes
  45704. */
  45705. export class PolyhedronBuilder {
  45706. /**
  45707. * Creates a polyhedron mesh
  45708. * * 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
  45709. * * The parameter `size` (positive float, default 1) sets the polygon size
  45710. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45711. * * 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`
  45712. * * 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
  45713. * * 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)`)
  45714. * * 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
  45715. * * 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
  45716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45719. * @param name defines the name of the mesh
  45720. * @param options defines the options used to create the mesh
  45721. * @param scene defines the hosting scene
  45722. * @returns the polyhedron mesh
  45723. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45724. */
  45725. static CreatePolyhedron(name: string, options: {
  45726. type?: number;
  45727. size?: number;
  45728. sizeX?: number;
  45729. sizeY?: number;
  45730. sizeZ?: number;
  45731. custom?: any;
  45732. faceUV?: Vector4[];
  45733. faceColors?: Color4[];
  45734. flat?: boolean;
  45735. updatable?: boolean;
  45736. sideOrientation?: number;
  45737. frontUVs?: Vector4;
  45738. backUVs?: Vector4;
  45739. }, scene?: Nullable<Scene>): Mesh;
  45740. }
  45741. }
  45742. declare module "babylonjs/Gizmos/scaleGizmo" {
  45743. import { Observable } from "babylonjs/Misc/observable";
  45744. import { Nullable } from "babylonjs/types";
  45745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45746. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45747. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45748. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45749. /**
  45750. * Gizmo that enables scaling a mesh along 3 axis
  45751. */
  45752. export class ScaleGizmo extends Gizmo {
  45753. /**
  45754. * Internal gizmo used for interactions on the x axis
  45755. */
  45756. xGizmo: AxisScaleGizmo;
  45757. /**
  45758. * Internal gizmo used for interactions on the y axis
  45759. */
  45760. yGizmo: AxisScaleGizmo;
  45761. /**
  45762. * Internal gizmo used for interactions on the z axis
  45763. */
  45764. zGizmo: AxisScaleGizmo;
  45765. /**
  45766. * Internal gizmo used to scale all axis equally
  45767. */
  45768. uniformScaleGizmo: AxisScaleGizmo;
  45769. private _meshAttached;
  45770. private _updateGizmoRotationToMatchAttachedMesh;
  45771. private _snapDistance;
  45772. private _scaleRatio;
  45773. private _uniformScalingMesh;
  45774. private _octahedron;
  45775. /** Fires an event when any of it's sub gizmos are dragged */
  45776. onDragStartObservable: Observable<unknown>;
  45777. /** Fires an event when any of it's sub gizmos are released from dragging */
  45778. onDragEndObservable: Observable<unknown>;
  45779. attachedMesh: Nullable<AbstractMesh>;
  45780. /**
  45781. * Creates a ScaleGizmo
  45782. * @param gizmoLayer The utility layer the gizmo will be added to
  45783. */
  45784. constructor(gizmoLayer?: UtilityLayerRenderer);
  45785. updateGizmoRotationToMatchAttachedMesh: boolean;
  45786. /**
  45787. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45788. */
  45789. snapDistance: number;
  45790. /**
  45791. * Ratio for the scale of the gizmo (Default: 1)
  45792. */
  45793. scaleRatio: number;
  45794. /**
  45795. * Disposes of the gizmo
  45796. */
  45797. dispose(): void;
  45798. }
  45799. }
  45800. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45801. import { Observable } from "babylonjs/Misc/observable";
  45802. import { Nullable } from "babylonjs/types";
  45803. import { Vector3 } from "babylonjs/Maths/math.vector";
  45804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45805. import { Mesh } from "babylonjs/Meshes/mesh";
  45806. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45807. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45808. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45809. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45810. import { Color3 } from "babylonjs/Maths/math.color";
  45811. /**
  45812. * Single axis scale gizmo
  45813. */
  45814. export class AxisScaleGizmo extends Gizmo {
  45815. /**
  45816. * Drag behavior responsible for the gizmos dragging interactions
  45817. */
  45818. dragBehavior: PointerDragBehavior;
  45819. private _pointerObserver;
  45820. /**
  45821. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45822. */
  45823. snapDistance: number;
  45824. /**
  45825. * Event that fires each time the gizmo snaps to a new location.
  45826. * * snapDistance is the the change in distance
  45827. */
  45828. onSnapObservable: Observable<{
  45829. snapDistance: number;
  45830. }>;
  45831. /**
  45832. * If the scaling operation should be done on all axis (default: false)
  45833. */
  45834. uniformScaling: boolean;
  45835. private _isEnabled;
  45836. private _parent;
  45837. private _arrow;
  45838. private _coloredMaterial;
  45839. private _hoverMaterial;
  45840. /**
  45841. * Creates an AxisScaleGizmo
  45842. * @param gizmoLayer The utility layer the gizmo will be added to
  45843. * @param dragAxis The axis which the gizmo will be able to scale on
  45844. * @param color The color of the gizmo
  45845. */
  45846. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45847. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45848. /**
  45849. * If the gizmo is enabled
  45850. */
  45851. isEnabled: boolean;
  45852. /**
  45853. * Disposes of the gizmo
  45854. */
  45855. dispose(): void;
  45856. /**
  45857. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45858. * @param mesh The mesh to replace the default mesh of the gizmo
  45859. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45860. */
  45861. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45862. }
  45863. }
  45864. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45865. import { Observable } from "babylonjs/Misc/observable";
  45866. import { Nullable } from "babylonjs/types";
  45867. import { Vector3 } from "babylonjs/Maths/math.vector";
  45868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45869. import { Mesh } from "babylonjs/Meshes/mesh";
  45870. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45871. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45872. import { Color3 } from "babylonjs/Maths/math.color";
  45873. import "babylonjs/Meshes/Builders/boxBuilder";
  45874. /**
  45875. * Bounding box gizmo
  45876. */
  45877. export class BoundingBoxGizmo extends Gizmo {
  45878. private _lineBoundingBox;
  45879. private _rotateSpheresParent;
  45880. private _scaleBoxesParent;
  45881. private _boundingDimensions;
  45882. private _renderObserver;
  45883. private _pointerObserver;
  45884. private _scaleDragSpeed;
  45885. private _tmpQuaternion;
  45886. private _tmpVector;
  45887. private _tmpRotationMatrix;
  45888. /**
  45889. * 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)
  45890. */
  45891. ignoreChildren: boolean;
  45892. /**
  45893. * 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)
  45894. */
  45895. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45896. /**
  45897. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45898. */
  45899. rotationSphereSize: number;
  45900. /**
  45901. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45902. */
  45903. scaleBoxSize: number;
  45904. /**
  45905. * 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)
  45906. */
  45907. fixedDragMeshScreenSize: boolean;
  45908. /**
  45909. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45910. */
  45911. fixedDragMeshScreenSizeDistanceFactor: number;
  45912. /**
  45913. * Fired when a rotation sphere or scale box is dragged
  45914. */
  45915. onDragStartObservable: Observable<{}>;
  45916. /**
  45917. * Fired when a scale box is dragged
  45918. */
  45919. onScaleBoxDragObservable: Observable<{}>;
  45920. /**
  45921. * Fired when a scale box drag is ended
  45922. */
  45923. onScaleBoxDragEndObservable: Observable<{}>;
  45924. /**
  45925. * Fired when a rotation sphere is dragged
  45926. */
  45927. onRotationSphereDragObservable: Observable<{}>;
  45928. /**
  45929. * Fired when a rotation sphere drag is ended
  45930. */
  45931. onRotationSphereDragEndObservable: Observable<{}>;
  45932. /**
  45933. * 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)
  45934. */
  45935. scalePivot: Nullable<Vector3>;
  45936. /**
  45937. * Mesh used as a pivot to rotate the attached mesh
  45938. */
  45939. private _anchorMesh;
  45940. private _existingMeshScale;
  45941. private _dragMesh;
  45942. private pointerDragBehavior;
  45943. private coloredMaterial;
  45944. private hoverColoredMaterial;
  45945. /**
  45946. * Sets the color of the bounding box gizmo
  45947. * @param color the color to set
  45948. */
  45949. setColor(color: Color3): void;
  45950. /**
  45951. * Creates an BoundingBoxGizmo
  45952. * @param gizmoLayer The utility layer the gizmo will be added to
  45953. * @param color The color of the gizmo
  45954. */
  45955. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45956. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45957. private _selectNode;
  45958. /**
  45959. * Updates the bounding box information for the Gizmo
  45960. */
  45961. updateBoundingBox(): void;
  45962. private _updateRotationSpheres;
  45963. private _updateScaleBoxes;
  45964. /**
  45965. * Enables rotation on the specified axis and disables rotation on the others
  45966. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45967. */
  45968. setEnabledRotationAxis(axis: string): void;
  45969. /**
  45970. * Enables/disables scaling
  45971. * @param enable if scaling should be enabled
  45972. */
  45973. setEnabledScaling(enable: boolean): void;
  45974. private _updateDummy;
  45975. /**
  45976. * Enables a pointer drag behavior on the bounding box of the gizmo
  45977. */
  45978. enableDragBehavior(): void;
  45979. /**
  45980. * Disposes of the gizmo
  45981. */
  45982. dispose(): void;
  45983. /**
  45984. * 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)
  45985. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45986. * @returns the bounding box mesh with the passed in mesh as a child
  45987. */
  45988. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45989. /**
  45990. * CustomMeshes are not supported by this gizmo
  45991. * @param mesh The mesh to replace the default mesh of the gizmo
  45992. */
  45993. setCustomMesh(mesh: Mesh): void;
  45994. }
  45995. }
  45996. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45997. import { Observable } from "babylonjs/Misc/observable";
  45998. import { Nullable } from "babylonjs/types";
  45999. import { Vector3 } from "babylonjs/Maths/math.vector";
  46000. import { Color3 } from "babylonjs/Maths/math.color";
  46001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46002. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46003. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46004. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46005. import "babylonjs/Meshes/Builders/linesBuilder";
  46006. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46007. /**
  46008. * Single plane rotation gizmo
  46009. */
  46010. export class PlaneRotationGizmo extends Gizmo {
  46011. /**
  46012. * Drag behavior responsible for the gizmos dragging interactions
  46013. */
  46014. dragBehavior: PointerDragBehavior;
  46015. private _pointerObserver;
  46016. /**
  46017. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46018. */
  46019. snapDistance: number;
  46020. /**
  46021. * Event that fires each time the gizmo snaps to a new location.
  46022. * * snapDistance is the the change in distance
  46023. */
  46024. onSnapObservable: Observable<{
  46025. snapDistance: number;
  46026. }>;
  46027. private _isEnabled;
  46028. private _parent;
  46029. /**
  46030. * Creates a PlaneRotationGizmo
  46031. * @param gizmoLayer The utility layer the gizmo will be added to
  46032. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46033. * @param color The color of the gizmo
  46034. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46035. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46036. */
  46037. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46038. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46039. /**
  46040. * If the gizmo is enabled
  46041. */
  46042. isEnabled: boolean;
  46043. /**
  46044. * Disposes of the gizmo
  46045. */
  46046. dispose(): void;
  46047. }
  46048. }
  46049. declare module "babylonjs/Gizmos/rotationGizmo" {
  46050. import { Observable } from "babylonjs/Misc/observable";
  46051. import { Nullable } from "babylonjs/types";
  46052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46053. import { Mesh } from "babylonjs/Meshes/mesh";
  46054. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46055. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46056. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46057. /**
  46058. * Gizmo that enables rotating a mesh along 3 axis
  46059. */
  46060. export class RotationGizmo extends Gizmo {
  46061. /**
  46062. * Internal gizmo used for interactions on the x axis
  46063. */
  46064. xGizmo: PlaneRotationGizmo;
  46065. /**
  46066. * Internal gizmo used for interactions on the y axis
  46067. */
  46068. yGizmo: PlaneRotationGizmo;
  46069. /**
  46070. * Internal gizmo used for interactions on the z axis
  46071. */
  46072. zGizmo: PlaneRotationGizmo;
  46073. /** Fires an event when any of it's sub gizmos are dragged */
  46074. onDragStartObservable: Observable<unknown>;
  46075. /** Fires an event when any of it's sub gizmos are released from dragging */
  46076. onDragEndObservable: Observable<unknown>;
  46077. private _meshAttached;
  46078. attachedMesh: Nullable<AbstractMesh>;
  46079. /**
  46080. * Creates a RotationGizmo
  46081. * @param gizmoLayer The utility layer the gizmo will be added to
  46082. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46083. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46084. */
  46085. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46086. updateGizmoRotationToMatchAttachedMesh: boolean;
  46087. /**
  46088. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46089. */
  46090. snapDistance: number;
  46091. /**
  46092. * Ratio for the scale of the gizmo (Default: 1)
  46093. */
  46094. scaleRatio: number;
  46095. /**
  46096. * Disposes of the gizmo
  46097. */
  46098. dispose(): void;
  46099. /**
  46100. * CustomMeshes are not supported by this gizmo
  46101. * @param mesh The mesh to replace the default mesh of the gizmo
  46102. */
  46103. setCustomMesh(mesh: Mesh): void;
  46104. }
  46105. }
  46106. declare module "babylonjs/Gizmos/gizmoManager" {
  46107. import { Observable } from "babylonjs/Misc/observable";
  46108. import { Nullable } from "babylonjs/types";
  46109. import { Scene, IDisposable } from "babylonjs/scene";
  46110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46111. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46112. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46113. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46114. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46115. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46116. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46117. /**
  46118. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46119. */
  46120. export class GizmoManager implements IDisposable {
  46121. private scene;
  46122. /**
  46123. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46124. */
  46125. gizmos: {
  46126. positionGizmo: Nullable<PositionGizmo>;
  46127. rotationGizmo: Nullable<RotationGizmo>;
  46128. scaleGizmo: Nullable<ScaleGizmo>;
  46129. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46130. };
  46131. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46132. clearGizmoOnEmptyPointerEvent: boolean;
  46133. /** Fires an event when the manager is attached to a mesh */
  46134. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46135. private _gizmosEnabled;
  46136. private _pointerObserver;
  46137. private _attachedMesh;
  46138. private _boundingBoxColor;
  46139. private _defaultUtilityLayer;
  46140. private _defaultKeepDepthUtilityLayer;
  46141. /**
  46142. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46143. */
  46144. boundingBoxDragBehavior: SixDofDragBehavior;
  46145. /**
  46146. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46147. */
  46148. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46149. /**
  46150. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46151. */
  46152. usePointerToAttachGizmos: boolean;
  46153. /**
  46154. * Utility layer that the bounding box gizmo belongs to
  46155. */
  46156. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46157. /**
  46158. * Utility layer that all gizmos besides bounding box belong to
  46159. */
  46160. readonly utilityLayer: UtilityLayerRenderer;
  46161. /**
  46162. * Instatiates a gizmo manager
  46163. * @param scene the scene to overlay the gizmos on top of
  46164. */
  46165. constructor(scene: Scene);
  46166. /**
  46167. * Attaches a set of gizmos to the specified mesh
  46168. * @param mesh The mesh the gizmo's should be attached to
  46169. */
  46170. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46171. /**
  46172. * If the position gizmo is enabled
  46173. */
  46174. positionGizmoEnabled: boolean;
  46175. /**
  46176. * If the rotation gizmo is enabled
  46177. */
  46178. rotationGizmoEnabled: boolean;
  46179. /**
  46180. * If the scale gizmo is enabled
  46181. */
  46182. scaleGizmoEnabled: boolean;
  46183. /**
  46184. * If the boundingBox gizmo is enabled
  46185. */
  46186. boundingBoxGizmoEnabled: boolean;
  46187. /**
  46188. * Disposes of the gizmo manager
  46189. */
  46190. dispose(): void;
  46191. }
  46192. }
  46193. declare module "babylonjs/Lights/directionalLight" {
  46194. import { Camera } from "babylonjs/Cameras/camera";
  46195. import { Scene } from "babylonjs/scene";
  46196. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46198. import { Light } from "babylonjs/Lights/light";
  46199. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46200. import { Effect } from "babylonjs/Materials/effect";
  46201. /**
  46202. * A directional light is defined by a direction (what a surprise!).
  46203. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46204. * 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.
  46205. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46206. */
  46207. export class DirectionalLight extends ShadowLight {
  46208. private _shadowFrustumSize;
  46209. /**
  46210. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46211. */
  46212. /**
  46213. * Specifies a fix frustum size for the shadow generation.
  46214. */
  46215. shadowFrustumSize: number;
  46216. private _shadowOrthoScale;
  46217. /**
  46218. * Gets the shadow projection scale against the optimal computed one.
  46219. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46220. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46221. */
  46222. /**
  46223. * Sets the shadow projection scale against the optimal computed one.
  46224. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46225. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46226. */
  46227. shadowOrthoScale: number;
  46228. /**
  46229. * Automatically compute the projection matrix to best fit (including all the casters)
  46230. * on each frame.
  46231. */
  46232. autoUpdateExtends: boolean;
  46233. private _orthoLeft;
  46234. private _orthoRight;
  46235. private _orthoTop;
  46236. private _orthoBottom;
  46237. /**
  46238. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46239. * The directional light is emitted from everywhere in the given direction.
  46240. * It can cast shadows.
  46241. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46242. * @param name The friendly name of the light
  46243. * @param direction The direction of the light
  46244. * @param scene The scene the light belongs to
  46245. */
  46246. constructor(name: string, direction: Vector3, scene: Scene);
  46247. /**
  46248. * Returns the string "DirectionalLight".
  46249. * @return The class name
  46250. */
  46251. getClassName(): string;
  46252. /**
  46253. * Returns the integer 1.
  46254. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46255. */
  46256. getTypeID(): number;
  46257. /**
  46258. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46259. * Returns the DirectionalLight Shadow projection matrix.
  46260. */
  46261. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46262. /**
  46263. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46264. * Returns the DirectionalLight Shadow projection matrix.
  46265. */
  46266. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46267. /**
  46268. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46269. * Returns the DirectionalLight Shadow projection matrix.
  46270. */
  46271. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46272. protected _buildUniformLayout(): void;
  46273. /**
  46274. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46275. * @param effect The effect to update
  46276. * @param lightIndex The index of the light in the effect to update
  46277. * @returns The directional light
  46278. */
  46279. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46280. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46281. /**
  46282. * Gets the minZ used for shadow according to both the scene and the light.
  46283. *
  46284. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46285. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46286. * @param activeCamera The camera we are returning the min for
  46287. * @returns the depth min z
  46288. */
  46289. getDepthMinZ(activeCamera: Camera): number;
  46290. /**
  46291. * Gets the maxZ used for shadow according to both the scene and the light.
  46292. *
  46293. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46294. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46295. * @param activeCamera The camera we are returning the max for
  46296. * @returns the depth max z
  46297. */
  46298. getDepthMaxZ(activeCamera: Camera): number;
  46299. /**
  46300. * Prepares the list of defines specific to the light type.
  46301. * @param defines the list of defines
  46302. * @param lightIndex defines the index of the light for the effect
  46303. */
  46304. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46305. }
  46306. }
  46307. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46308. import { Mesh } from "babylonjs/Meshes/mesh";
  46309. /**
  46310. * Class containing static functions to help procedurally build meshes
  46311. */
  46312. export class HemisphereBuilder {
  46313. /**
  46314. * Creates a hemisphere mesh
  46315. * @param name defines the name of the mesh
  46316. * @param options defines the options used to create the mesh
  46317. * @param scene defines the hosting scene
  46318. * @returns the hemisphere mesh
  46319. */
  46320. static CreateHemisphere(name: string, options: {
  46321. segments?: number;
  46322. diameter?: number;
  46323. sideOrientation?: number;
  46324. }, scene: any): Mesh;
  46325. }
  46326. }
  46327. declare module "babylonjs/Lights/spotLight" {
  46328. import { Nullable } from "babylonjs/types";
  46329. import { Scene } from "babylonjs/scene";
  46330. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46332. import { Effect } from "babylonjs/Materials/effect";
  46333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46334. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46335. /**
  46336. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46337. * These values define a cone of light starting from the position, emitting toward the direction.
  46338. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46339. * and the exponent defines the speed of the decay of the light with distance (reach).
  46340. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46341. */
  46342. export class SpotLight extends ShadowLight {
  46343. private _angle;
  46344. private _innerAngle;
  46345. private _cosHalfAngle;
  46346. private _lightAngleScale;
  46347. private _lightAngleOffset;
  46348. /**
  46349. * Gets the cone angle of the spot light in Radians.
  46350. */
  46351. /**
  46352. * Sets the cone angle of the spot light in Radians.
  46353. */
  46354. angle: number;
  46355. /**
  46356. * Only used in gltf falloff mode, this defines the angle where
  46357. * the directional falloff will start before cutting at angle which could be seen
  46358. * as outer angle.
  46359. */
  46360. /**
  46361. * Only used in gltf falloff mode, this defines the angle where
  46362. * the directional falloff will start before cutting at angle which could be seen
  46363. * as outer angle.
  46364. */
  46365. innerAngle: number;
  46366. private _shadowAngleScale;
  46367. /**
  46368. * Allows scaling the angle of the light for shadow generation only.
  46369. */
  46370. /**
  46371. * Allows scaling the angle of the light for shadow generation only.
  46372. */
  46373. shadowAngleScale: number;
  46374. /**
  46375. * The light decay speed with the distance from the emission spot.
  46376. */
  46377. exponent: number;
  46378. private _projectionTextureMatrix;
  46379. /**
  46380. * Allows reading the projecton texture
  46381. */
  46382. readonly projectionTextureMatrix: Matrix;
  46383. protected _projectionTextureLightNear: number;
  46384. /**
  46385. * Gets the near clip of the Spotlight for texture projection.
  46386. */
  46387. /**
  46388. * Sets the near clip of the Spotlight for texture projection.
  46389. */
  46390. projectionTextureLightNear: number;
  46391. protected _projectionTextureLightFar: number;
  46392. /**
  46393. * Gets the far clip of the Spotlight for texture projection.
  46394. */
  46395. /**
  46396. * Sets the far clip of the Spotlight for texture projection.
  46397. */
  46398. projectionTextureLightFar: number;
  46399. protected _projectionTextureUpDirection: Vector3;
  46400. /**
  46401. * Gets the Up vector of the Spotlight for texture projection.
  46402. */
  46403. /**
  46404. * Sets the Up vector of the Spotlight for texture projection.
  46405. */
  46406. projectionTextureUpDirection: Vector3;
  46407. private _projectionTexture;
  46408. /**
  46409. * Gets the projection texture of the light.
  46410. */
  46411. /**
  46412. * Sets the projection texture of the light.
  46413. */
  46414. projectionTexture: Nullable<BaseTexture>;
  46415. private _projectionTextureViewLightDirty;
  46416. private _projectionTextureProjectionLightDirty;
  46417. private _projectionTextureDirty;
  46418. private _projectionTextureViewTargetVector;
  46419. private _projectionTextureViewLightMatrix;
  46420. private _projectionTextureProjectionLightMatrix;
  46421. private _projectionTextureScalingMatrix;
  46422. /**
  46423. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46424. * It can cast shadows.
  46425. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46426. * @param name The light friendly name
  46427. * @param position The position of the spot light in the scene
  46428. * @param direction The direction of the light in the scene
  46429. * @param angle The cone angle of the light in Radians
  46430. * @param exponent The light decay speed with the distance from the emission spot
  46431. * @param scene The scene the lights belongs to
  46432. */
  46433. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46434. /**
  46435. * Returns the string "SpotLight".
  46436. * @returns the class name
  46437. */
  46438. getClassName(): string;
  46439. /**
  46440. * Returns the integer 2.
  46441. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46442. */
  46443. getTypeID(): number;
  46444. /**
  46445. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46446. */
  46447. protected _setDirection(value: Vector3): void;
  46448. /**
  46449. * Overrides the position setter to recompute the projection texture view light Matrix.
  46450. */
  46451. protected _setPosition(value: Vector3): void;
  46452. /**
  46453. * 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.
  46454. * Returns the SpotLight.
  46455. */
  46456. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46457. protected _computeProjectionTextureViewLightMatrix(): void;
  46458. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46459. /**
  46460. * Main function for light texture projection matrix computing.
  46461. */
  46462. protected _computeProjectionTextureMatrix(): void;
  46463. protected _buildUniformLayout(): void;
  46464. private _computeAngleValues;
  46465. /**
  46466. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46467. * @param effect The effect to update
  46468. * @param lightIndex The index of the light in the effect to update
  46469. * @returns The spot light
  46470. */
  46471. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46472. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46473. /**
  46474. * Disposes the light and the associated resources.
  46475. */
  46476. dispose(): void;
  46477. /**
  46478. * Prepares the list of defines specific to the light type.
  46479. * @param defines the list of defines
  46480. * @param lightIndex defines the index of the light for the effect
  46481. */
  46482. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46483. }
  46484. }
  46485. declare module "babylonjs/Gizmos/lightGizmo" {
  46486. import { Nullable } from "babylonjs/types";
  46487. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46488. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46489. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46490. import { Light } from "babylonjs/Lights/light";
  46491. /**
  46492. * Gizmo that enables viewing a light
  46493. */
  46494. export class LightGizmo extends Gizmo {
  46495. private _lightMesh;
  46496. private _material;
  46497. private cachedPosition;
  46498. private cachedForward;
  46499. /**
  46500. * Creates a LightGizmo
  46501. * @param gizmoLayer The utility layer the gizmo will be added to
  46502. */
  46503. constructor(gizmoLayer?: UtilityLayerRenderer);
  46504. private _light;
  46505. /**
  46506. * The light that the gizmo is attached to
  46507. */
  46508. light: Nullable<Light>;
  46509. /**
  46510. * Gets the material used to render the light gizmo
  46511. */
  46512. readonly material: StandardMaterial;
  46513. /**
  46514. * @hidden
  46515. * Updates the gizmo to match the attached mesh's position/rotation
  46516. */
  46517. protected _update(): void;
  46518. private static _Scale;
  46519. /**
  46520. * Creates the lines for a light mesh
  46521. */
  46522. private static _createLightLines;
  46523. /**
  46524. * Disposes of the light gizmo
  46525. */
  46526. dispose(): void;
  46527. private static _CreateHemisphericLightMesh;
  46528. private static _CreatePointLightMesh;
  46529. private static _CreateSpotLightMesh;
  46530. private static _CreateDirectionalLightMesh;
  46531. }
  46532. }
  46533. declare module "babylonjs/Gizmos/index" {
  46534. export * from "babylonjs/Gizmos/axisDragGizmo";
  46535. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46536. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46537. export * from "babylonjs/Gizmos/gizmo";
  46538. export * from "babylonjs/Gizmos/gizmoManager";
  46539. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46540. export * from "babylonjs/Gizmos/positionGizmo";
  46541. export * from "babylonjs/Gizmos/rotationGizmo";
  46542. export * from "babylonjs/Gizmos/scaleGizmo";
  46543. export * from "babylonjs/Gizmos/lightGizmo";
  46544. export * from "babylonjs/Gizmos/planeDragGizmo";
  46545. }
  46546. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46547. /** @hidden */
  46548. export var backgroundFragmentDeclaration: {
  46549. name: string;
  46550. shader: string;
  46551. };
  46552. }
  46553. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46554. /** @hidden */
  46555. export var backgroundUboDeclaration: {
  46556. name: string;
  46557. shader: string;
  46558. };
  46559. }
  46560. declare module "babylonjs/Shaders/background.fragment" {
  46561. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46562. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46563. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46564. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46565. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46566. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46568. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46569. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46570. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46572. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46573. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46574. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46575. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46576. /** @hidden */
  46577. export var backgroundPixelShader: {
  46578. name: string;
  46579. shader: string;
  46580. };
  46581. }
  46582. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46583. /** @hidden */
  46584. export var backgroundVertexDeclaration: {
  46585. name: string;
  46586. shader: string;
  46587. };
  46588. }
  46589. declare module "babylonjs/Shaders/background.vertex" {
  46590. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46591. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46593. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46594. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46595. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46596. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46597. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46598. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46599. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46600. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46601. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46602. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46603. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46604. /** @hidden */
  46605. export var backgroundVertexShader: {
  46606. name: string;
  46607. shader: string;
  46608. };
  46609. }
  46610. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46611. import { Nullable, int, float } from "babylonjs/types";
  46612. import { Scene } from "babylonjs/scene";
  46613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46616. import { Mesh } from "babylonjs/Meshes/mesh";
  46617. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46618. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46619. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46621. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46622. import { Color3 } from "babylonjs/Maths/math.color";
  46623. import "babylonjs/Shaders/background.fragment";
  46624. import "babylonjs/Shaders/background.vertex";
  46625. /**
  46626. * Background material used to create an efficient environement around your scene.
  46627. */
  46628. export class BackgroundMaterial extends PushMaterial {
  46629. /**
  46630. * Standard reflectance value at parallel view angle.
  46631. */
  46632. static StandardReflectance0: number;
  46633. /**
  46634. * Standard reflectance value at grazing angle.
  46635. */
  46636. static StandardReflectance90: number;
  46637. protected _primaryColor: Color3;
  46638. /**
  46639. * Key light Color (multiply against the environement texture)
  46640. */
  46641. primaryColor: Color3;
  46642. protected __perceptualColor: Nullable<Color3>;
  46643. /**
  46644. * Experimental Internal Use Only.
  46645. *
  46646. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46647. * This acts as a helper to set the primary color to a more "human friendly" value.
  46648. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46649. * output color as close as possible from the chosen value.
  46650. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46651. * part of lighting setup.)
  46652. */
  46653. _perceptualColor: Nullable<Color3>;
  46654. protected _primaryColorShadowLevel: float;
  46655. /**
  46656. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46657. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46658. */
  46659. primaryColorShadowLevel: float;
  46660. protected _primaryColorHighlightLevel: float;
  46661. /**
  46662. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46663. * The primary color is used at the level chosen to define what the white area would look.
  46664. */
  46665. primaryColorHighlightLevel: float;
  46666. protected _reflectionTexture: Nullable<BaseTexture>;
  46667. /**
  46668. * Reflection Texture used in the material.
  46669. * Should be author in a specific way for the best result (refer to the documentation).
  46670. */
  46671. reflectionTexture: Nullable<BaseTexture>;
  46672. protected _reflectionBlur: float;
  46673. /**
  46674. * Reflection Texture level of blur.
  46675. *
  46676. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46677. * texture twice.
  46678. */
  46679. reflectionBlur: float;
  46680. protected _diffuseTexture: Nullable<BaseTexture>;
  46681. /**
  46682. * Diffuse Texture used in the material.
  46683. * Should be author in a specific way for the best result (refer to the documentation).
  46684. */
  46685. diffuseTexture: Nullable<BaseTexture>;
  46686. protected _shadowLights: Nullable<IShadowLight[]>;
  46687. /**
  46688. * Specify the list of lights casting shadow on the material.
  46689. * All scene shadow lights will be included if null.
  46690. */
  46691. shadowLights: Nullable<IShadowLight[]>;
  46692. protected _shadowLevel: float;
  46693. /**
  46694. * Helps adjusting the shadow to a softer level if required.
  46695. * 0 means black shadows and 1 means no shadows.
  46696. */
  46697. shadowLevel: float;
  46698. protected _sceneCenter: Vector3;
  46699. /**
  46700. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46701. * It is usually zero but might be interesting to modify according to your setup.
  46702. */
  46703. sceneCenter: Vector3;
  46704. protected _opacityFresnel: boolean;
  46705. /**
  46706. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46707. * This helps ensuring a nice transition when the camera goes under the ground.
  46708. */
  46709. opacityFresnel: boolean;
  46710. protected _reflectionFresnel: boolean;
  46711. /**
  46712. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46713. * This helps adding a mirror texture on the ground.
  46714. */
  46715. reflectionFresnel: boolean;
  46716. protected _reflectionFalloffDistance: number;
  46717. /**
  46718. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46719. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46720. */
  46721. reflectionFalloffDistance: number;
  46722. protected _reflectionAmount: number;
  46723. /**
  46724. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46725. */
  46726. reflectionAmount: number;
  46727. protected _reflectionReflectance0: number;
  46728. /**
  46729. * This specifies the weight of the reflection at grazing angle.
  46730. */
  46731. reflectionReflectance0: number;
  46732. protected _reflectionReflectance90: number;
  46733. /**
  46734. * This specifies the weight of the reflection at a perpendicular point of view.
  46735. */
  46736. reflectionReflectance90: number;
  46737. /**
  46738. * Sets the reflection reflectance fresnel values according to the default standard
  46739. * empirically know to work well :-)
  46740. */
  46741. reflectionStandardFresnelWeight: number;
  46742. protected _useRGBColor: boolean;
  46743. /**
  46744. * Helps to directly use the maps channels instead of their level.
  46745. */
  46746. useRGBColor: boolean;
  46747. protected _enableNoise: boolean;
  46748. /**
  46749. * This helps reducing the banding effect that could occur on the background.
  46750. */
  46751. enableNoise: boolean;
  46752. /**
  46753. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46754. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46755. * Recommended to be keep at 1.0 except for special cases.
  46756. */
  46757. fovMultiplier: number;
  46758. private _fovMultiplier;
  46759. /**
  46760. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46761. */
  46762. useEquirectangularFOV: boolean;
  46763. private _maxSimultaneousLights;
  46764. /**
  46765. * Number of Simultaneous lights allowed on the material.
  46766. */
  46767. maxSimultaneousLights: int;
  46768. /**
  46769. * Default configuration related to image processing available in the Background Material.
  46770. */
  46771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46772. /**
  46773. * Keep track of the image processing observer to allow dispose and replace.
  46774. */
  46775. private _imageProcessingObserver;
  46776. /**
  46777. * Attaches a new image processing configuration to the PBR Material.
  46778. * @param configuration (if null the scene configuration will be use)
  46779. */
  46780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46781. /**
  46782. * Gets the image processing configuration used either in this material.
  46783. */
  46784. /**
  46785. * Sets the Default image processing configuration used either in the this material.
  46786. *
  46787. * If sets to null, the scene one is in use.
  46788. */
  46789. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46790. /**
  46791. * Gets wether the color curves effect is enabled.
  46792. */
  46793. /**
  46794. * Sets wether the color curves effect is enabled.
  46795. */
  46796. cameraColorCurvesEnabled: boolean;
  46797. /**
  46798. * Gets wether the color grading effect is enabled.
  46799. */
  46800. /**
  46801. * Gets wether the color grading effect is enabled.
  46802. */
  46803. cameraColorGradingEnabled: boolean;
  46804. /**
  46805. * Gets wether tonemapping is enabled or not.
  46806. */
  46807. /**
  46808. * Sets wether tonemapping is enabled or not
  46809. */
  46810. cameraToneMappingEnabled: boolean;
  46811. /**
  46812. * The camera exposure used on this material.
  46813. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46814. * This corresponds to a photographic exposure.
  46815. */
  46816. /**
  46817. * The camera exposure used on this material.
  46818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46819. * This corresponds to a photographic exposure.
  46820. */
  46821. cameraExposure: float;
  46822. /**
  46823. * Gets The camera contrast used on this material.
  46824. */
  46825. /**
  46826. * Sets The camera contrast used on this material.
  46827. */
  46828. cameraContrast: float;
  46829. /**
  46830. * Gets the Color Grading 2D Lookup Texture.
  46831. */
  46832. /**
  46833. * Sets the Color Grading 2D Lookup Texture.
  46834. */
  46835. cameraColorGradingTexture: Nullable<BaseTexture>;
  46836. /**
  46837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46839. * 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;
  46840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46841. */
  46842. /**
  46843. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46844. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46845. * 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;
  46846. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46847. */
  46848. cameraColorCurves: Nullable<ColorCurves>;
  46849. /**
  46850. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46851. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46852. */
  46853. switchToBGR: boolean;
  46854. private _renderTargets;
  46855. private _reflectionControls;
  46856. private _white;
  46857. private _primaryShadowColor;
  46858. private _primaryHighlightColor;
  46859. /**
  46860. * Instantiates a Background Material in the given scene
  46861. * @param name The friendly name of the material
  46862. * @param scene The scene to add the material to
  46863. */
  46864. constructor(name: string, scene: Scene);
  46865. /**
  46866. * Gets a boolean indicating that current material needs to register RTT
  46867. */
  46868. readonly hasRenderTargetTextures: boolean;
  46869. /**
  46870. * The entire material has been created in order to prevent overdraw.
  46871. * @returns false
  46872. */
  46873. needAlphaTesting(): boolean;
  46874. /**
  46875. * The entire material has been created in order to prevent overdraw.
  46876. * @returns true if blending is enable
  46877. */
  46878. needAlphaBlending(): boolean;
  46879. /**
  46880. * Checks wether the material is ready to be rendered for a given mesh.
  46881. * @param mesh The mesh to render
  46882. * @param subMesh The submesh to check against
  46883. * @param useInstances Specify wether or not the material is used with instances
  46884. * @returns true if all the dependencies are ready (Textures, Effects...)
  46885. */
  46886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46887. /**
  46888. * Compute the primary color according to the chosen perceptual color.
  46889. */
  46890. private _computePrimaryColorFromPerceptualColor;
  46891. /**
  46892. * Compute the highlights and shadow colors according to their chosen levels.
  46893. */
  46894. private _computePrimaryColors;
  46895. /**
  46896. * Build the uniform buffer used in the material.
  46897. */
  46898. buildUniformLayout(): void;
  46899. /**
  46900. * Unbind the material.
  46901. */
  46902. unbind(): void;
  46903. /**
  46904. * Bind only the world matrix to the material.
  46905. * @param world The world matrix to bind.
  46906. */
  46907. bindOnlyWorldMatrix(world: Matrix): void;
  46908. /**
  46909. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46910. * @param world The world matrix to bind.
  46911. * @param subMesh The submesh to bind for.
  46912. */
  46913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46914. /**
  46915. * Checks to see if a texture is used in the material.
  46916. * @param texture - Base texture to use.
  46917. * @returns - Boolean specifying if a texture is used in the material.
  46918. */
  46919. hasTexture(texture: BaseTexture): boolean;
  46920. /**
  46921. * Dispose the material.
  46922. * @param forceDisposeEffect Force disposal of the associated effect.
  46923. * @param forceDisposeTextures Force disposal of the associated textures.
  46924. */
  46925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46926. /**
  46927. * Clones the material.
  46928. * @param name The cloned name.
  46929. * @returns The cloned material.
  46930. */
  46931. clone(name: string): BackgroundMaterial;
  46932. /**
  46933. * Serializes the current material to its JSON representation.
  46934. * @returns The JSON representation.
  46935. */
  46936. serialize(): any;
  46937. /**
  46938. * Gets the class name of the material
  46939. * @returns "BackgroundMaterial"
  46940. */
  46941. getClassName(): string;
  46942. /**
  46943. * Parse a JSON input to create back a background material.
  46944. * @param source The JSON data to parse
  46945. * @param scene The scene to create the parsed material in
  46946. * @param rootUrl The root url of the assets the material depends upon
  46947. * @returns the instantiated BackgroundMaterial.
  46948. */
  46949. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46950. }
  46951. }
  46952. declare module "babylonjs/Helpers/environmentHelper" {
  46953. import { Observable } from "babylonjs/Misc/observable";
  46954. import { Nullable } from "babylonjs/types";
  46955. import { Scene } from "babylonjs/scene";
  46956. import { Vector3 } from "babylonjs/Maths/math.vector";
  46957. import { Color3 } from "babylonjs/Maths/math.color";
  46958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46959. import { Mesh } from "babylonjs/Meshes/mesh";
  46960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46961. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46962. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46963. import "babylonjs/Meshes/Builders/planeBuilder";
  46964. import "babylonjs/Meshes/Builders/boxBuilder";
  46965. /**
  46966. * Represents the different options available during the creation of
  46967. * a Environment helper.
  46968. *
  46969. * This can control the default ground, skybox and image processing setup of your scene.
  46970. */
  46971. export interface IEnvironmentHelperOptions {
  46972. /**
  46973. * Specifies wether or not to create a ground.
  46974. * True by default.
  46975. */
  46976. createGround: boolean;
  46977. /**
  46978. * Specifies the ground size.
  46979. * 15 by default.
  46980. */
  46981. groundSize: number;
  46982. /**
  46983. * The texture used on the ground for the main color.
  46984. * Comes from the BabylonJS CDN by default.
  46985. *
  46986. * Remarks: Can be either a texture or a url.
  46987. */
  46988. groundTexture: string | BaseTexture;
  46989. /**
  46990. * The color mixed in the ground texture by default.
  46991. * BabylonJS clearColor by default.
  46992. */
  46993. groundColor: Color3;
  46994. /**
  46995. * Specifies the ground opacity.
  46996. * 1 by default.
  46997. */
  46998. groundOpacity: number;
  46999. /**
  47000. * Enables the ground to receive shadows.
  47001. * True by default.
  47002. */
  47003. enableGroundShadow: boolean;
  47004. /**
  47005. * Helps preventing the shadow to be fully black on the ground.
  47006. * 0.5 by default.
  47007. */
  47008. groundShadowLevel: number;
  47009. /**
  47010. * Creates a mirror texture attach to the ground.
  47011. * false by default.
  47012. */
  47013. enableGroundMirror: boolean;
  47014. /**
  47015. * Specifies the ground mirror size ratio.
  47016. * 0.3 by default as the default kernel is 64.
  47017. */
  47018. groundMirrorSizeRatio: number;
  47019. /**
  47020. * Specifies the ground mirror blur kernel size.
  47021. * 64 by default.
  47022. */
  47023. groundMirrorBlurKernel: number;
  47024. /**
  47025. * Specifies the ground mirror visibility amount.
  47026. * 1 by default
  47027. */
  47028. groundMirrorAmount: number;
  47029. /**
  47030. * Specifies the ground mirror reflectance weight.
  47031. * This uses the standard weight of the background material to setup the fresnel effect
  47032. * of the mirror.
  47033. * 1 by default.
  47034. */
  47035. groundMirrorFresnelWeight: number;
  47036. /**
  47037. * Specifies the ground mirror Falloff distance.
  47038. * This can helps reducing the size of the reflection.
  47039. * 0 by Default.
  47040. */
  47041. groundMirrorFallOffDistance: number;
  47042. /**
  47043. * Specifies the ground mirror texture type.
  47044. * Unsigned Int by Default.
  47045. */
  47046. groundMirrorTextureType: number;
  47047. /**
  47048. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47049. * the shown objects.
  47050. */
  47051. groundYBias: number;
  47052. /**
  47053. * Specifies wether or not to create a skybox.
  47054. * True by default.
  47055. */
  47056. createSkybox: boolean;
  47057. /**
  47058. * Specifies the skybox size.
  47059. * 20 by default.
  47060. */
  47061. skyboxSize: number;
  47062. /**
  47063. * The texture used on the skybox for the main color.
  47064. * Comes from the BabylonJS CDN by default.
  47065. *
  47066. * Remarks: Can be either a texture or a url.
  47067. */
  47068. skyboxTexture: string | BaseTexture;
  47069. /**
  47070. * The color mixed in the skybox texture by default.
  47071. * BabylonJS clearColor by default.
  47072. */
  47073. skyboxColor: Color3;
  47074. /**
  47075. * The background rotation around the Y axis of the scene.
  47076. * This helps aligning the key lights of your scene with the background.
  47077. * 0 by default.
  47078. */
  47079. backgroundYRotation: number;
  47080. /**
  47081. * Compute automatically the size of the elements to best fit with the scene.
  47082. */
  47083. sizeAuto: boolean;
  47084. /**
  47085. * Default position of the rootMesh if autoSize is not true.
  47086. */
  47087. rootPosition: Vector3;
  47088. /**
  47089. * Sets up the image processing in the scene.
  47090. * true by default.
  47091. */
  47092. setupImageProcessing: boolean;
  47093. /**
  47094. * The texture used as your environment texture in the scene.
  47095. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47096. *
  47097. * Remarks: Can be either a texture or a url.
  47098. */
  47099. environmentTexture: string | BaseTexture;
  47100. /**
  47101. * The value of the exposure to apply to the scene.
  47102. * 0.6 by default if setupImageProcessing is true.
  47103. */
  47104. cameraExposure: number;
  47105. /**
  47106. * The value of the contrast to apply to the scene.
  47107. * 1.6 by default if setupImageProcessing is true.
  47108. */
  47109. cameraContrast: number;
  47110. /**
  47111. * Specifies wether or not tonemapping should be enabled in the scene.
  47112. * true by default if setupImageProcessing is true.
  47113. */
  47114. toneMappingEnabled: boolean;
  47115. }
  47116. /**
  47117. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47118. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47119. * It also helps with the default setup of your imageProcessing configuration.
  47120. */
  47121. export class EnvironmentHelper {
  47122. /**
  47123. * Default ground texture URL.
  47124. */
  47125. private static _groundTextureCDNUrl;
  47126. /**
  47127. * Default skybox texture URL.
  47128. */
  47129. private static _skyboxTextureCDNUrl;
  47130. /**
  47131. * Default environment texture URL.
  47132. */
  47133. private static _environmentTextureCDNUrl;
  47134. /**
  47135. * Creates the default options for the helper.
  47136. */
  47137. private static _getDefaultOptions;
  47138. private _rootMesh;
  47139. /**
  47140. * Gets the root mesh created by the helper.
  47141. */
  47142. readonly rootMesh: Mesh;
  47143. private _skybox;
  47144. /**
  47145. * Gets the skybox created by the helper.
  47146. */
  47147. readonly skybox: Nullable<Mesh>;
  47148. private _skyboxTexture;
  47149. /**
  47150. * Gets the skybox texture created by the helper.
  47151. */
  47152. readonly skyboxTexture: Nullable<BaseTexture>;
  47153. private _skyboxMaterial;
  47154. /**
  47155. * Gets the skybox material created by the helper.
  47156. */
  47157. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47158. private _ground;
  47159. /**
  47160. * Gets the ground mesh created by the helper.
  47161. */
  47162. readonly ground: Nullable<Mesh>;
  47163. private _groundTexture;
  47164. /**
  47165. * Gets the ground texture created by the helper.
  47166. */
  47167. readonly groundTexture: Nullable<BaseTexture>;
  47168. private _groundMirror;
  47169. /**
  47170. * Gets the ground mirror created by the helper.
  47171. */
  47172. readonly groundMirror: Nullable<MirrorTexture>;
  47173. /**
  47174. * Gets the ground mirror render list to helps pushing the meshes
  47175. * you wish in the ground reflection.
  47176. */
  47177. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47178. private _groundMaterial;
  47179. /**
  47180. * Gets the ground material created by the helper.
  47181. */
  47182. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47183. /**
  47184. * Stores the creation options.
  47185. */
  47186. private readonly _scene;
  47187. private _options;
  47188. /**
  47189. * This observable will be notified with any error during the creation of the environment,
  47190. * mainly texture creation errors.
  47191. */
  47192. onErrorObservable: Observable<{
  47193. message?: string;
  47194. exception?: any;
  47195. }>;
  47196. /**
  47197. * constructor
  47198. * @param options Defines the options we want to customize the helper
  47199. * @param scene The scene to add the material to
  47200. */
  47201. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47202. /**
  47203. * Updates the background according to the new options
  47204. * @param options
  47205. */
  47206. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47207. /**
  47208. * Sets the primary color of all the available elements.
  47209. * @param color the main color to affect to the ground and the background
  47210. */
  47211. setMainColor(color: Color3): void;
  47212. /**
  47213. * Setup the image processing according to the specified options.
  47214. */
  47215. private _setupImageProcessing;
  47216. /**
  47217. * Setup the environment texture according to the specified options.
  47218. */
  47219. private _setupEnvironmentTexture;
  47220. /**
  47221. * Setup the background according to the specified options.
  47222. */
  47223. private _setupBackground;
  47224. /**
  47225. * Get the scene sizes according to the setup.
  47226. */
  47227. private _getSceneSize;
  47228. /**
  47229. * Setup the ground according to the specified options.
  47230. */
  47231. private _setupGround;
  47232. /**
  47233. * Setup the ground material according to the specified options.
  47234. */
  47235. private _setupGroundMaterial;
  47236. /**
  47237. * Setup the ground diffuse texture according to the specified options.
  47238. */
  47239. private _setupGroundDiffuseTexture;
  47240. /**
  47241. * Setup the ground mirror texture according to the specified options.
  47242. */
  47243. private _setupGroundMirrorTexture;
  47244. /**
  47245. * Setup the ground to receive the mirror texture.
  47246. */
  47247. private _setupMirrorInGroundMaterial;
  47248. /**
  47249. * Setup the skybox according to the specified options.
  47250. */
  47251. private _setupSkybox;
  47252. /**
  47253. * Setup the skybox material according to the specified options.
  47254. */
  47255. private _setupSkyboxMaterial;
  47256. /**
  47257. * Setup the skybox reflection texture according to the specified options.
  47258. */
  47259. private _setupSkyboxReflectionTexture;
  47260. private _errorHandler;
  47261. /**
  47262. * Dispose all the elements created by the Helper.
  47263. */
  47264. dispose(): void;
  47265. }
  47266. }
  47267. declare module "babylonjs/Helpers/photoDome" {
  47268. import { Observable } from "babylonjs/Misc/observable";
  47269. import { Nullable } from "babylonjs/types";
  47270. import { Scene } from "babylonjs/scene";
  47271. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47272. import { Mesh } from "babylonjs/Meshes/mesh";
  47273. import { Texture } from "babylonjs/Materials/Textures/texture";
  47274. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47275. import "babylonjs/Meshes/Builders/sphereBuilder";
  47276. /**
  47277. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47278. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47279. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47280. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47281. */
  47282. export class PhotoDome extends TransformNode {
  47283. /**
  47284. * Define the image as a Monoscopic panoramic 360 image.
  47285. */
  47286. static readonly MODE_MONOSCOPIC: number;
  47287. /**
  47288. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47289. */
  47290. static readonly MODE_TOPBOTTOM: number;
  47291. /**
  47292. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47293. */
  47294. static readonly MODE_SIDEBYSIDE: number;
  47295. private _useDirectMapping;
  47296. /**
  47297. * The texture being displayed on the sphere
  47298. */
  47299. protected _photoTexture: Texture;
  47300. /**
  47301. * Gets or sets the texture being displayed on the sphere
  47302. */
  47303. photoTexture: Texture;
  47304. /**
  47305. * Observable raised when an error occured while loading the 360 image
  47306. */
  47307. onLoadErrorObservable: Observable<string>;
  47308. /**
  47309. * The skybox material
  47310. */
  47311. protected _material: BackgroundMaterial;
  47312. /**
  47313. * The surface used for the skybox
  47314. */
  47315. protected _mesh: Mesh;
  47316. /**
  47317. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47318. * Also see the options.resolution property.
  47319. */
  47320. fovMultiplier: number;
  47321. private _imageMode;
  47322. /**
  47323. * Gets or set the current video mode for the video. It can be:
  47324. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47325. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47326. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47327. */
  47328. imageMode: number;
  47329. /**
  47330. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47331. * @param name Element's name, child elements will append suffixes for their own names.
  47332. * @param urlsOfPhoto defines the url of the photo to display
  47333. * @param options defines an object containing optional or exposed sub element properties
  47334. * @param onError defines a callback called when an error occured while loading the texture
  47335. */
  47336. constructor(name: string, urlOfPhoto: string, options: {
  47337. resolution?: number;
  47338. size?: number;
  47339. useDirectMapping?: boolean;
  47340. faceForward?: boolean;
  47341. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47342. private _onBeforeCameraRenderObserver;
  47343. private _changeImageMode;
  47344. /**
  47345. * Releases resources associated with this node.
  47346. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47347. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47348. */
  47349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47350. }
  47351. }
  47352. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47353. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47354. /** @hidden */
  47355. export var rgbdDecodePixelShader: {
  47356. name: string;
  47357. shader: string;
  47358. };
  47359. }
  47360. declare module "babylonjs/Misc/brdfTextureTools" {
  47361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47362. import { Scene } from "babylonjs/scene";
  47363. import "babylonjs/Shaders/rgbdDecode.fragment";
  47364. /**
  47365. * Class used to host texture specific utilities
  47366. */
  47367. export class BRDFTextureTools {
  47368. /**
  47369. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47370. * @param texture the texture to expand.
  47371. */
  47372. private static _ExpandDefaultBRDFTexture;
  47373. /**
  47374. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47375. * @param scene defines the hosting scene
  47376. * @returns the environment BRDF texture
  47377. */
  47378. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47379. private static _environmentBRDFBase64Texture;
  47380. }
  47381. }
  47382. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47383. import { Nullable } from "babylonjs/types";
  47384. import { Color3 } from "babylonjs/Maths/math.color";
  47385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47386. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47388. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47389. import { Engine } from "babylonjs/Engines/engine";
  47390. import { Scene } from "babylonjs/scene";
  47391. /**
  47392. * @hidden
  47393. */
  47394. export interface IMaterialClearCoatDefines {
  47395. CLEARCOAT: boolean;
  47396. CLEARCOAT_DEFAULTIOR: boolean;
  47397. CLEARCOAT_TEXTURE: boolean;
  47398. CLEARCOAT_TEXTUREDIRECTUV: number;
  47399. CLEARCOAT_BUMP: boolean;
  47400. CLEARCOAT_BUMPDIRECTUV: number;
  47401. CLEARCOAT_TINT: boolean;
  47402. CLEARCOAT_TINT_TEXTURE: boolean;
  47403. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47404. /** @hidden */
  47405. _areTexturesDirty: boolean;
  47406. }
  47407. /**
  47408. * Define the code related to the clear coat parameters of the pbr material.
  47409. */
  47410. export class PBRClearCoatConfiguration {
  47411. /**
  47412. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47413. * The default fits with a polyurethane material.
  47414. */
  47415. private static readonly _DefaultIndexOfRefraction;
  47416. private _isEnabled;
  47417. /**
  47418. * Defines if the clear coat is enabled in the material.
  47419. */
  47420. isEnabled: boolean;
  47421. /**
  47422. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47423. */
  47424. intensity: number;
  47425. /**
  47426. * Defines the clear coat layer roughness.
  47427. */
  47428. roughness: number;
  47429. private _indexOfRefraction;
  47430. /**
  47431. * Defines the index of refraction of the clear coat.
  47432. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47433. * The default fits with a polyurethane material.
  47434. * Changing the default value is more performance intensive.
  47435. */
  47436. indexOfRefraction: number;
  47437. private _texture;
  47438. /**
  47439. * Stores the clear coat values in a texture.
  47440. */
  47441. texture: Nullable<BaseTexture>;
  47442. private _bumpTexture;
  47443. /**
  47444. * Define the clear coat specific bump texture.
  47445. */
  47446. bumpTexture: Nullable<BaseTexture>;
  47447. private _isTintEnabled;
  47448. /**
  47449. * Defines if the clear coat tint is enabled in the material.
  47450. */
  47451. isTintEnabled: boolean;
  47452. /**
  47453. * Defines the clear coat tint of the material.
  47454. * This is only use if tint is enabled
  47455. */
  47456. tintColor: Color3;
  47457. /**
  47458. * Defines the distance at which the tint color should be found in the
  47459. * clear coat media.
  47460. * This is only use if tint is enabled
  47461. */
  47462. tintColorAtDistance: number;
  47463. /**
  47464. * Defines the clear coat layer thickness.
  47465. * This is only use if tint is enabled
  47466. */
  47467. tintThickness: number;
  47468. private _tintTexture;
  47469. /**
  47470. * Stores the clear tint values in a texture.
  47471. * rgb is tint
  47472. * a is a thickness factor
  47473. */
  47474. tintTexture: Nullable<BaseTexture>;
  47475. /** @hidden */
  47476. private _internalMarkAllSubMeshesAsTexturesDirty;
  47477. /** @hidden */
  47478. _markAllSubMeshesAsTexturesDirty(): void;
  47479. /**
  47480. * Instantiate a new istance of clear coat configuration.
  47481. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47482. */
  47483. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47484. /**
  47485. * Gets wehter the submesh is ready to be used or not.
  47486. * @param defines the list of "defines" to update.
  47487. * @param scene defines the scene the material belongs to.
  47488. * @param engine defines the engine the material belongs to.
  47489. * @param disableBumpMap defines wether the material disables bump or not.
  47490. * @returns - boolean indicating that the submesh is ready or not.
  47491. */
  47492. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47493. /**
  47494. * Checks to see if a texture is used in the material.
  47495. * @param defines the list of "defines" to update.
  47496. * @param scene defines the scene to the material belongs to.
  47497. */
  47498. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47499. /**
  47500. * Binds the material data.
  47501. * @param uniformBuffer defines the Uniform buffer to fill in.
  47502. * @param scene defines the scene the material belongs to.
  47503. * @param engine defines the engine the material belongs to.
  47504. * @param disableBumpMap defines wether the material disables bump or not.
  47505. * @param isFrozen defines wether the material is frozen or not.
  47506. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47507. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47508. */
  47509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47510. /**
  47511. * Checks to see if a texture is used in the material.
  47512. * @param texture - Base texture to use.
  47513. * @returns - Boolean specifying if a texture is used in the material.
  47514. */
  47515. hasTexture(texture: BaseTexture): boolean;
  47516. /**
  47517. * Returns an array of the actively used textures.
  47518. * @param activeTextures Array of BaseTextures
  47519. */
  47520. getActiveTextures(activeTextures: BaseTexture[]): void;
  47521. /**
  47522. * Returns the animatable textures.
  47523. * @param animatables Array of animatable textures.
  47524. */
  47525. getAnimatables(animatables: IAnimatable[]): void;
  47526. /**
  47527. * Disposes the resources of the material.
  47528. * @param forceDisposeTextures - Forces the disposal of all textures.
  47529. */
  47530. dispose(forceDisposeTextures?: boolean): void;
  47531. /**
  47532. * Get the current class name of the texture useful for serialization or dynamic coding.
  47533. * @returns "PBRClearCoatConfiguration"
  47534. */
  47535. getClassName(): string;
  47536. /**
  47537. * Add fallbacks to the effect fallbacks list.
  47538. * @param defines defines the Base texture to use.
  47539. * @param fallbacks defines the current fallback list.
  47540. * @param currentRank defines the current fallback rank.
  47541. * @returns the new fallback rank.
  47542. */
  47543. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47544. /**
  47545. * Add the required uniforms to the current list.
  47546. * @param uniforms defines the current uniform list.
  47547. */
  47548. static AddUniforms(uniforms: string[]): void;
  47549. /**
  47550. * Add the required samplers to the current list.
  47551. * @param samplers defines the current sampler list.
  47552. */
  47553. static AddSamplers(samplers: string[]): void;
  47554. /**
  47555. * Add the required uniforms to the current buffer.
  47556. * @param uniformBuffer defines the current uniform buffer.
  47557. */
  47558. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47559. /**
  47560. * Makes a duplicate of the current configuration into another one.
  47561. * @param clearCoatConfiguration define the config where to copy the info
  47562. */
  47563. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47564. /**
  47565. * Serializes this clear coat configuration.
  47566. * @returns - An object with the serialized config.
  47567. */
  47568. serialize(): any;
  47569. /**
  47570. * Parses a anisotropy Configuration from a serialized object.
  47571. * @param source - Serialized object.
  47572. * @param scene Defines the scene we are parsing for
  47573. * @param rootUrl Defines the rootUrl to load from
  47574. */
  47575. parse(source: any, scene: Scene, rootUrl: string): void;
  47576. }
  47577. }
  47578. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47579. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47580. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47582. import { Vector2 } from "babylonjs/Maths/math.vector";
  47583. import { Scene } from "babylonjs/scene";
  47584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47585. import { Nullable } from "babylonjs/types";
  47586. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47587. /**
  47588. * @hidden
  47589. */
  47590. export interface IMaterialAnisotropicDefines {
  47591. ANISOTROPIC: boolean;
  47592. ANISOTROPIC_TEXTURE: boolean;
  47593. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47594. MAINUV1: boolean;
  47595. _areTexturesDirty: boolean;
  47596. _needUVs: boolean;
  47597. }
  47598. /**
  47599. * Define the code related to the anisotropic parameters of the pbr material.
  47600. */
  47601. export class PBRAnisotropicConfiguration {
  47602. private _isEnabled;
  47603. /**
  47604. * Defines if the anisotropy is enabled in the material.
  47605. */
  47606. isEnabled: boolean;
  47607. /**
  47608. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47609. */
  47610. intensity: number;
  47611. /**
  47612. * Defines if the effect is along the tangents, bitangents or in between.
  47613. * By default, the effect is "strectching" the highlights along the tangents.
  47614. */
  47615. direction: Vector2;
  47616. private _texture;
  47617. /**
  47618. * Stores the anisotropy values in a texture.
  47619. * rg is direction (like normal from -1 to 1)
  47620. * b is a intensity
  47621. */
  47622. texture: Nullable<BaseTexture>;
  47623. /** @hidden */
  47624. private _internalMarkAllSubMeshesAsTexturesDirty;
  47625. /** @hidden */
  47626. _markAllSubMeshesAsTexturesDirty(): void;
  47627. /**
  47628. * Instantiate a new istance of anisotropy configuration.
  47629. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47630. */
  47631. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47632. /**
  47633. * Specifies that the submesh is ready to be used.
  47634. * @param defines the list of "defines" to update.
  47635. * @param scene defines the scene the material belongs to.
  47636. * @returns - boolean indicating that the submesh is ready or not.
  47637. */
  47638. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47639. /**
  47640. * Checks to see if a texture is used in the material.
  47641. * @param defines the list of "defines" to update.
  47642. * @param mesh the mesh we are preparing the defines for.
  47643. * @param scene defines the scene the material belongs to.
  47644. */
  47645. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47646. /**
  47647. * Binds the material data.
  47648. * @param uniformBuffer defines the Uniform buffer to fill in.
  47649. * @param scene defines the scene the material belongs to.
  47650. * @param isFrozen defines wether the material is frozen or not.
  47651. */
  47652. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47653. /**
  47654. * Checks to see if a texture is used in the material.
  47655. * @param texture - Base texture to use.
  47656. * @returns - Boolean specifying if a texture is used in the material.
  47657. */
  47658. hasTexture(texture: BaseTexture): boolean;
  47659. /**
  47660. * Returns an array of the actively used textures.
  47661. * @param activeTextures Array of BaseTextures
  47662. */
  47663. getActiveTextures(activeTextures: BaseTexture[]): void;
  47664. /**
  47665. * Returns the animatable textures.
  47666. * @param animatables Array of animatable textures.
  47667. */
  47668. getAnimatables(animatables: IAnimatable[]): void;
  47669. /**
  47670. * Disposes the resources of the material.
  47671. * @param forceDisposeTextures - Forces the disposal of all textures.
  47672. */
  47673. dispose(forceDisposeTextures?: boolean): void;
  47674. /**
  47675. * Get the current class name of the texture useful for serialization or dynamic coding.
  47676. * @returns "PBRAnisotropicConfiguration"
  47677. */
  47678. getClassName(): string;
  47679. /**
  47680. * Add fallbacks to the effect fallbacks list.
  47681. * @param defines defines the Base texture to use.
  47682. * @param fallbacks defines the current fallback list.
  47683. * @param currentRank defines the current fallback rank.
  47684. * @returns the new fallback rank.
  47685. */
  47686. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47687. /**
  47688. * Add the required uniforms to the current list.
  47689. * @param uniforms defines the current uniform list.
  47690. */
  47691. static AddUniforms(uniforms: string[]): void;
  47692. /**
  47693. * Add the required uniforms to the current buffer.
  47694. * @param uniformBuffer defines the current uniform buffer.
  47695. */
  47696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47697. /**
  47698. * Add the required samplers to the current list.
  47699. * @param samplers defines the current sampler list.
  47700. */
  47701. static AddSamplers(samplers: string[]): void;
  47702. /**
  47703. * Makes a duplicate of the current configuration into another one.
  47704. * @param anisotropicConfiguration define the config where to copy the info
  47705. */
  47706. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47707. /**
  47708. * Serializes this anisotropy configuration.
  47709. * @returns - An object with the serialized config.
  47710. */
  47711. serialize(): any;
  47712. /**
  47713. * Parses a anisotropy Configuration from a serialized object.
  47714. * @param source - Serialized object.
  47715. * @param scene Defines the scene we are parsing for
  47716. * @param rootUrl Defines the rootUrl to load from
  47717. */
  47718. parse(source: any, scene: Scene, rootUrl: string): void;
  47719. }
  47720. }
  47721. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47722. import { Scene } from "babylonjs/scene";
  47723. /**
  47724. * @hidden
  47725. */
  47726. export interface IMaterialBRDFDefines {
  47727. BRDF_V_HEIGHT_CORRELATED: boolean;
  47728. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47729. SPHERICAL_HARMONICS: boolean;
  47730. /** @hidden */
  47731. _areMiscDirty: boolean;
  47732. }
  47733. /**
  47734. * Define the code related to the BRDF parameters of the pbr material.
  47735. */
  47736. export class PBRBRDFConfiguration {
  47737. /**
  47738. * Default value used for the energy conservation.
  47739. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47740. */
  47741. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47742. /**
  47743. * Default value used for the Smith Visibility Height Correlated mode.
  47744. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47745. */
  47746. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47747. /**
  47748. * Default value used for the IBL diffuse part.
  47749. * This can help switching back to the polynomials mode globally which is a tiny bit
  47750. * less GPU intensive at the drawback of a lower quality.
  47751. */
  47752. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47753. private _useEnergyConservation;
  47754. /**
  47755. * Defines if the material uses energy conservation.
  47756. */
  47757. useEnergyConservation: boolean;
  47758. private _useSmithVisibilityHeightCorrelated;
  47759. /**
  47760. * LEGACY Mode set to false
  47761. * Defines if the material uses height smith correlated visibility term.
  47762. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47763. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47764. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47765. * Not relying on height correlated will also disable energy conservation.
  47766. */
  47767. useSmithVisibilityHeightCorrelated: boolean;
  47768. private _useSphericalHarmonics;
  47769. /**
  47770. * LEGACY Mode set to false
  47771. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47772. * diffuse part of the IBL.
  47773. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47774. * to the ground truth.
  47775. */
  47776. useSphericalHarmonics: boolean;
  47777. /** @hidden */
  47778. private _internalMarkAllSubMeshesAsMiscDirty;
  47779. /** @hidden */
  47780. _markAllSubMeshesAsMiscDirty(): void;
  47781. /**
  47782. * Instantiate a new istance of clear coat configuration.
  47783. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47784. */
  47785. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47786. /**
  47787. * Checks to see if a texture is used in the material.
  47788. * @param defines the list of "defines" to update.
  47789. */
  47790. prepareDefines(defines: IMaterialBRDFDefines): void;
  47791. /**
  47792. * Get the current class name of the texture useful for serialization or dynamic coding.
  47793. * @returns "PBRClearCoatConfiguration"
  47794. */
  47795. getClassName(): string;
  47796. /**
  47797. * Makes a duplicate of the current configuration into another one.
  47798. * @param brdfConfiguration define the config where to copy the info
  47799. */
  47800. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47801. /**
  47802. * Serializes this BRDF configuration.
  47803. * @returns - An object with the serialized config.
  47804. */
  47805. serialize(): any;
  47806. /**
  47807. * Parses a anisotropy Configuration from a serialized object.
  47808. * @param source - Serialized object.
  47809. * @param scene Defines the scene we are parsing for
  47810. * @param rootUrl Defines the rootUrl to load from
  47811. */
  47812. parse(source: any, scene: Scene, rootUrl: string): void;
  47813. }
  47814. }
  47815. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47816. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47817. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47818. import { Color3 } from "babylonjs/Maths/math.color";
  47819. import { Scene } from "babylonjs/scene";
  47820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47821. import { Nullable } from "babylonjs/types";
  47822. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47823. /**
  47824. * @hidden
  47825. */
  47826. export interface IMaterialSheenDefines {
  47827. SHEEN: boolean;
  47828. SHEEN_TEXTURE: boolean;
  47829. SHEEN_TEXTUREDIRECTUV: number;
  47830. SHEEN_LINKWITHALBEDO: boolean;
  47831. /** @hidden */
  47832. _areTexturesDirty: boolean;
  47833. }
  47834. /**
  47835. * Define the code related to the Sheen parameters of the pbr material.
  47836. */
  47837. export class PBRSheenConfiguration {
  47838. private _isEnabled;
  47839. /**
  47840. * Defines if the material uses sheen.
  47841. */
  47842. isEnabled: boolean;
  47843. private _linkSheenWithAlbedo;
  47844. /**
  47845. * Defines if the sheen is linked to the sheen color.
  47846. */
  47847. linkSheenWithAlbedo: boolean;
  47848. /**
  47849. * Defines the sheen intensity.
  47850. */
  47851. intensity: number;
  47852. /**
  47853. * Defines the sheen color.
  47854. */
  47855. color: Color3;
  47856. private _texture;
  47857. /**
  47858. * Stores the sheen tint values in a texture.
  47859. * rgb is tint
  47860. * a is a intensity
  47861. */
  47862. texture: Nullable<BaseTexture>;
  47863. /** @hidden */
  47864. private _internalMarkAllSubMeshesAsTexturesDirty;
  47865. /** @hidden */
  47866. _markAllSubMeshesAsTexturesDirty(): void;
  47867. /**
  47868. * Instantiate a new istance of clear coat configuration.
  47869. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47870. */
  47871. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47872. /**
  47873. * Specifies that the submesh is ready to be used.
  47874. * @param defines the list of "defines" to update.
  47875. * @param scene defines the scene the material belongs to.
  47876. * @returns - boolean indicating that the submesh is ready or not.
  47877. */
  47878. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47879. /**
  47880. * Checks to see if a texture is used in the material.
  47881. * @param defines the list of "defines" to update.
  47882. * @param scene defines the scene the material belongs to.
  47883. */
  47884. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47885. /**
  47886. * Binds the material data.
  47887. * @param uniformBuffer defines the Uniform buffer to fill in.
  47888. * @param scene defines the scene the material belongs to.
  47889. * @param isFrozen defines wether the material is frozen or not.
  47890. */
  47891. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47892. /**
  47893. * Checks to see if a texture is used in the material.
  47894. * @param texture - Base texture to use.
  47895. * @returns - Boolean specifying if a texture is used in the material.
  47896. */
  47897. hasTexture(texture: BaseTexture): boolean;
  47898. /**
  47899. * Returns an array of the actively used textures.
  47900. * @param activeTextures Array of BaseTextures
  47901. */
  47902. getActiveTextures(activeTextures: BaseTexture[]): void;
  47903. /**
  47904. * Returns the animatable textures.
  47905. * @param animatables Array of animatable textures.
  47906. */
  47907. getAnimatables(animatables: IAnimatable[]): void;
  47908. /**
  47909. * Disposes the resources of the material.
  47910. * @param forceDisposeTextures - Forces the disposal of all textures.
  47911. */
  47912. dispose(forceDisposeTextures?: boolean): void;
  47913. /**
  47914. * Get the current class name of the texture useful for serialization or dynamic coding.
  47915. * @returns "PBRSheenConfiguration"
  47916. */
  47917. getClassName(): string;
  47918. /**
  47919. * Add fallbacks to the effect fallbacks list.
  47920. * @param defines defines the Base texture to use.
  47921. * @param fallbacks defines the current fallback list.
  47922. * @param currentRank defines the current fallback rank.
  47923. * @returns the new fallback rank.
  47924. */
  47925. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47926. /**
  47927. * Add the required uniforms to the current list.
  47928. * @param uniforms defines the current uniform list.
  47929. */
  47930. static AddUniforms(uniforms: string[]): void;
  47931. /**
  47932. * Add the required uniforms to the current buffer.
  47933. * @param uniformBuffer defines the current uniform buffer.
  47934. */
  47935. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47936. /**
  47937. * Add the required samplers to the current list.
  47938. * @param samplers defines the current sampler list.
  47939. */
  47940. static AddSamplers(samplers: string[]): void;
  47941. /**
  47942. * Makes a duplicate of the current configuration into another one.
  47943. * @param sheenConfiguration define the config where to copy the info
  47944. */
  47945. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47946. /**
  47947. * Serializes this BRDF configuration.
  47948. * @returns - An object with the serialized config.
  47949. */
  47950. serialize(): any;
  47951. /**
  47952. * Parses a anisotropy Configuration from a serialized object.
  47953. * @param source - Serialized object.
  47954. * @param scene Defines the scene we are parsing for
  47955. * @param rootUrl Defines the rootUrl to load from
  47956. */
  47957. parse(source: any, scene: Scene, rootUrl: string): void;
  47958. }
  47959. }
  47960. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47961. import { Nullable } from "babylonjs/types";
  47962. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47963. import { Color3 } from "babylonjs/Maths/math.color";
  47964. import { SmartArray } from "babylonjs/Misc/smartArray";
  47965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47966. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47967. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47968. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47969. import { Engine } from "babylonjs/Engines/engine";
  47970. import { Scene } from "babylonjs/scene";
  47971. /**
  47972. * @hidden
  47973. */
  47974. export interface IMaterialSubSurfaceDefines {
  47975. SUBSURFACE: boolean;
  47976. SS_REFRACTION: boolean;
  47977. SS_TRANSLUCENCY: boolean;
  47978. SS_SCATERRING: boolean;
  47979. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47980. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47981. SS_REFRACTIONMAP_3D: boolean;
  47982. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47983. SS_LODINREFRACTIONALPHA: boolean;
  47984. SS_GAMMAREFRACTION: boolean;
  47985. SS_RGBDREFRACTION: boolean;
  47986. SS_LINEARSPECULARREFRACTION: boolean;
  47987. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47988. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47989. /** @hidden */
  47990. _areTexturesDirty: boolean;
  47991. }
  47992. /**
  47993. * Define the code related to the sub surface parameters of the pbr material.
  47994. */
  47995. export class PBRSubSurfaceConfiguration {
  47996. private _isRefractionEnabled;
  47997. /**
  47998. * Defines if the refraction is enabled in the material.
  47999. */
  48000. isRefractionEnabled: boolean;
  48001. private _isTranslucencyEnabled;
  48002. /**
  48003. * Defines if the translucency is enabled in the material.
  48004. */
  48005. isTranslucencyEnabled: boolean;
  48006. private _isScatteringEnabled;
  48007. /**
  48008. * Defines the refraction intensity of the material.
  48009. * The refraction when enabled replaces the Diffuse part of the material.
  48010. * The intensity helps transitionning between diffuse and refraction.
  48011. */
  48012. refractionIntensity: number;
  48013. /**
  48014. * Defines the translucency intensity of the material.
  48015. * When translucency has been enabled, this defines how much of the "translucency"
  48016. * is addded to the diffuse part of the material.
  48017. */
  48018. translucencyIntensity: number;
  48019. /**
  48020. * Defines the scattering intensity of the material.
  48021. * When scattering has been enabled, this defines how much of the "scattered light"
  48022. * is addded to the diffuse part of the material.
  48023. */
  48024. scatteringIntensity: number;
  48025. private _thicknessTexture;
  48026. /**
  48027. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48028. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48029. * 0 would mean minimumThickness
  48030. * 1 would mean maximumThickness
  48031. * The other channels might be use as a mask to vary the different effects intensity.
  48032. */
  48033. thicknessTexture: Nullable<BaseTexture>;
  48034. private _refractionTexture;
  48035. /**
  48036. * Defines the texture to use for refraction.
  48037. */
  48038. refractionTexture: Nullable<BaseTexture>;
  48039. private _indexOfRefraction;
  48040. /**
  48041. * Defines the index of refraction used in the material.
  48042. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48043. */
  48044. indexOfRefraction: number;
  48045. private _invertRefractionY;
  48046. /**
  48047. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48048. */
  48049. invertRefractionY: boolean;
  48050. private _linkRefractionWithTransparency;
  48051. /**
  48052. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48053. * Materials half opaque for instance using refraction could benefit from this control.
  48054. */
  48055. linkRefractionWithTransparency: boolean;
  48056. /**
  48057. * Defines the minimum thickness stored in the thickness map.
  48058. * If no thickness map is defined, this value will be used to simulate thickness.
  48059. */
  48060. minimumThickness: number;
  48061. /**
  48062. * Defines the maximum thickness stored in the thickness map.
  48063. */
  48064. maximumThickness: number;
  48065. /**
  48066. * Defines the volume tint of the material.
  48067. * This is used for both translucency and scattering.
  48068. */
  48069. tintColor: Color3;
  48070. /**
  48071. * Defines the distance at which the tint color should be found in the media.
  48072. * This is used for refraction only.
  48073. */
  48074. tintColorAtDistance: number;
  48075. /**
  48076. * Defines how far each channel transmit through the media.
  48077. * It is defined as a color to simplify it selection.
  48078. */
  48079. diffusionDistance: Color3;
  48080. private _useMaskFromThicknessTexture;
  48081. /**
  48082. * Stores the intensity of the different subsurface effects in the thickness texture.
  48083. * * the green channel is the translucency intensity.
  48084. * * the blue channel is the scattering intensity.
  48085. * * the alpha channel is the refraction intensity.
  48086. */
  48087. useMaskFromThicknessTexture: boolean;
  48088. /** @hidden */
  48089. private _internalMarkAllSubMeshesAsTexturesDirty;
  48090. /** @hidden */
  48091. _markAllSubMeshesAsTexturesDirty(): void;
  48092. /**
  48093. * Instantiate a new istance of sub surface configuration.
  48094. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48095. */
  48096. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48097. /**
  48098. * Gets wehter the submesh is ready to be used or not.
  48099. * @param defines the list of "defines" to update.
  48100. * @param scene defines the scene the material belongs to.
  48101. * @returns - boolean indicating that the submesh is ready or not.
  48102. */
  48103. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48104. /**
  48105. * Checks to see if a texture is used in the material.
  48106. * @param defines the list of "defines" to update.
  48107. * @param scene defines the scene to the material belongs to.
  48108. */
  48109. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48110. /**
  48111. * Binds the material data.
  48112. * @param uniformBuffer defines the Uniform buffer to fill in.
  48113. * @param scene defines the scene the material belongs to.
  48114. * @param engine defines the engine the material belongs to.
  48115. * @param isFrozen defines wether the material is frozen or not.
  48116. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48117. */
  48118. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48119. /**
  48120. * Unbinds the material from the mesh.
  48121. * @param activeEffect defines the effect that should be unbound from.
  48122. * @returns true if unbound, otherwise false
  48123. */
  48124. unbind(activeEffect: Effect): boolean;
  48125. /**
  48126. * Returns the texture used for refraction or null if none is used.
  48127. * @param scene defines the scene the material belongs to.
  48128. * @returns - Refraction texture if present. If no refraction texture and refraction
  48129. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48130. */
  48131. private _getRefractionTexture;
  48132. /**
  48133. * Returns true if alpha blending should be disabled.
  48134. */
  48135. readonly disableAlphaBlending: boolean;
  48136. /**
  48137. * Fills the list of render target textures.
  48138. * @param renderTargets the list of render targets to update
  48139. */
  48140. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48141. /**
  48142. * Checks to see if a texture is used in the material.
  48143. * @param texture - Base texture to use.
  48144. * @returns - Boolean specifying if a texture is used in the material.
  48145. */
  48146. hasTexture(texture: BaseTexture): boolean;
  48147. /**
  48148. * Gets a boolean indicating that current material needs to register RTT
  48149. * @returns true if this uses a render target otherwise false.
  48150. */
  48151. hasRenderTargetTextures(): boolean;
  48152. /**
  48153. * Returns an array of the actively used textures.
  48154. * @param activeTextures Array of BaseTextures
  48155. */
  48156. getActiveTextures(activeTextures: BaseTexture[]): void;
  48157. /**
  48158. * Returns the animatable textures.
  48159. * @param animatables Array of animatable textures.
  48160. */
  48161. getAnimatables(animatables: IAnimatable[]): void;
  48162. /**
  48163. * Disposes the resources of the material.
  48164. * @param forceDisposeTextures - Forces the disposal of all textures.
  48165. */
  48166. dispose(forceDisposeTextures?: boolean): void;
  48167. /**
  48168. * Get the current class name of the texture useful for serialization or dynamic coding.
  48169. * @returns "PBRSubSurfaceConfiguration"
  48170. */
  48171. getClassName(): string;
  48172. /**
  48173. * Add fallbacks to the effect fallbacks list.
  48174. * @param defines defines the Base texture to use.
  48175. * @param fallbacks defines the current fallback list.
  48176. * @param currentRank defines the current fallback rank.
  48177. * @returns the new fallback rank.
  48178. */
  48179. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48180. /**
  48181. * Add the required uniforms to the current list.
  48182. * @param uniforms defines the current uniform list.
  48183. */
  48184. static AddUniforms(uniforms: string[]): void;
  48185. /**
  48186. * Add the required samplers to the current list.
  48187. * @param samplers defines the current sampler list.
  48188. */
  48189. static AddSamplers(samplers: string[]): void;
  48190. /**
  48191. * Add the required uniforms to the current buffer.
  48192. * @param uniformBuffer defines the current uniform buffer.
  48193. */
  48194. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48195. /**
  48196. * Makes a duplicate of the current configuration into another one.
  48197. * @param configuration define the config where to copy the info
  48198. */
  48199. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48200. /**
  48201. * Serializes this Sub Surface configuration.
  48202. * @returns - An object with the serialized config.
  48203. */
  48204. serialize(): any;
  48205. /**
  48206. * Parses a anisotropy Configuration from a serialized object.
  48207. * @param source - Serialized object.
  48208. * @param scene Defines the scene we are parsing for
  48209. * @param rootUrl Defines the rootUrl to load from
  48210. */
  48211. parse(source: any, scene: Scene, rootUrl: string): void;
  48212. }
  48213. }
  48214. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48215. /** @hidden */
  48216. export var pbrFragmentDeclaration: {
  48217. name: string;
  48218. shader: string;
  48219. };
  48220. }
  48221. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48222. /** @hidden */
  48223. export var pbrUboDeclaration: {
  48224. name: string;
  48225. shader: string;
  48226. };
  48227. }
  48228. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48229. /** @hidden */
  48230. export var pbrFragmentExtraDeclaration: {
  48231. name: string;
  48232. shader: string;
  48233. };
  48234. }
  48235. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48236. /** @hidden */
  48237. export var pbrFragmentSamplersDeclaration: {
  48238. name: string;
  48239. shader: string;
  48240. };
  48241. }
  48242. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48243. /** @hidden */
  48244. export var pbrHelperFunctions: {
  48245. name: string;
  48246. shader: string;
  48247. };
  48248. }
  48249. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48250. /** @hidden */
  48251. export var harmonicsFunctions: {
  48252. name: string;
  48253. shader: string;
  48254. };
  48255. }
  48256. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48257. /** @hidden */
  48258. export var pbrDirectLightingSetupFunctions: {
  48259. name: string;
  48260. shader: string;
  48261. };
  48262. }
  48263. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48264. /** @hidden */
  48265. export var pbrDirectLightingFalloffFunctions: {
  48266. name: string;
  48267. shader: string;
  48268. };
  48269. }
  48270. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48271. /** @hidden */
  48272. export var pbrBRDFFunctions: {
  48273. name: string;
  48274. shader: string;
  48275. };
  48276. }
  48277. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48278. /** @hidden */
  48279. export var pbrDirectLightingFunctions: {
  48280. name: string;
  48281. shader: string;
  48282. };
  48283. }
  48284. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48285. /** @hidden */
  48286. export var pbrIBLFunctions: {
  48287. name: string;
  48288. shader: string;
  48289. };
  48290. }
  48291. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48292. /** @hidden */
  48293. export var pbrDebug: {
  48294. name: string;
  48295. shader: string;
  48296. };
  48297. }
  48298. declare module "babylonjs/Shaders/pbr.fragment" {
  48299. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48300. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48301. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48302. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48303. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48304. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48305. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48306. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48307. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48308. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48309. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48310. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48311. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48312. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48313. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48314. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48315. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48316. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48317. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48318. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48319. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48320. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48322. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48323. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48324. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48325. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48326. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48327. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48328. /** @hidden */
  48329. export var pbrPixelShader: {
  48330. name: string;
  48331. shader: string;
  48332. };
  48333. }
  48334. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48335. /** @hidden */
  48336. export var pbrVertexDeclaration: {
  48337. name: string;
  48338. shader: string;
  48339. };
  48340. }
  48341. declare module "babylonjs/Shaders/pbr.vertex" {
  48342. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48343. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48344. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48345. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48346. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48347. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48348. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48349. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48350. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48351. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48352. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48353. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48354. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48355. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48356. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48357. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48358. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48359. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48360. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48361. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48362. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48363. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48364. /** @hidden */
  48365. export var pbrVertexShader: {
  48366. name: string;
  48367. shader: string;
  48368. };
  48369. }
  48370. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48371. import { Nullable } from "babylonjs/types";
  48372. import { Scene } from "babylonjs/scene";
  48373. import { Matrix } from "babylonjs/Maths/math.vector";
  48374. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48376. import { Mesh } from "babylonjs/Meshes/mesh";
  48377. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48378. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48379. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48380. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48381. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48382. import { Color3 } from "babylonjs/Maths/math.color";
  48383. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48384. import { Material } from "babylonjs/Materials/material";
  48385. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48386. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48388. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48389. import "babylonjs/Shaders/pbr.fragment";
  48390. import "babylonjs/Shaders/pbr.vertex";
  48391. /**
  48392. * Manages the defines for the PBR Material.
  48393. * @hidden
  48394. */
  48395. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48396. PBR: boolean;
  48397. MAINUV1: boolean;
  48398. MAINUV2: boolean;
  48399. UV1: boolean;
  48400. UV2: boolean;
  48401. ALBEDO: boolean;
  48402. ALBEDODIRECTUV: number;
  48403. VERTEXCOLOR: boolean;
  48404. AMBIENT: boolean;
  48405. AMBIENTDIRECTUV: number;
  48406. AMBIENTINGRAYSCALE: boolean;
  48407. OPACITY: boolean;
  48408. VERTEXALPHA: boolean;
  48409. OPACITYDIRECTUV: number;
  48410. OPACITYRGB: boolean;
  48411. ALPHATEST: boolean;
  48412. DEPTHPREPASS: boolean;
  48413. ALPHABLEND: boolean;
  48414. ALPHAFROMALBEDO: boolean;
  48415. ALPHATESTVALUE: string;
  48416. SPECULAROVERALPHA: boolean;
  48417. RADIANCEOVERALPHA: boolean;
  48418. ALPHAFRESNEL: boolean;
  48419. LINEARALPHAFRESNEL: boolean;
  48420. PREMULTIPLYALPHA: boolean;
  48421. EMISSIVE: boolean;
  48422. EMISSIVEDIRECTUV: number;
  48423. REFLECTIVITY: boolean;
  48424. REFLECTIVITYDIRECTUV: number;
  48425. SPECULARTERM: boolean;
  48426. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48427. MICROSURFACEAUTOMATIC: boolean;
  48428. LODBASEDMICROSFURACE: boolean;
  48429. MICROSURFACEMAP: boolean;
  48430. MICROSURFACEMAPDIRECTUV: number;
  48431. METALLICWORKFLOW: boolean;
  48432. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48433. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48434. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48435. AOSTOREINMETALMAPRED: boolean;
  48436. ENVIRONMENTBRDF: boolean;
  48437. ENVIRONMENTBRDF_RGBD: boolean;
  48438. NORMAL: boolean;
  48439. TANGENT: boolean;
  48440. BUMP: boolean;
  48441. BUMPDIRECTUV: number;
  48442. OBJECTSPACE_NORMALMAP: boolean;
  48443. PARALLAX: boolean;
  48444. PARALLAXOCCLUSION: boolean;
  48445. NORMALXYSCALE: boolean;
  48446. LIGHTMAP: boolean;
  48447. LIGHTMAPDIRECTUV: number;
  48448. USELIGHTMAPASSHADOWMAP: boolean;
  48449. GAMMALIGHTMAP: boolean;
  48450. REFLECTION: boolean;
  48451. REFLECTIONMAP_3D: boolean;
  48452. REFLECTIONMAP_SPHERICAL: boolean;
  48453. REFLECTIONMAP_PLANAR: boolean;
  48454. REFLECTIONMAP_CUBIC: boolean;
  48455. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48456. REFLECTIONMAP_PROJECTION: boolean;
  48457. REFLECTIONMAP_SKYBOX: boolean;
  48458. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48459. REFLECTIONMAP_EXPLICIT: boolean;
  48460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48463. INVERTCUBICMAP: boolean;
  48464. USESPHERICALFROMREFLECTIONMAP: boolean;
  48465. USEIRRADIANCEMAP: boolean;
  48466. SPHERICAL_HARMONICS: boolean;
  48467. USESPHERICALINVERTEX: boolean;
  48468. REFLECTIONMAP_OPPOSITEZ: boolean;
  48469. LODINREFLECTIONALPHA: boolean;
  48470. GAMMAREFLECTION: boolean;
  48471. RGBDREFLECTION: boolean;
  48472. LINEARSPECULARREFLECTION: boolean;
  48473. RADIANCEOCCLUSION: boolean;
  48474. HORIZONOCCLUSION: boolean;
  48475. INSTANCES: boolean;
  48476. NUM_BONE_INFLUENCERS: number;
  48477. BonesPerMesh: number;
  48478. BONETEXTURE: boolean;
  48479. NONUNIFORMSCALING: boolean;
  48480. MORPHTARGETS: boolean;
  48481. MORPHTARGETS_NORMAL: boolean;
  48482. MORPHTARGETS_TANGENT: boolean;
  48483. MORPHTARGETS_UV: boolean;
  48484. NUM_MORPH_INFLUENCERS: number;
  48485. IMAGEPROCESSING: boolean;
  48486. VIGNETTE: boolean;
  48487. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48488. VIGNETTEBLENDMODEOPAQUE: boolean;
  48489. TONEMAPPING: boolean;
  48490. TONEMAPPING_ACES: boolean;
  48491. CONTRAST: boolean;
  48492. COLORCURVES: boolean;
  48493. COLORGRADING: boolean;
  48494. COLORGRADING3D: boolean;
  48495. SAMPLER3DGREENDEPTH: boolean;
  48496. SAMPLER3DBGRMAP: boolean;
  48497. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48498. EXPOSURE: boolean;
  48499. MULTIVIEW: boolean;
  48500. USEPHYSICALLIGHTFALLOFF: boolean;
  48501. USEGLTFLIGHTFALLOFF: boolean;
  48502. TWOSIDEDLIGHTING: boolean;
  48503. SHADOWFLOAT: boolean;
  48504. CLIPPLANE: boolean;
  48505. CLIPPLANE2: boolean;
  48506. CLIPPLANE3: boolean;
  48507. CLIPPLANE4: boolean;
  48508. POINTSIZE: boolean;
  48509. FOG: boolean;
  48510. LOGARITHMICDEPTH: boolean;
  48511. FORCENORMALFORWARD: boolean;
  48512. SPECULARAA: boolean;
  48513. CLEARCOAT: boolean;
  48514. CLEARCOAT_DEFAULTIOR: boolean;
  48515. CLEARCOAT_TEXTURE: boolean;
  48516. CLEARCOAT_TEXTUREDIRECTUV: number;
  48517. CLEARCOAT_BUMP: boolean;
  48518. CLEARCOAT_BUMPDIRECTUV: number;
  48519. CLEARCOAT_TINT: boolean;
  48520. CLEARCOAT_TINT_TEXTURE: boolean;
  48521. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48522. ANISOTROPIC: boolean;
  48523. ANISOTROPIC_TEXTURE: boolean;
  48524. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48525. BRDF_V_HEIGHT_CORRELATED: boolean;
  48526. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48527. SHEEN: boolean;
  48528. SHEEN_TEXTURE: boolean;
  48529. SHEEN_TEXTUREDIRECTUV: number;
  48530. SHEEN_LINKWITHALBEDO: boolean;
  48531. SUBSURFACE: boolean;
  48532. SS_REFRACTION: boolean;
  48533. SS_TRANSLUCENCY: boolean;
  48534. SS_SCATERRING: boolean;
  48535. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48536. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48537. SS_REFRACTIONMAP_3D: boolean;
  48538. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48539. SS_LODINREFRACTIONALPHA: boolean;
  48540. SS_GAMMAREFRACTION: boolean;
  48541. SS_RGBDREFRACTION: boolean;
  48542. SS_LINEARSPECULARREFRACTION: boolean;
  48543. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48544. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48545. UNLIT: boolean;
  48546. DEBUGMODE: number;
  48547. /**
  48548. * Initializes the PBR Material defines.
  48549. */
  48550. constructor();
  48551. /**
  48552. * Resets the PBR Material defines.
  48553. */
  48554. reset(): void;
  48555. }
  48556. /**
  48557. * The Physically based material base class of BJS.
  48558. *
  48559. * This offers the main features of a standard PBR material.
  48560. * For more information, please refer to the documentation :
  48561. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48562. */
  48563. export abstract class PBRBaseMaterial extends PushMaterial {
  48564. /**
  48565. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48566. */
  48567. static readonly PBRMATERIAL_OPAQUE: number;
  48568. /**
  48569. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48570. */
  48571. static readonly PBRMATERIAL_ALPHATEST: number;
  48572. /**
  48573. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48574. */
  48575. static readonly PBRMATERIAL_ALPHABLEND: number;
  48576. /**
  48577. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48578. * They are also discarded below the alpha cutoff threshold to improve performances.
  48579. */
  48580. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48581. /**
  48582. * Defines the default value of how much AO map is occluding the analytical lights
  48583. * (point spot...).
  48584. */
  48585. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48586. /**
  48587. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48588. */
  48589. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48590. /**
  48591. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48592. * to enhance interoperability with other engines.
  48593. */
  48594. static readonly LIGHTFALLOFF_GLTF: number;
  48595. /**
  48596. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48597. * to enhance interoperability with other materials.
  48598. */
  48599. static readonly LIGHTFALLOFF_STANDARD: number;
  48600. /**
  48601. * Intensity of the direct lights e.g. the four lights available in your scene.
  48602. * This impacts both the direct diffuse and specular highlights.
  48603. */
  48604. protected _directIntensity: number;
  48605. /**
  48606. * Intensity of the emissive part of the material.
  48607. * This helps controlling the emissive effect without modifying the emissive color.
  48608. */
  48609. protected _emissiveIntensity: number;
  48610. /**
  48611. * Intensity of the environment e.g. how much the environment will light the object
  48612. * either through harmonics for rough material or through the refelction for shiny ones.
  48613. */
  48614. protected _environmentIntensity: number;
  48615. /**
  48616. * This is a special control allowing the reduction of the specular highlights coming from the
  48617. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48618. */
  48619. protected _specularIntensity: number;
  48620. /**
  48621. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48622. */
  48623. private _lightingInfos;
  48624. /**
  48625. * Debug Control allowing disabling the bump map on this material.
  48626. */
  48627. protected _disableBumpMap: boolean;
  48628. /**
  48629. * AKA Diffuse Texture in standard nomenclature.
  48630. */
  48631. protected _albedoTexture: Nullable<BaseTexture>;
  48632. /**
  48633. * AKA Occlusion Texture in other nomenclature.
  48634. */
  48635. protected _ambientTexture: Nullable<BaseTexture>;
  48636. /**
  48637. * AKA Occlusion Texture Intensity in other nomenclature.
  48638. */
  48639. protected _ambientTextureStrength: number;
  48640. /**
  48641. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48642. * 1 means it completely occludes it
  48643. * 0 mean it has no impact
  48644. */
  48645. protected _ambientTextureImpactOnAnalyticalLights: number;
  48646. /**
  48647. * Stores the alpha values in a texture.
  48648. */
  48649. protected _opacityTexture: Nullable<BaseTexture>;
  48650. /**
  48651. * Stores the reflection values in a texture.
  48652. */
  48653. protected _reflectionTexture: Nullable<BaseTexture>;
  48654. /**
  48655. * Stores the emissive values in a texture.
  48656. */
  48657. protected _emissiveTexture: Nullable<BaseTexture>;
  48658. /**
  48659. * AKA Specular texture in other nomenclature.
  48660. */
  48661. protected _reflectivityTexture: Nullable<BaseTexture>;
  48662. /**
  48663. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48664. */
  48665. protected _metallicTexture: Nullable<BaseTexture>;
  48666. /**
  48667. * Specifies the metallic scalar of the metallic/roughness workflow.
  48668. * Can also be used to scale the metalness values of the metallic texture.
  48669. */
  48670. protected _metallic: Nullable<number>;
  48671. /**
  48672. * Specifies the roughness scalar of the metallic/roughness workflow.
  48673. * Can also be used to scale the roughness values of the metallic texture.
  48674. */
  48675. protected _roughness: Nullable<number>;
  48676. /**
  48677. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48678. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48679. */
  48680. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48681. /**
  48682. * Stores surface normal data used to displace a mesh in a texture.
  48683. */
  48684. protected _bumpTexture: Nullable<BaseTexture>;
  48685. /**
  48686. * Stores the pre-calculated light information of a mesh in a texture.
  48687. */
  48688. protected _lightmapTexture: Nullable<BaseTexture>;
  48689. /**
  48690. * The color of a material in ambient lighting.
  48691. */
  48692. protected _ambientColor: Color3;
  48693. /**
  48694. * AKA Diffuse Color in other nomenclature.
  48695. */
  48696. protected _albedoColor: Color3;
  48697. /**
  48698. * AKA Specular Color in other nomenclature.
  48699. */
  48700. protected _reflectivityColor: Color3;
  48701. /**
  48702. * The color applied when light is reflected from a material.
  48703. */
  48704. protected _reflectionColor: Color3;
  48705. /**
  48706. * The color applied when light is emitted from a material.
  48707. */
  48708. protected _emissiveColor: Color3;
  48709. /**
  48710. * AKA Glossiness in other nomenclature.
  48711. */
  48712. protected _microSurface: number;
  48713. /**
  48714. * Specifies that the material will use the light map as a show map.
  48715. */
  48716. protected _useLightmapAsShadowmap: boolean;
  48717. /**
  48718. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48719. * makes the reflect vector face the model (under horizon).
  48720. */
  48721. protected _useHorizonOcclusion: boolean;
  48722. /**
  48723. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48724. * too much the area relying on ambient texture to define their ambient occlusion.
  48725. */
  48726. protected _useRadianceOcclusion: boolean;
  48727. /**
  48728. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48729. */
  48730. protected _useAlphaFromAlbedoTexture: boolean;
  48731. /**
  48732. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48733. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48734. */
  48735. protected _useSpecularOverAlpha: boolean;
  48736. /**
  48737. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48738. */
  48739. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48740. /**
  48741. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48742. */
  48743. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48744. /**
  48745. * Specifies if the metallic texture contains the roughness information in its green channel.
  48746. */
  48747. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48748. /**
  48749. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48750. */
  48751. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48752. /**
  48753. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48754. */
  48755. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48756. /**
  48757. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48758. */
  48759. protected _useAmbientInGrayScale: boolean;
  48760. /**
  48761. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48762. * The material will try to infer what glossiness each pixel should be.
  48763. */
  48764. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48765. /**
  48766. * Defines the falloff type used in this material.
  48767. * It by default is Physical.
  48768. */
  48769. protected _lightFalloff: number;
  48770. /**
  48771. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48772. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48773. */
  48774. protected _useRadianceOverAlpha: boolean;
  48775. /**
  48776. * Allows using an object space normal map (instead of tangent space).
  48777. */
  48778. protected _useObjectSpaceNormalMap: boolean;
  48779. /**
  48780. * Allows using the bump map in parallax mode.
  48781. */
  48782. protected _useParallax: boolean;
  48783. /**
  48784. * Allows using the bump map in parallax occlusion mode.
  48785. */
  48786. protected _useParallaxOcclusion: boolean;
  48787. /**
  48788. * Controls the scale bias of the parallax mode.
  48789. */
  48790. protected _parallaxScaleBias: number;
  48791. /**
  48792. * If sets to true, disables all the lights affecting the material.
  48793. */
  48794. protected _disableLighting: boolean;
  48795. /**
  48796. * Number of Simultaneous lights allowed on the material.
  48797. */
  48798. protected _maxSimultaneousLights: number;
  48799. /**
  48800. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48801. */
  48802. protected _invertNormalMapX: boolean;
  48803. /**
  48804. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48805. */
  48806. protected _invertNormalMapY: boolean;
  48807. /**
  48808. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48809. */
  48810. protected _twoSidedLighting: boolean;
  48811. /**
  48812. * Defines the alpha limits in alpha test mode.
  48813. */
  48814. protected _alphaCutOff: number;
  48815. /**
  48816. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48817. */
  48818. protected _forceAlphaTest: boolean;
  48819. /**
  48820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48821. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48822. */
  48823. protected _useAlphaFresnel: boolean;
  48824. /**
  48825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48826. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48827. */
  48828. protected _useLinearAlphaFresnel: boolean;
  48829. /**
  48830. * The transparency mode of the material.
  48831. */
  48832. protected _transparencyMode: Nullable<number>;
  48833. /**
  48834. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48835. * from cos thetav and roughness:
  48836. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48837. */
  48838. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48839. /**
  48840. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48841. */
  48842. protected _forceIrradianceInFragment: boolean;
  48843. /**
  48844. * Force normal to face away from face.
  48845. */
  48846. protected _forceNormalForward: boolean;
  48847. /**
  48848. * Enables specular anti aliasing in the PBR shader.
  48849. * It will both interacts on the Geometry for analytical and IBL lighting.
  48850. * It also prefilter the roughness map based on the bump values.
  48851. */
  48852. protected _enableSpecularAntiAliasing: boolean;
  48853. /**
  48854. * Default configuration related to image processing available in the PBR Material.
  48855. */
  48856. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48857. /**
  48858. * Keep track of the image processing observer to allow dispose and replace.
  48859. */
  48860. private _imageProcessingObserver;
  48861. /**
  48862. * Attaches a new image processing configuration to the PBR Material.
  48863. * @param configuration
  48864. */
  48865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48866. /**
  48867. * Stores the available render targets.
  48868. */
  48869. private _renderTargets;
  48870. /**
  48871. * Sets the global ambient color for the material used in lighting calculations.
  48872. */
  48873. private _globalAmbientColor;
  48874. /**
  48875. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48876. */
  48877. private _useLogarithmicDepth;
  48878. /**
  48879. * If set to true, no lighting calculations will be applied.
  48880. */
  48881. private _unlit;
  48882. private _debugMode;
  48883. /**
  48884. * @hidden
  48885. * This is reserved for the inspector.
  48886. * Defines the material debug mode.
  48887. * It helps seeing only some components of the material while troubleshooting.
  48888. */
  48889. debugMode: number;
  48890. /**
  48891. * @hidden
  48892. * This is reserved for the inspector.
  48893. * Specify from where on screen the debug mode should start.
  48894. * The value goes from -1 (full screen) to 1 (not visible)
  48895. * It helps with side by side comparison against the final render
  48896. * This defaults to -1
  48897. */
  48898. private debugLimit;
  48899. /**
  48900. * @hidden
  48901. * This is reserved for the inspector.
  48902. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48903. * You can use the factor to better multiply the final value.
  48904. */
  48905. private debugFactor;
  48906. /**
  48907. * Defines the clear coat layer parameters for the material.
  48908. */
  48909. readonly clearCoat: PBRClearCoatConfiguration;
  48910. /**
  48911. * Defines the anisotropic parameters for the material.
  48912. */
  48913. readonly anisotropy: PBRAnisotropicConfiguration;
  48914. /**
  48915. * Defines the BRDF parameters for the material.
  48916. */
  48917. readonly brdf: PBRBRDFConfiguration;
  48918. /**
  48919. * Defines the Sheen parameters for the material.
  48920. */
  48921. readonly sheen: PBRSheenConfiguration;
  48922. /**
  48923. * Defines the SubSurface parameters for the material.
  48924. */
  48925. readonly subSurface: PBRSubSurfaceConfiguration;
  48926. /**
  48927. * Custom callback helping to override the default shader used in the material.
  48928. */
  48929. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48930. protected _rebuildInParallel: boolean;
  48931. /**
  48932. * Instantiates a new PBRMaterial instance.
  48933. *
  48934. * @param name The material name
  48935. * @param scene The scene the material will be use in.
  48936. */
  48937. constructor(name: string, scene: Scene);
  48938. /**
  48939. * Gets a boolean indicating that current material needs to register RTT
  48940. */
  48941. readonly hasRenderTargetTextures: boolean;
  48942. /**
  48943. * Gets the name of the material class.
  48944. */
  48945. getClassName(): string;
  48946. /**
  48947. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48948. */
  48949. /**
  48950. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48951. */
  48952. useLogarithmicDepth: boolean;
  48953. /**
  48954. * Gets the current transparency mode.
  48955. */
  48956. /**
  48957. * Sets the transparency mode of the material.
  48958. *
  48959. * | Value | Type | Description |
  48960. * | ----- | ----------------------------------- | ----------- |
  48961. * | 0 | OPAQUE | |
  48962. * | 1 | ALPHATEST | |
  48963. * | 2 | ALPHABLEND | |
  48964. * | 3 | ALPHATESTANDBLEND | |
  48965. *
  48966. */
  48967. transparencyMode: Nullable<number>;
  48968. /**
  48969. * Returns true if alpha blending should be disabled.
  48970. */
  48971. private readonly _disableAlphaBlending;
  48972. /**
  48973. * Specifies whether or not this material should be rendered in alpha blend mode.
  48974. */
  48975. needAlphaBlending(): boolean;
  48976. /**
  48977. * Specifies if the mesh will require alpha blending.
  48978. * @param mesh - BJS mesh.
  48979. */
  48980. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48981. /**
  48982. * Specifies whether or not this material should be rendered in alpha test mode.
  48983. */
  48984. needAlphaTesting(): boolean;
  48985. /**
  48986. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48987. */
  48988. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48989. /**
  48990. * Gets the texture used for the alpha test.
  48991. */
  48992. getAlphaTestTexture(): Nullable<BaseTexture>;
  48993. /**
  48994. * Specifies that the submesh is ready to be used.
  48995. * @param mesh - BJS mesh.
  48996. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48997. * @param useInstances - Specifies that instances should be used.
  48998. * @returns - boolean indicating that the submesh is ready or not.
  48999. */
  49000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49001. /**
  49002. * Specifies if the material uses metallic roughness workflow.
  49003. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49004. */
  49005. isMetallicWorkflow(): boolean;
  49006. private _prepareEffect;
  49007. private _prepareDefines;
  49008. /**
  49009. * Force shader compilation
  49010. */
  49011. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49012. clipPlane: boolean;
  49013. }>): void;
  49014. /**
  49015. * Initializes the uniform buffer layout for the shader.
  49016. */
  49017. buildUniformLayout(): void;
  49018. /**
  49019. * Unbinds the material from the mesh
  49020. */
  49021. unbind(): void;
  49022. /**
  49023. * Binds the submesh data.
  49024. * @param world - The world matrix.
  49025. * @param mesh - The BJS mesh.
  49026. * @param subMesh - A submesh of the BJS mesh.
  49027. */
  49028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49029. /**
  49030. * Returns the animatable textures.
  49031. * @returns - Array of animatable textures.
  49032. */
  49033. getAnimatables(): IAnimatable[];
  49034. /**
  49035. * Returns the texture used for reflections.
  49036. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49037. */
  49038. private _getReflectionTexture;
  49039. /**
  49040. * Returns an array of the actively used textures.
  49041. * @returns - Array of BaseTextures
  49042. */
  49043. getActiveTextures(): BaseTexture[];
  49044. /**
  49045. * Checks to see if a texture is used in the material.
  49046. * @param texture - Base texture to use.
  49047. * @returns - Boolean specifying if a texture is used in the material.
  49048. */
  49049. hasTexture(texture: BaseTexture): boolean;
  49050. /**
  49051. * Disposes the resources of the material.
  49052. * @param forceDisposeEffect - Forces the disposal of effects.
  49053. * @param forceDisposeTextures - Forces the disposal of all textures.
  49054. */
  49055. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49056. }
  49057. }
  49058. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49059. import { Nullable } from "babylonjs/types";
  49060. import { Scene } from "babylonjs/scene";
  49061. import { Color3 } from "babylonjs/Maths/math.color";
  49062. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49063. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49065. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49066. /**
  49067. * The Physically based material of BJS.
  49068. *
  49069. * This offers the main features of a standard PBR material.
  49070. * For more information, please refer to the documentation :
  49071. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49072. */
  49073. export class PBRMaterial extends PBRBaseMaterial {
  49074. /**
  49075. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49076. */
  49077. static readonly PBRMATERIAL_OPAQUE: number;
  49078. /**
  49079. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49080. */
  49081. static readonly PBRMATERIAL_ALPHATEST: number;
  49082. /**
  49083. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49084. */
  49085. static readonly PBRMATERIAL_ALPHABLEND: number;
  49086. /**
  49087. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49088. * They are also discarded below the alpha cutoff threshold to improve performances.
  49089. */
  49090. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49091. /**
  49092. * Defines the default value of how much AO map is occluding the analytical lights
  49093. * (point spot...).
  49094. */
  49095. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49096. /**
  49097. * Intensity of the direct lights e.g. the four lights available in your scene.
  49098. * This impacts both the direct diffuse and specular highlights.
  49099. */
  49100. directIntensity: number;
  49101. /**
  49102. * Intensity of the emissive part of the material.
  49103. * This helps controlling the emissive effect without modifying the emissive color.
  49104. */
  49105. emissiveIntensity: number;
  49106. /**
  49107. * Intensity of the environment e.g. how much the environment will light the object
  49108. * either through harmonics for rough material or through the refelction for shiny ones.
  49109. */
  49110. environmentIntensity: number;
  49111. /**
  49112. * This is a special control allowing the reduction of the specular highlights coming from the
  49113. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49114. */
  49115. specularIntensity: number;
  49116. /**
  49117. * Debug Control allowing disabling the bump map on this material.
  49118. */
  49119. disableBumpMap: boolean;
  49120. /**
  49121. * AKA Diffuse Texture in standard nomenclature.
  49122. */
  49123. albedoTexture: BaseTexture;
  49124. /**
  49125. * AKA Occlusion Texture in other nomenclature.
  49126. */
  49127. ambientTexture: BaseTexture;
  49128. /**
  49129. * AKA Occlusion Texture Intensity in other nomenclature.
  49130. */
  49131. ambientTextureStrength: number;
  49132. /**
  49133. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49134. * 1 means it completely occludes it
  49135. * 0 mean it has no impact
  49136. */
  49137. ambientTextureImpactOnAnalyticalLights: number;
  49138. /**
  49139. * Stores the alpha values in a texture.
  49140. */
  49141. opacityTexture: BaseTexture;
  49142. /**
  49143. * Stores the reflection values in a texture.
  49144. */
  49145. reflectionTexture: Nullable<BaseTexture>;
  49146. /**
  49147. * Stores the emissive values in a texture.
  49148. */
  49149. emissiveTexture: BaseTexture;
  49150. /**
  49151. * AKA Specular texture in other nomenclature.
  49152. */
  49153. reflectivityTexture: BaseTexture;
  49154. /**
  49155. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49156. */
  49157. metallicTexture: BaseTexture;
  49158. /**
  49159. * Specifies the metallic scalar of the metallic/roughness workflow.
  49160. * Can also be used to scale the metalness values of the metallic texture.
  49161. */
  49162. metallic: Nullable<number>;
  49163. /**
  49164. * Specifies the roughness scalar of the metallic/roughness workflow.
  49165. * Can also be used to scale the roughness values of the metallic texture.
  49166. */
  49167. roughness: Nullable<number>;
  49168. /**
  49169. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49170. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49171. */
  49172. microSurfaceTexture: BaseTexture;
  49173. /**
  49174. * Stores surface normal data used to displace a mesh in a texture.
  49175. */
  49176. bumpTexture: BaseTexture;
  49177. /**
  49178. * Stores the pre-calculated light information of a mesh in a texture.
  49179. */
  49180. lightmapTexture: BaseTexture;
  49181. /**
  49182. * Stores the refracted light information in a texture.
  49183. */
  49184. refractionTexture: Nullable<BaseTexture>;
  49185. /**
  49186. * The color of a material in ambient lighting.
  49187. */
  49188. ambientColor: Color3;
  49189. /**
  49190. * AKA Diffuse Color in other nomenclature.
  49191. */
  49192. albedoColor: Color3;
  49193. /**
  49194. * AKA Specular Color in other nomenclature.
  49195. */
  49196. reflectivityColor: Color3;
  49197. /**
  49198. * The color reflected from the material.
  49199. */
  49200. reflectionColor: Color3;
  49201. /**
  49202. * The color emitted from the material.
  49203. */
  49204. emissiveColor: Color3;
  49205. /**
  49206. * AKA Glossiness in other nomenclature.
  49207. */
  49208. microSurface: number;
  49209. /**
  49210. * source material index of refraction (IOR)' / 'destination material IOR.
  49211. */
  49212. indexOfRefraction: number;
  49213. /**
  49214. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49215. */
  49216. invertRefractionY: boolean;
  49217. /**
  49218. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49219. * Materials half opaque for instance using refraction could benefit from this control.
  49220. */
  49221. linkRefractionWithTransparency: boolean;
  49222. /**
  49223. * If true, the light map contains occlusion information instead of lighting info.
  49224. */
  49225. useLightmapAsShadowmap: boolean;
  49226. /**
  49227. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49228. */
  49229. useAlphaFromAlbedoTexture: boolean;
  49230. /**
  49231. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49232. */
  49233. forceAlphaTest: boolean;
  49234. /**
  49235. * Defines the alpha limits in alpha test mode.
  49236. */
  49237. alphaCutOff: number;
  49238. /**
  49239. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49240. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49241. */
  49242. useSpecularOverAlpha: boolean;
  49243. /**
  49244. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49245. */
  49246. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49247. /**
  49248. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49249. */
  49250. useRoughnessFromMetallicTextureAlpha: boolean;
  49251. /**
  49252. * Specifies if the metallic texture contains the roughness information in its green channel.
  49253. */
  49254. useRoughnessFromMetallicTextureGreen: boolean;
  49255. /**
  49256. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49257. */
  49258. useMetallnessFromMetallicTextureBlue: boolean;
  49259. /**
  49260. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49261. */
  49262. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49263. /**
  49264. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49265. */
  49266. useAmbientInGrayScale: boolean;
  49267. /**
  49268. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49269. * The material will try to infer what glossiness each pixel should be.
  49270. */
  49271. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49272. /**
  49273. * BJS is using an harcoded light falloff based on a manually sets up range.
  49274. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49275. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49276. */
  49277. /**
  49278. * BJS is using an harcoded light falloff based on a manually sets up range.
  49279. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49280. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49281. */
  49282. usePhysicalLightFalloff: boolean;
  49283. /**
  49284. * In order to support the falloff compatibility with gltf, a special mode has been added
  49285. * to reproduce the gltf light falloff.
  49286. */
  49287. /**
  49288. * In order to support the falloff compatibility with gltf, a special mode has been added
  49289. * to reproduce the gltf light falloff.
  49290. */
  49291. useGLTFLightFalloff: boolean;
  49292. /**
  49293. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49294. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49295. */
  49296. useRadianceOverAlpha: boolean;
  49297. /**
  49298. * Allows using an object space normal map (instead of tangent space).
  49299. */
  49300. useObjectSpaceNormalMap: boolean;
  49301. /**
  49302. * Allows using the bump map in parallax mode.
  49303. */
  49304. useParallax: boolean;
  49305. /**
  49306. * Allows using the bump map in parallax occlusion mode.
  49307. */
  49308. useParallaxOcclusion: boolean;
  49309. /**
  49310. * Controls the scale bias of the parallax mode.
  49311. */
  49312. parallaxScaleBias: number;
  49313. /**
  49314. * If sets to true, disables all the lights affecting the material.
  49315. */
  49316. disableLighting: boolean;
  49317. /**
  49318. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49319. */
  49320. forceIrradianceInFragment: boolean;
  49321. /**
  49322. * Number of Simultaneous lights allowed on the material.
  49323. */
  49324. maxSimultaneousLights: number;
  49325. /**
  49326. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49327. */
  49328. invertNormalMapX: boolean;
  49329. /**
  49330. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49331. */
  49332. invertNormalMapY: boolean;
  49333. /**
  49334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49335. */
  49336. twoSidedLighting: boolean;
  49337. /**
  49338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49339. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49340. */
  49341. useAlphaFresnel: boolean;
  49342. /**
  49343. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49344. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49345. */
  49346. useLinearAlphaFresnel: boolean;
  49347. /**
  49348. * Let user defines the brdf lookup texture used for IBL.
  49349. * A default 8bit version is embedded but you could point at :
  49350. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49351. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49352. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49353. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49354. */
  49355. environmentBRDFTexture: Nullable<BaseTexture>;
  49356. /**
  49357. * Force normal to face away from face.
  49358. */
  49359. forceNormalForward: boolean;
  49360. /**
  49361. * Enables specular anti aliasing in the PBR shader.
  49362. * It will both interacts on the Geometry for analytical and IBL lighting.
  49363. * It also prefilter the roughness map based on the bump values.
  49364. */
  49365. enableSpecularAntiAliasing: boolean;
  49366. /**
  49367. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49368. * makes the reflect vector face the model (under horizon).
  49369. */
  49370. useHorizonOcclusion: boolean;
  49371. /**
  49372. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49373. * too much the area relying on ambient texture to define their ambient occlusion.
  49374. */
  49375. useRadianceOcclusion: boolean;
  49376. /**
  49377. * If set to true, no lighting calculations will be applied.
  49378. */
  49379. unlit: boolean;
  49380. /**
  49381. * Gets the image processing configuration used either in this material.
  49382. */
  49383. /**
  49384. * Sets the Default image processing configuration used either in the this material.
  49385. *
  49386. * If sets to null, the scene one is in use.
  49387. */
  49388. imageProcessingConfiguration: ImageProcessingConfiguration;
  49389. /**
  49390. * Gets wether the color curves effect is enabled.
  49391. */
  49392. /**
  49393. * Sets wether the color curves effect is enabled.
  49394. */
  49395. cameraColorCurvesEnabled: boolean;
  49396. /**
  49397. * Gets wether the color grading effect is enabled.
  49398. */
  49399. /**
  49400. * Gets wether the color grading effect is enabled.
  49401. */
  49402. cameraColorGradingEnabled: boolean;
  49403. /**
  49404. * Gets wether tonemapping is enabled or not.
  49405. */
  49406. /**
  49407. * Sets wether tonemapping is enabled or not
  49408. */
  49409. cameraToneMappingEnabled: boolean;
  49410. /**
  49411. * The camera exposure used on this material.
  49412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49413. * This corresponds to a photographic exposure.
  49414. */
  49415. /**
  49416. * The camera exposure used on this material.
  49417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49418. * This corresponds to a photographic exposure.
  49419. */
  49420. cameraExposure: number;
  49421. /**
  49422. * Gets The camera contrast used on this material.
  49423. */
  49424. /**
  49425. * Sets The camera contrast used on this material.
  49426. */
  49427. cameraContrast: number;
  49428. /**
  49429. * Gets the Color Grading 2D Lookup Texture.
  49430. */
  49431. /**
  49432. * Sets the Color Grading 2D Lookup Texture.
  49433. */
  49434. cameraColorGradingTexture: Nullable<BaseTexture>;
  49435. /**
  49436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49438. * 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;
  49439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49440. */
  49441. /**
  49442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49444. * 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;
  49445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49446. */
  49447. cameraColorCurves: Nullable<ColorCurves>;
  49448. /**
  49449. * Instantiates a new PBRMaterial instance.
  49450. *
  49451. * @param name The material name
  49452. * @param scene The scene the material will be use in.
  49453. */
  49454. constructor(name: string, scene: Scene);
  49455. /**
  49456. * Returns the name of this material class.
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Makes a duplicate of the current material.
  49461. * @param name - name to use for the new material.
  49462. */
  49463. clone(name: string): PBRMaterial;
  49464. /**
  49465. * Serializes this PBR Material.
  49466. * @returns - An object with the serialized material.
  49467. */
  49468. serialize(): any;
  49469. /**
  49470. * Parses a PBR Material from a serialized object.
  49471. * @param source - Serialized object.
  49472. * @param scene - BJS scene instance.
  49473. * @param rootUrl - url for the scene object
  49474. * @returns - PBRMaterial
  49475. */
  49476. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49477. }
  49478. }
  49479. declare module "babylonjs/Misc/dds" {
  49480. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49481. import { Engine } from "babylonjs/Engines/engine";
  49482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49483. import { Nullable } from "babylonjs/types";
  49484. import { Scene } from "babylonjs/scene";
  49485. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49486. /**
  49487. * Direct draw surface info
  49488. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49489. */
  49490. export interface DDSInfo {
  49491. /**
  49492. * Width of the texture
  49493. */
  49494. width: number;
  49495. /**
  49496. * Width of the texture
  49497. */
  49498. height: number;
  49499. /**
  49500. * Number of Mipmaps for the texture
  49501. * @see https://en.wikipedia.org/wiki/Mipmap
  49502. */
  49503. mipmapCount: number;
  49504. /**
  49505. * If the textures format is a known fourCC format
  49506. * @see https://www.fourcc.org/
  49507. */
  49508. isFourCC: boolean;
  49509. /**
  49510. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49511. */
  49512. isRGB: boolean;
  49513. /**
  49514. * If the texture is a lumincance format
  49515. */
  49516. isLuminance: boolean;
  49517. /**
  49518. * If this is a cube texture
  49519. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49520. */
  49521. isCube: boolean;
  49522. /**
  49523. * If the texture is a compressed format eg. FOURCC_DXT1
  49524. */
  49525. isCompressed: boolean;
  49526. /**
  49527. * The dxgiFormat of the texture
  49528. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49529. */
  49530. dxgiFormat: number;
  49531. /**
  49532. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49533. */
  49534. textureType: number;
  49535. /**
  49536. * Sphericle polynomial created for the dds texture
  49537. */
  49538. sphericalPolynomial?: SphericalPolynomial;
  49539. }
  49540. /**
  49541. * Class used to provide DDS decompression tools
  49542. */
  49543. export class DDSTools {
  49544. /**
  49545. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49546. */
  49547. static StoreLODInAlphaChannel: boolean;
  49548. /**
  49549. * Gets DDS information from an array buffer
  49550. * @param arrayBuffer defines the array buffer to read data from
  49551. * @returns the DDS information
  49552. */
  49553. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49554. private static _FloatView;
  49555. private static _Int32View;
  49556. private static _ToHalfFloat;
  49557. private static _FromHalfFloat;
  49558. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49559. private static _GetHalfFloatRGBAArrayBuffer;
  49560. private static _GetFloatRGBAArrayBuffer;
  49561. private static _GetFloatAsUIntRGBAArrayBuffer;
  49562. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49563. private static _GetRGBAArrayBuffer;
  49564. private static _ExtractLongWordOrder;
  49565. private static _GetRGBArrayBuffer;
  49566. private static _GetLuminanceArrayBuffer;
  49567. /**
  49568. * Uploads DDS Levels to a Babylon Texture
  49569. * @hidden
  49570. */
  49571. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49572. }
  49573. module "babylonjs/Engines/engine" {
  49574. interface Engine {
  49575. /**
  49576. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49577. * @param rootUrl defines the url where the file to load is located
  49578. * @param scene defines the current scene
  49579. * @param lodScale defines scale to apply to the mip map selection
  49580. * @param lodOffset defines offset to apply to the mip map selection
  49581. * @param onLoad defines an optional callback raised when the texture is loaded
  49582. * @param onError defines an optional callback raised if there is an issue to load the texture
  49583. * @param format defines the format of the data
  49584. * @param forcedExtension defines the extension to use to pick the right loader
  49585. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49586. * @returns the cube texture as an InternalTexture
  49587. */
  49588. 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;
  49589. }
  49590. }
  49591. }
  49592. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49593. import { Nullable } from "babylonjs/types";
  49594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49595. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49596. /**
  49597. * Implementation of the DDS Texture Loader.
  49598. * @hidden
  49599. */
  49600. export class _DDSTextureLoader implements IInternalTextureLoader {
  49601. /**
  49602. * Defines wether the loader supports cascade loading the different faces.
  49603. */
  49604. readonly supportCascades: boolean;
  49605. /**
  49606. * This returns if the loader support the current file information.
  49607. * @param extension defines the file extension of the file being loaded
  49608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49609. * @param fallback defines the fallback internal texture if any
  49610. * @param isBase64 defines whether the texture is encoded as a base64
  49611. * @param isBuffer defines whether the texture data are stored as a buffer
  49612. * @returns true if the loader can load the specified file
  49613. */
  49614. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49615. /**
  49616. * Transform the url before loading if required.
  49617. * @param rootUrl the url of the texture
  49618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49619. * @returns the transformed texture
  49620. */
  49621. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49622. /**
  49623. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49624. * @param rootUrl the url of the texture
  49625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49626. * @returns the fallback texture
  49627. */
  49628. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49629. /**
  49630. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49631. * @param data contains the texture data
  49632. * @param texture defines the BabylonJS internal texture
  49633. * @param createPolynomials will be true if polynomials have been requested
  49634. * @param onLoad defines the callback to trigger once the texture is ready
  49635. * @param onError defines the callback to trigger in case of error
  49636. */
  49637. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49638. /**
  49639. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49640. * @param data contains the texture data
  49641. * @param texture defines the BabylonJS internal texture
  49642. * @param callback defines the method to call once ready to upload
  49643. */
  49644. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49645. }
  49646. }
  49647. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49648. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49649. /** @hidden */
  49650. export var rgbdEncodePixelShader: {
  49651. name: string;
  49652. shader: string;
  49653. };
  49654. }
  49655. declare module "babylonjs/Misc/environmentTextureTools" {
  49656. import { Nullable } from "babylonjs/types";
  49657. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49659. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49660. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49661. import "babylonjs/Shaders/rgbdEncode.fragment";
  49662. import "babylonjs/Shaders/rgbdDecode.fragment";
  49663. /**
  49664. * Raw texture data and descriptor sufficient for WebGL texture upload
  49665. */
  49666. export interface EnvironmentTextureInfo {
  49667. /**
  49668. * Version of the environment map
  49669. */
  49670. version: number;
  49671. /**
  49672. * Width of image
  49673. */
  49674. width: number;
  49675. /**
  49676. * Irradiance information stored in the file.
  49677. */
  49678. irradiance: any;
  49679. /**
  49680. * Specular information stored in the file.
  49681. */
  49682. specular: any;
  49683. }
  49684. /**
  49685. * Sets of helpers addressing the serialization and deserialization of environment texture
  49686. * stored in a BabylonJS env file.
  49687. * Those files are usually stored as .env files.
  49688. */
  49689. export class EnvironmentTextureTools {
  49690. /**
  49691. * Magic number identifying the env file.
  49692. */
  49693. private static _MagicBytes;
  49694. /**
  49695. * Gets the environment info from an env file.
  49696. * @param data The array buffer containing the .env bytes.
  49697. * @returns the environment file info (the json header) if successfully parsed.
  49698. */
  49699. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49700. /**
  49701. * Creates an environment texture from a loaded cube texture.
  49702. * @param texture defines the cube texture to convert in env file
  49703. * @return a promise containing the environment data if succesfull.
  49704. */
  49705. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49706. /**
  49707. * Creates a JSON representation of the spherical data.
  49708. * @param texture defines the texture containing the polynomials
  49709. * @return the JSON representation of the spherical info
  49710. */
  49711. private static _CreateEnvTextureIrradiance;
  49712. /**
  49713. * Uploads the texture info contained in the env file to the GPU.
  49714. * @param texture defines the internal texture to upload to
  49715. * @param arrayBuffer defines the buffer cotaining the data to load
  49716. * @param info defines the texture info retrieved through the GetEnvInfo method
  49717. * @returns a promise
  49718. */
  49719. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49720. /**
  49721. * Uploads the levels of image data to the GPU.
  49722. * @param texture defines the internal texture to upload to
  49723. * @param imageData defines the array buffer views of image data [mipmap][face]
  49724. * @returns a promise
  49725. */
  49726. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49727. /**
  49728. * Uploads spherical polynomials information to the texture.
  49729. * @param texture defines the texture we are trying to upload the information to
  49730. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49731. */
  49732. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49733. /** @hidden */
  49734. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49735. }
  49736. }
  49737. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49738. import { Nullable } from "babylonjs/types";
  49739. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49740. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49741. /**
  49742. * Implementation of the ENV Texture Loader.
  49743. * @hidden
  49744. */
  49745. export class _ENVTextureLoader implements IInternalTextureLoader {
  49746. /**
  49747. * Defines wether the loader supports cascade loading the different faces.
  49748. */
  49749. readonly supportCascades: boolean;
  49750. /**
  49751. * This returns if the loader support the current file information.
  49752. * @param extension defines the file extension of the file being loaded
  49753. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49754. * @param fallback defines the fallback internal texture if any
  49755. * @param isBase64 defines whether the texture is encoded as a base64
  49756. * @param isBuffer defines whether the texture data are stored as a buffer
  49757. * @returns true if the loader can load the specified file
  49758. */
  49759. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49760. /**
  49761. * Transform the url before loading if required.
  49762. * @param rootUrl the url of the texture
  49763. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49764. * @returns the transformed texture
  49765. */
  49766. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49767. /**
  49768. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49769. * @param rootUrl the url of the texture
  49770. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49771. * @returns the fallback texture
  49772. */
  49773. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49774. /**
  49775. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49776. * @param data contains the texture data
  49777. * @param texture defines the BabylonJS internal texture
  49778. * @param createPolynomials will be true if polynomials have been requested
  49779. * @param onLoad defines the callback to trigger once the texture is ready
  49780. * @param onError defines the callback to trigger in case of error
  49781. */
  49782. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49783. /**
  49784. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49785. * @param data contains the texture data
  49786. * @param texture defines the BabylonJS internal texture
  49787. * @param callback defines the method to call once ready to upload
  49788. */
  49789. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49790. }
  49791. }
  49792. declare module "babylonjs/Misc/khronosTextureContainer" {
  49793. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49794. /**
  49795. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49796. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49797. */
  49798. export class KhronosTextureContainer {
  49799. /** contents of the KTX container file */
  49800. arrayBuffer: any;
  49801. private static HEADER_LEN;
  49802. private static COMPRESSED_2D;
  49803. private static COMPRESSED_3D;
  49804. private static TEX_2D;
  49805. private static TEX_3D;
  49806. /**
  49807. * Gets the openGL type
  49808. */
  49809. glType: number;
  49810. /**
  49811. * Gets the openGL type size
  49812. */
  49813. glTypeSize: number;
  49814. /**
  49815. * Gets the openGL format
  49816. */
  49817. glFormat: number;
  49818. /**
  49819. * Gets the openGL internal format
  49820. */
  49821. glInternalFormat: number;
  49822. /**
  49823. * Gets the base internal format
  49824. */
  49825. glBaseInternalFormat: number;
  49826. /**
  49827. * Gets image width in pixel
  49828. */
  49829. pixelWidth: number;
  49830. /**
  49831. * Gets image height in pixel
  49832. */
  49833. pixelHeight: number;
  49834. /**
  49835. * Gets image depth in pixels
  49836. */
  49837. pixelDepth: number;
  49838. /**
  49839. * Gets the number of array elements
  49840. */
  49841. numberOfArrayElements: number;
  49842. /**
  49843. * Gets the number of faces
  49844. */
  49845. numberOfFaces: number;
  49846. /**
  49847. * Gets the number of mipmap levels
  49848. */
  49849. numberOfMipmapLevels: number;
  49850. /**
  49851. * Gets the bytes of key value data
  49852. */
  49853. bytesOfKeyValueData: number;
  49854. /**
  49855. * Gets the load type
  49856. */
  49857. loadType: number;
  49858. /**
  49859. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49860. */
  49861. isInvalid: boolean;
  49862. /**
  49863. * Creates a new KhronosTextureContainer
  49864. * @param arrayBuffer contents of the KTX container file
  49865. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49866. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49867. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49868. */
  49869. constructor(
  49870. /** contents of the KTX container file */
  49871. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49872. /**
  49873. * Uploads KTX content to a Babylon Texture.
  49874. * It is assumed that the texture has already been created & is currently bound
  49875. * @hidden
  49876. */
  49877. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49878. private _upload2DCompressedLevels;
  49879. }
  49880. }
  49881. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49882. import { Nullable } from "babylonjs/types";
  49883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49884. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49885. /**
  49886. * Implementation of the KTX Texture Loader.
  49887. * @hidden
  49888. */
  49889. export class _KTXTextureLoader implements IInternalTextureLoader {
  49890. /**
  49891. * Defines wether the loader supports cascade loading the different faces.
  49892. */
  49893. readonly supportCascades: boolean;
  49894. /**
  49895. * This returns if the loader support the current file information.
  49896. * @param extension defines the file extension of the file being loaded
  49897. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49898. * @param fallback defines the fallback internal texture if any
  49899. * @param isBase64 defines whether the texture is encoded as a base64
  49900. * @param isBuffer defines whether the texture data are stored as a buffer
  49901. * @returns true if the loader can load the specified file
  49902. */
  49903. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49904. /**
  49905. * Transform the url before loading if required.
  49906. * @param rootUrl the url of the texture
  49907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49908. * @returns the transformed texture
  49909. */
  49910. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49911. /**
  49912. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49913. * @param rootUrl the url of the texture
  49914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49915. * @returns the fallback texture
  49916. */
  49917. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49918. /**
  49919. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49920. * @param data contains the texture data
  49921. * @param texture defines the BabylonJS internal texture
  49922. * @param createPolynomials will be true if polynomials have been requested
  49923. * @param onLoad defines the callback to trigger once the texture is ready
  49924. * @param onError defines the callback to trigger in case of error
  49925. */
  49926. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49927. /**
  49928. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49929. * @param data contains the texture data
  49930. * @param texture defines the BabylonJS internal texture
  49931. * @param callback defines the method to call once ready to upload
  49932. */
  49933. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49934. }
  49935. }
  49936. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49937. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49938. import { Scene } from "babylonjs/scene";
  49939. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49940. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49941. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49942. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49943. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49944. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49946. /**
  49947. * Options for the default xr helper
  49948. */
  49949. export class WebXRDefaultExperienceOptions {
  49950. /**
  49951. * Floor meshes that should be used for teleporting
  49952. */
  49953. floorMeshes: Array<AbstractMesh>;
  49954. }
  49955. /**
  49956. * Default experience which provides a similar setup to the previous webVRExperience
  49957. */
  49958. export class WebXRDefaultExperience {
  49959. /**
  49960. * Base experience
  49961. */
  49962. baseExperience: WebXRExperienceHelper;
  49963. /**
  49964. * Input experience extension
  49965. */
  49966. input: WebXRInput;
  49967. /**
  49968. * Loads the controller models
  49969. */
  49970. controllerModelLoader: WebXRControllerModelLoader;
  49971. /**
  49972. * Enables laser pointer and selection
  49973. */
  49974. pointerSelection: WebXRControllerPointerSelection;
  49975. /**
  49976. * Enables teleportation
  49977. */
  49978. teleportation: WebXRControllerTeleportation;
  49979. /**
  49980. * Enables ui for enetering/exiting xr
  49981. */
  49982. enterExitUI: WebXREnterExitUI;
  49983. /**
  49984. * Default output canvas xr should render to
  49985. */
  49986. outputCanvas: WebXRManagedOutputCanvas;
  49987. /**
  49988. * Creates the default xr experience
  49989. * @param scene scene
  49990. * @param options options for basic configuration
  49991. * @returns resulting WebXRDefaultExperience
  49992. */
  49993. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49994. private constructor();
  49995. /**
  49996. * DIsposes of the experience helper
  49997. */
  49998. dispose(): void;
  49999. }
  50000. }
  50001. declare module "babylonjs/Helpers/sceneHelpers" {
  50002. import { Nullable } from "babylonjs/types";
  50003. import { Mesh } from "babylonjs/Meshes/mesh";
  50004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50005. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50006. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50007. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50008. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50009. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50010. import "babylonjs/Meshes/Builders/boxBuilder";
  50011. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50012. /** @hidden */
  50013. export var _forceSceneHelpersToBundle: boolean;
  50014. module "babylonjs/scene" {
  50015. interface Scene {
  50016. /**
  50017. * Creates a default light for the scene.
  50018. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50019. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50020. */
  50021. createDefaultLight(replace?: boolean): void;
  50022. /**
  50023. * Creates a default camera for the scene.
  50024. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50025. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50026. * @param replace has default false, when true replaces the active camera in the scene
  50027. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50028. */
  50029. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50030. /**
  50031. * Creates a default camera and a default light.
  50032. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50033. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50034. * @param replace has the default false, when true replaces the active camera/light in the scene
  50035. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50036. */
  50037. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50038. /**
  50039. * Creates a new sky box
  50040. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50041. * @param environmentTexture defines the texture to use as environment texture
  50042. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50043. * @param scale defines the overall scale of the skybox
  50044. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50045. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50046. * @returns a new mesh holding the sky box
  50047. */
  50048. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50049. /**
  50050. * Creates a new environment
  50051. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50052. * @param options defines the options you can use to configure the environment
  50053. * @returns the new EnvironmentHelper
  50054. */
  50055. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50056. /**
  50057. * Creates a new VREXperienceHelper
  50058. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50059. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50060. * @returns a new VREXperienceHelper
  50061. */
  50062. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50063. /**
  50064. * Creates a new WebXRDefaultExperience
  50065. * @see http://doc.babylonjs.com/how_to/webxr
  50066. * @param options experience options
  50067. * @returns a promise for a new WebXRDefaultExperience
  50068. */
  50069. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50070. }
  50071. }
  50072. }
  50073. declare module "babylonjs/Maths/math.vertexFormat" {
  50074. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50075. /**
  50076. * Contains position and normal vectors for a vertex
  50077. */
  50078. export class PositionNormalVertex {
  50079. /** the position of the vertex (defaut: 0,0,0) */
  50080. position: Vector3;
  50081. /** the normal of the vertex (defaut: 0,1,0) */
  50082. normal: Vector3;
  50083. /**
  50084. * Creates a PositionNormalVertex
  50085. * @param position the position of the vertex (defaut: 0,0,0)
  50086. * @param normal the normal of the vertex (defaut: 0,1,0)
  50087. */
  50088. constructor(
  50089. /** the position of the vertex (defaut: 0,0,0) */
  50090. position?: Vector3,
  50091. /** the normal of the vertex (defaut: 0,1,0) */
  50092. normal?: Vector3);
  50093. /**
  50094. * Clones the PositionNormalVertex
  50095. * @returns the cloned PositionNormalVertex
  50096. */
  50097. clone(): PositionNormalVertex;
  50098. }
  50099. /**
  50100. * Contains position, normal and uv vectors for a vertex
  50101. */
  50102. export class PositionNormalTextureVertex {
  50103. /** the position of the vertex (defaut: 0,0,0) */
  50104. position: Vector3;
  50105. /** the normal of the vertex (defaut: 0,1,0) */
  50106. normal: Vector3;
  50107. /** the uv of the vertex (default: 0,0) */
  50108. uv: Vector2;
  50109. /**
  50110. * Creates a PositionNormalTextureVertex
  50111. * @param position the position of the vertex (defaut: 0,0,0)
  50112. * @param normal the normal of the vertex (defaut: 0,1,0)
  50113. * @param uv the uv of the vertex (default: 0,0)
  50114. */
  50115. constructor(
  50116. /** the position of the vertex (defaut: 0,0,0) */
  50117. position?: Vector3,
  50118. /** the normal of the vertex (defaut: 0,1,0) */
  50119. normal?: Vector3,
  50120. /** the uv of the vertex (default: 0,0) */
  50121. uv?: Vector2);
  50122. /**
  50123. * Clones the PositionNormalTextureVertex
  50124. * @returns the cloned PositionNormalTextureVertex
  50125. */
  50126. clone(): PositionNormalTextureVertex;
  50127. }
  50128. }
  50129. declare module "babylonjs/Maths/math" {
  50130. export * from "babylonjs/Maths/math.axis";
  50131. export * from "babylonjs/Maths/math.color";
  50132. export * from "babylonjs/Maths/math.constants";
  50133. export * from "babylonjs/Maths/math.frustum";
  50134. export * from "babylonjs/Maths/math.path";
  50135. export * from "babylonjs/Maths/math.plane";
  50136. export * from "babylonjs/Maths/math.size";
  50137. export * from "babylonjs/Maths/math.vector";
  50138. export * from "babylonjs/Maths/math.vertexFormat";
  50139. export * from "babylonjs/Maths/math.viewport";
  50140. }
  50141. declare module "babylonjs/Helpers/videoDome" {
  50142. import { Scene } from "babylonjs/scene";
  50143. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50144. import { Mesh } from "babylonjs/Meshes/mesh";
  50145. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50146. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50147. import "babylonjs/Meshes/Builders/sphereBuilder";
  50148. /**
  50149. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50150. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50151. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50152. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50153. */
  50154. export class VideoDome extends TransformNode {
  50155. /**
  50156. * Define the video source as a Monoscopic panoramic 360 video.
  50157. */
  50158. static readonly MODE_MONOSCOPIC: number;
  50159. /**
  50160. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50161. */
  50162. static readonly MODE_TOPBOTTOM: number;
  50163. /**
  50164. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50165. */
  50166. static readonly MODE_SIDEBYSIDE: number;
  50167. private _halfDome;
  50168. private _useDirectMapping;
  50169. /**
  50170. * The video texture being displayed on the sphere
  50171. */
  50172. protected _videoTexture: VideoTexture;
  50173. /**
  50174. * Gets the video texture being displayed on the sphere
  50175. */
  50176. readonly videoTexture: VideoTexture;
  50177. /**
  50178. * The skybox material
  50179. */
  50180. protected _material: BackgroundMaterial;
  50181. /**
  50182. * The surface used for the skybox
  50183. */
  50184. protected _mesh: Mesh;
  50185. /**
  50186. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50187. */
  50188. private _halfDomeMask;
  50189. /**
  50190. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50191. * Also see the options.resolution property.
  50192. */
  50193. fovMultiplier: number;
  50194. private _videoMode;
  50195. /**
  50196. * Gets or set the current video mode for the video. It can be:
  50197. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50198. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50199. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50200. */
  50201. videoMode: number;
  50202. /**
  50203. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50204. *
  50205. */
  50206. /**
  50207. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50208. */
  50209. halfDome: boolean;
  50210. /**
  50211. * Oberserver used in Stereoscopic VR Mode.
  50212. */
  50213. private _onBeforeCameraRenderObserver;
  50214. /**
  50215. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50216. * @param name Element's name, child elements will append suffixes for their own names.
  50217. * @param urlsOrVideo defines the url(s) or the video element to use
  50218. * @param options An object containing optional or exposed sub element properties
  50219. */
  50220. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50221. resolution?: number;
  50222. clickToPlay?: boolean;
  50223. autoPlay?: boolean;
  50224. loop?: boolean;
  50225. size?: number;
  50226. poster?: string;
  50227. faceForward?: boolean;
  50228. useDirectMapping?: boolean;
  50229. halfDomeMode?: boolean;
  50230. }, scene: Scene);
  50231. private _changeVideoMode;
  50232. /**
  50233. * Releases resources associated with this node.
  50234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50236. */
  50237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50238. }
  50239. }
  50240. declare module "babylonjs/Helpers/index" {
  50241. export * from "babylonjs/Helpers/environmentHelper";
  50242. export * from "babylonjs/Helpers/photoDome";
  50243. export * from "babylonjs/Helpers/sceneHelpers";
  50244. export * from "babylonjs/Helpers/videoDome";
  50245. }
  50246. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50247. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50248. import { IDisposable } from "babylonjs/scene";
  50249. import { Engine } from "babylonjs/Engines/engine";
  50250. /**
  50251. * This class can be used to get instrumentation data from a Babylon engine
  50252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50253. */
  50254. export class EngineInstrumentation implements IDisposable {
  50255. /**
  50256. * Define the instrumented engine.
  50257. */
  50258. engine: Engine;
  50259. private _captureGPUFrameTime;
  50260. private _gpuFrameTimeToken;
  50261. private _gpuFrameTime;
  50262. private _captureShaderCompilationTime;
  50263. private _shaderCompilationTime;
  50264. private _onBeginFrameObserver;
  50265. private _onEndFrameObserver;
  50266. private _onBeforeShaderCompilationObserver;
  50267. private _onAfterShaderCompilationObserver;
  50268. /**
  50269. * Gets the perf counter used for GPU frame time
  50270. */
  50271. readonly gpuFrameTimeCounter: PerfCounter;
  50272. /**
  50273. * Gets the GPU frame time capture status
  50274. */
  50275. /**
  50276. * Enable or disable the GPU frame time capture
  50277. */
  50278. captureGPUFrameTime: boolean;
  50279. /**
  50280. * Gets the perf counter used for shader compilation time
  50281. */
  50282. readonly shaderCompilationTimeCounter: PerfCounter;
  50283. /**
  50284. * Gets the shader compilation time capture status
  50285. */
  50286. /**
  50287. * Enable or disable the shader compilation time capture
  50288. */
  50289. captureShaderCompilationTime: boolean;
  50290. /**
  50291. * Instantiates a new engine instrumentation.
  50292. * This class can be used to get instrumentation data from a Babylon engine
  50293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50294. * @param engine Defines the engine to instrument
  50295. */
  50296. constructor(
  50297. /**
  50298. * Define the instrumented engine.
  50299. */
  50300. engine: Engine);
  50301. /**
  50302. * Dispose and release associated resources.
  50303. */
  50304. dispose(): void;
  50305. }
  50306. }
  50307. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50308. import { Scene, IDisposable } from "babylonjs/scene";
  50309. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50310. /**
  50311. * This class can be used to get instrumentation data from a Babylon engine
  50312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50313. */
  50314. export class SceneInstrumentation implements IDisposable {
  50315. /**
  50316. * Defines the scene to instrument
  50317. */
  50318. scene: Scene;
  50319. private _captureActiveMeshesEvaluationTime;
  50320. private _activeMeshesEvaluationTime;
  50321. private _captureRenderTargetsRenderTime;
  50322. private _renderTargetsRenderTime;
  50323. private _captureFrameTime;
  50324. private _frameTime;
  50325. private _captureRenderTime;
  50326. private _renderTime;
  50327. private _captureInterFrameTime;
  50328. private _interFrameTime;
  50329. private _captureParticlesRenderTime;
  50330. private _particlesRenderTime;
  50331. private _captureSpritesRenderTime;
  50332. private _spritesRenderTime;
  50333. private _capturePhysicsTime;
  50334. private _physicsTime;
  50335. private _captureAnimationsTime;
  50336. private _animationsTime;
  50337. private _captureCameraRenderTime;
  50338. private _cameraRenderTime;
  50339. private _onBeforeActiveMeshesEvaluationObserver;
  50340. private _onAfterActiveMeshesEvaluationObserver;
  50341. private _onBeforeRenderTargetsRenderObserver;
  50342. private _onAfterRenderTargetsRenderObserver;
  50343. private _onAfterRenderObserver;
  50344. private _onBeforeDrawPhaseObserver;
  50345. private _onAfterDrawPhaseObserver;
  50346. private _onBeforeAnimationsObserver;
  50347. private _onBeforeParticlesRenderingObserver;
  50348. private _onAfterParticlesRenderingObserver;
  50349. private _onBeforeSpritesRenderingObserver;
  50350. private _onAfterSpritesRenderingObserver;
  50351. private _onBeforePhysicsObserver;
  50352. private _onAfterPhysicsObserver;
  50353. private _onAfterAnimationsObserver;
  50354. private _onBeforeCameraRenderObserver;
  50355. private _onAfterCameraRenderObserver;
  50356. /**
  50357. * Gets the perf counter used for active meshes evaluation time
  50358. */
  50359. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50360. /**
  50361. * Gets the active meshes evaluation time capture status
  50362. */
  50363. /**
  50364. * Enable or disable the active meshes evaluation time capture
  50365. */
  50366. captureActiveMeshesEvaluationTime: boolean;
  50367. /**
  50368. * Gets the perf counter used for render targets render time
  50369. */
  50370. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50371. /**
  50372. * Gets the render targets render time capture status
  50373. */
  50374. /**
  50375. * Enable or disable the render targets render time capture
  50376. */
  50377. captureRenderTargetsRenderTime: boolean;
  50378. /**
  50379. * Gets the perf counter used for particles render time
  50380. */
  50381. readonly particlesRenderTimeCounter: PerfCounter;
  50382. /**
  50383. * Gets the particles render time capture status
  50384. */
  50385. /**
  50386. * Enable or disable the particles render time capture
  50387. */
  50388. captureParticlesRenderTime: boolean;
  50389. /**
  50390. * Gets the perf counter used for sprites render time
  50391. */
  50392. readonly spritesRenderTimeCounter: PerfCounter;
  50393. /**
  50394. * Gets the sprites render time capture status
  50395. */
  50396. /**
  50397. * Enable or disable the sprites render time capture
  50398. */
  50399. captureSpritesRenderTime: boolean;
  50400. /**
  50401. * Gets the perf counter used for physics time
  50402. */
  50403. readonly physicsTimeCounter: PerfCounter;
  50404. /**
  50405. * Gets the physics time capture status
  50406. */
  50407. /**
  50408. * Enable or disable the physics time capture
  50409. */
  50410. capturePhysicsTime: boolean;
  50411. /**
  50412. * Gets the perf counter used for animations time
  50413. */
  50414. readonly animationsTimeCounter: PerfCounter;
  50415. /**
  50416. * Gets the animations time capture status
  50417. */
  50418. /**
  50419. * Enable or disable the animations time capture
  50420. */
  50421. captureAnimationsTime: boolean;
  50422. /**
  50423. * Gets the perf counter used for frame time capture
  50424. */
  50425. readonly frameTimeCounter: PerfCounter;
  50426. /**
  50427. * Gets the frame time capture status
  50428. */
  50429. /**
  50430. * Enable or disable the frame time capture
  50431. */
  50432. captureFrameTime: boolean;
  50433. /**
  50434. * Gets the perf counter used for inter-frames time capture
  50435. */
  50436. readonly interFrameTimeCounter: PerfCounter;
  50437. /**
  50438. * Gets the inter-frames time capture status
  50439. */
  50440. /**
  50441. * Enable or disable the inter-frames time capture
  50442. */
  50443. captureInterFrameTime: boolean;
  50444. /**
  50445. * Gets the perf counter used for render time capture
  50446. */
  50447. readonly renderTimeCounter: PerfCounter;
  50448. /**
  50449. * Gets the render time capture status
  50450. */
  50451. /**
  50452. * Enable or disable the render time capture
  50453. */
  50454. captureRenderTime: boolean;
  50455. /**
  50456. * Gets the perf counter used for camera render time capture
  50457. */
  50458. readonly cameraRenderTimeCounter: PerfCounter;
  50459. /**
  50460. * Gets the camera render time capture status
  50461. */
  50462. /**
  50463. * Enable or disable the camera render time capture
  50464. */
  50465. captureCameraRenderTime: boolean;
  50466. /**
  50467. * Gets the perf counter used for draw calls
  50468. */
  50469. readonly drawCallsCounter: PerfCounter;
  50470. /**
  50471. * Instantiates a new scene instrumentation.
  50472. * This class can be used to get instrumentation data from a Babylon engine
  50473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50474. * @param scene Defines the scene to instrument
  50475. */
  50476. constructor(
  50477. /**
  50478. * Defines the scene to instrument
  50479. */
  50480. scene: Scene);
  50481. /**
  50482. * Dispose and release associated resources.
  50483. */
  50484. dispose(): void;
  50485. }
  50486. }
  50487. declare module "babylonjs/Instrumentation/index" {
  50488. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50489. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50490. export * from "babylonjs/Instrumentation/timeToken";
  50491. }
  50492. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50493. /** @hidden */
  50494. export var glowMapGenerationPixelShader: {
  50495. name: string;
  50496. shader: string;
  50497. };
  50498. }
  50499. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50500. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50501. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50503. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50504. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50505. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50506. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50507. /** @hidden */
  50508. export var glowMapGenerationVertexShader: {
  50509. name: string;
  50510. shader: string;
  50511. };
  50512. }
  50513. declare module "babylonjs/Layers/effectLayer" {
  50514. import { Observable } from "babylonjs/Misc/observable";
  50515. import { Nullable } from "babylonjs/types";
  50516. import { Camera } from "babylonjs/Cameras/camera";
  50517. import { Scene } from "babylonjs/scene";
  50518. import { ISize } from "babylonjs/Maths/math.size";
  50519. import { Color4 } from "babylonjs/Maths/math.color";
  50520. import { Engine } from "babylonjs/Engines/engine";
  50521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50523. import { Mesh } from "babylonjs/Meshes/mesh";
  50524. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50527. import { Effect } from "babylonjs/Materials/effect";
  50528. import { Material } from "babylonjs/Materials/material";
  50529. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50530. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50531. /**
  50532. * Effect layer options. This helps customizing the behaviour
  50533. * of the effect layer.
  50534. */
  50535. export interface IEffectLayerOptions {
  50536. /**
  50537. * Multiplication factor apply to the canvas size to compute the render target size
  50538. * used to generated the objects (the smaller the faster).
  50539. */
  50540. mainTextureRatio: number;
  50541. /**
  50542. * Enforces a fixed size texture to ensure effect stability across devices.
  50543. */
  50544. mainTextureFixedSize?: number;
  50545. /**
  50546. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50547. */
  50548. alphaBlendingMode: number;
  50549. /**
  50550. * The camera attached to the layer.
  50551. */
  50552. camera: Nullable<Camera>;
  50553. /**
  50554. * The rendering group to draw the layer in.
  50555. */
  50556. renderingGroupId: number;
  50557. }
  50558. /**
  50559. * The effect layer Helps adding post process effect blended with the main pass.
  50560. *
  50561. * This can be for instance use to generate glow or higlight effects on the scene.
  50562. *
  50563. * The effect layer class can not be used directly and is intented to inherited from to be
  50564. * customized per effects.
  50565. */
  50566. export abstract class EffectLayer {
  50567. private _vertexBuffers;
  50568. private _indexBuffer;
  50569. private _cachedDefines;
  50570. private _effectLayerMapGenerationEffect;
  50571. private _effectLayerOptions;
  50572. private _mergeEffect;
  50573. protected _scene: Scene;
  50574. protected _engine: Engine;
  50575. protected _maxSize: number;
  50576. protected _mainTextureDesiredSize: ISize;
  50577. protected _mainTexture: RenderTargetTexture;
  50578. protected _shouldRender: boolean;
  50579. protected _postProcesses: PostProcess[];
  50580. protected _textures: BaseTexture[];
  50581. protected _emissiveTextureAndColor: {
  50582. texture: Nullable<BaseTexture>;
  50583. color: Color4;
  50584. };
  50585. /**
  50586. * The name of the layer
  50587. */
  50588. name: string;
  50589. /**
  50590. * The clear color of the texture used to generate the glow map.
  50591. */
  50592. neutralColor: Color4;
  50593. /**
  50594. * Specifies wether the highlight layer is enabled or not.
  50595. */
  50596. isEnabled: boolean;
  50597. /**
  50598. * Gets the camera attached to the layer.
  50599. */
  50600. readonly camera: Nullable<Camera>;
  50601. /**
  50602. * Gets the rendering group id the layer should render in.
  50603. */
  50604. renderingGroupId: number;
  50605. /**
  50606. * An event triggered when the effect layer has been disposed.
  50607. */
  50608. onDisposeObservable: Observable<EffectLayer>;
  50609. /**
  50610. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50611. */
  50612. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50613. /**
  50614. * An event triggered when the generated texture is being merged in the scene.
  50615. */
  50616. onBeforeComposeObservable: Observable<EffectLayer>;
  50617. /**
  50618. * An event triggered when the generated texture has been merged in the scene.
  50619. */
  50620. onAfterComposeObservable: Observable<EffectLayer>;
  50621. /**
  50622. * An event triggered when the efffect layer changes its size.
  50623. */
  50624. onSizeChangedObservable: Observable<EffectLayer>;
  50625. /** @hidden */
  50626. static _SceneComponentInitialization: (scene: Scene) => void;
  50627. /**
  50628. * Instantiates a new effect Layer and references it in the scene.
  50629. * @param name The name of the layer
  50630. * @param scene The scene to use the layer in
  50631. */
  50632. constructor(
  50633. /** The Friendly of the effect in the scene */
  50634. name: string, scene: Scene);
  50635. /**
  50636. * Get the effect name of the layer.
  50637. * @return The effect name
  50638. */
  50639. abstract getEffectName(): string;
  50640. /**
  50641. * Checks for the readiness of the element composing the layer.
  50642. * @param subMesh the mesh to check for
  50643. * @param useInstances specify wether or not to use instances to render the mesh
  50644. * @return true if ready otherwise, false
  50645. */
  50646. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50647. /**
  50648. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50649. * @returns true if the effect requires stencil during the main canvas render pass.
  50650. */
  50651. abstract needStencil(): boolean;
  50652. /**
  50653. * Create the merge effect. This is the shader use to blit the information back
  50654. * to the main canvas at the end of the scene rendering.
  50655. * @returns The effect containing the shader used to merge the effect on the main canvas
  50656. */
  50657. protected abstract _createMergeEffect(): Effect;
  50658. /**
  50659. * Creates the render target textures and post processes used in the effect layer.
  50660. */
  50661. protected abstract _createTextureAndPostProcesses(): void;
  50662. /**
  50663. * Implementation specific of rendering the generating effect on the main canvas.
  50664. * @param effect The effect used to render through
  50665. */
  50666. protected abstract _internalRender(effect: Effect): void;
  50667. /**
  50668. * Sets the required values for both the emissive texture and and the main color.
  50669. */
  50670. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50671. /**
  50672. * Free any resources and references associated to a mesh.
  50673. * Internal use
  50674. * @param mesh The mesh to free.
  50675. */
  50676. abstract _disposeMesh(mesh: Mesh): void;
  50677. /**
  50678. * Serializes this layer (Glow or Highlight for example)
  50679. * @returns a serialized layer object
  50680. */
  50681. abstract serialize?(): any;
  50682. /**
  50683. * Initializes the effect layer with the required options.
  50684. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50685. */
  50686. protected _init(options: Partial<IEffectLayerOptions>): void;
  50687. /**
  50688. * Generates the index buffer of the full screen quad blending to the main canvas.
  50689. */
  50690. private _generateIndexBuffer;
  50691. /**
  50692. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50693. */
  50694. private _generateVertexBuffer;
  50695. /**
  50696. * Sets the main texture desired size which is the closest power of two
  50697. * of the engine canvas size.
  50698. */
  50699. private _setMainTextureSize;
  50700. /**
  50701. * Creates the main texture for the effect layer.
  50702. */
  50703. protected _createMainTexture(): void;
  50704. /**
  50705. * Adds specific effects defines.
  50706. * @param defines The defines to add specifics to.
  50707. */
  50708. protected _addCustomEffectDefines(defines: string[]): void;
  50709. /**
  50710. * Checks for the readiness of the element composing the layer.
  50711. * @param subMesh the mesh to check for
  50712. * @param useInstances specify wether or not to use instances to render the mesh
  50713. * @param emissiveTexture the associated emissive texture used to generate the glow
  50714. * @return true if ready otherwise, false
  50715. */
  50716. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50717. /**
  50718. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50719. */
  50720. render(): void;
  50721. /**
  50722. * Determine if a given mesh will be used in the current effect.
  50723. * @param mesh mesh to test
  50724. * @returns true if the mesh will be used
  50725. */
  50726. hasMesh(mesh: AbstractMesh): boolean;
  50727. /**
  50728. * Returns true if the layer contains information to display, otherwise false.
  50729. * @returns true if the glow layer should be rendered
  50730. */
  50731. shouldRender(): boolean;
  50732. /**
  50733. * Returns true if the mesh should render, otherwise false.
  50734. * @param mesh The mesh to render
  50735. * @returns true if it should render otherwise false
  50736. */
  50737. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50738. /**
  50739. * Returns true if the mesh can be rendered, otherwise false.
  50740. * @param mesh The mesh to render
  50741. * @param material The material used on the mesh
  50742. * @returns true if it can be rendered otherwise false
  50743. */
  50744. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50745. /**
  50746. * Returns true if the mesh should render, otherwise false.
  50747. * @param mesh The mesh to render
  50748. * @returns true if it should render otherwise false
  50749. */
  50750. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50751. /**
  50752. * Renders the submesh passed in parameter to the generation map.
  50753. */
  50754. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50755. /**
  50756. * Rebuild the required buffers.
  50757. * @hidden Internal use only.
  50758. */
  50759. _rebuild(): void;
  50760. /**
  50761. * Dispose only the render target textures and post process.
  50762. */
  50763. private _disposeTextureAndPostProcesses;
  50764. /**
  50765. * Dispose the highlight layer and free resources.
  50766. */
  50767. dispose(): void;
  50768. /**
  50769. * Gets the class name of the effect layer
  50770. * @returns the string with the class name of the effect layer
  50771. */
  50772. getClassName(): string;
  50773. /**
  50774. * Creates an effect layer from parsed effect layer data
  50775. * @param parsedEffectLayer defines effect layer data
  50776. * @param scene defines the current scene
  50777. * @param rootUrl defines the root URL containing the effect layer information
  50778. * @returns a parsed effect Layer
  50779. */
  50780. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50781. }
  50782. }
  50783. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50784. import { Scene } from "babylonjs/scene";
  50785. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50786. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50787. import { AbstractScene } from "babylonjs/abstractScene";
  50788. module "babylonjs/abstractScene" {
  50789. interface AbstractScene {
  50790. /**
  50791. * The list of effect layers (highlights/glow) added to the scene
  50792. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50793. * @see http://doc.babylonjs.com/how_to/glow_layer
  50794. */
  50795. effectLayers: Array<EffectLayer>;
  50796. /**
  50797. * Removes the given effect layer from this scene.
  50798. * @param toRemove defines the effect layer to remove
  50799. * @returns the index of the removed effect layer
  50800. */
  50801. removeEffectLayer(toRemove: EffectLayer): number;
  50802. /**
  50803. * Adds the given effect layer to this scene
  50804. * @param newEffectLayer defines the effect layer to add
  50805. */
  50806. addEffectLayer(newEffectLayer: EffectLayer): void;
  50807. }
  50808. }
  50809. /**
  50810. * Defines the layer scene component responsible to manage any effect layers
  50811. * in a given scene.
  50812. */
  50813. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50814. /**
  50815. * The component name helpfull to identify the component in the list of scene components.
  50816. */
  50817. readonly name: string;
  50818. /**
  50819. * The scene the component belongs to.
  50820. */
  50821. scene: Scene;
  50822. private _engine;
  50823. private _renderEffects;
  50824. private _needStencil;
  50825. private _previousStencilState;
  50826. /**
  50827. * Creates a new instance of the component for the given scene
  50828. * @param scene Defines the scene to register the component in
  50829. */
  50830. constructor(scene: Scene);
  50831. /**
  50832. * Registers the component in a given scene
  50833. */
  50834. register(): void;
  50835. /**
  50836. * Rebuilds the elements related to this component in case of
  50837. * context lost for instance.
  50838. */
  50839. rebuild(): void;
  50840. /**
  50841. * Serializes the component data to the specified json object
  50842. * @param serializationObject The object to serialize to
  50843. */
  50844. serialize(serializationObject: any): void;
  50845. /**
  50846. * Adds all the elements from the container to the scene
  50847. * @param container the container holding the elements
  50848. */
  50849. addFromContainer(container: AbstractScene): void;
  50850. /**
  50851. * Removes all the elements in the container from the scene
  50852. * @param container contains the elements to remove
  50853. * @param dispose if the removed element should be disposed (default: false)
  50854. */
  50855. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50856. /**
  50857. * Disposes the component and the associated ressources.
  50858. */
  50859. dispose(): void;
  50860. private _isReadyForMesh;
  50861. private _renderMainTexture;
  50862. private _setStencil;
  50863. private _setStencilBack;
  50864. private _draw;
  50865. private _drawCamera;
  50866. private _drawRenderingGroup;
  50867. }
  50868. }
  50869. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50870. /** @hidden */
  50871. export var glowMapMergePixelShader: {
  50872. name: string;
  50873. shader: string;
  50874. };
  50875. }
  50876. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50877. /** @hidden */
  50878. export var glowMapMergeVertexShader: {
  50879. name: string;
  50880. shader: string;
  50881. };
  50882. }
  50883. declare module "babylonjs/Layers/glowLayer" {
  50884. import { Nullable } from "babylonjs/types";
  50885. import { Camera } from "babylonjs/Cameras/camera";
  50886. import { Scene } from "babylonjs/scene";
  50887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50889. import { Mesh } from "babylonjs/Meshes/mesh";
  50890. import { Texture } from "babylonjs/Materials/Textures/texture";
  50891. import { Effect } from "babylonjs/Materials/effect";
  50892. import { Material } from "babylonjs/Materials/material";
  50893. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50894. import { Color4 } from "babylonjs/Maths/math.color";
  50895. import "babylonjs/Shaders/glowMapMerge.fragment";
  50896. import "babylonjs/Shaders/glowMapMerge.vertex";
  50897. import "babylonjs/Layers/effectLayerSceneComponent";
  50898. module "babylonjs/abstractScene" {
  50899. interface AbstractScene {
  50900. /**
  50901. * Return a the first highlight layer of the scene with a given name.
  50902. * @param name The name of the highlight layer to look for.
  50903. * @return The highlight layer if found otherwise null.
  50904. */
  50905. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50906. }
  50907. }
  50908. /**
  50909. * Glow layer options. This helps customizing the behaviour
  50910. * of the glow layer.
  50911. */
  50912. export interface IGlowLayerOptions {
  50913. /**
  50914. * Multiplication factor apply to the canvas size to compute the render target size
  50915. * used to generated the glowing objects (the smaller the faster).
  50916. */
  50917. mainTextureRatio: number;
  50918. /**
  50919. * Enforces a fixed size texture to ensure resize independant blur.
  50920. */
  50921. mainTextureFixedSize?: number;
  50922. /**
  50923. * How big is the kernel of the blur texture.
  50924. */
  50925. blurKernelSize: number;
  50926. /**
  50927. * The camera attached to the layer.
  50928. */
  50929. camera: Nullable<Camera>;
  50930. /**
  50931. * Enable MSAA by chosing the number of samples.
  50932. */
  50933. mainTextureSamples?: number;
  50934. /**
  50935. * The rendering group to draw the layer in.
  50936. */
  50937. renderingGroupId: number;
  50938. }
  50939. /**
  50940. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50941. *
  50942. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50943. * glowy meshes to your scene.
  50944. *
  50945. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50946. */
  50947. export class GlowLayer extends EffectLayer {
  50948. /**
  50949. * Effect Name of the layer.
  50950. */
  50951. static readonly EffectName: string;
  50952. /**
  50953. * The default blur kernel size used for the glow.
  50954. */
  50955. static DefaultBlurKernelSize: number;
  50956. /**
  50957. * The default texture size ratio used for the glow.
  50958. */
  50959. static DefaultTextureRatio: number;
  50960. /**
  50961. * Sets the kernel size of the blur.
  50962. */
  50963. /**
  50964. * Gets the kernel size of the blur.
  50965. */
  50966. blurKernelSize: number;
  50967. /**
  50968. * Sets the glow intensity.
  50969. */
  50970. /**
  50971. * Gets the glow intensity.
  50972. */
  50973. intensity: number;
  50974. private _options;
  50975. private _intensity;
  50976. private _horizontalBlurPostprocess1;
  50977. private _verticalBlurPostprocess1;
  50978. private _horizontalBlurPostprocess2;
  50979. private _verticalBlurPostprocess2;
  50980. private _blurTexture1;
  50981. private _blurTexture2;
  50982. private _postProcesses1;
  50983. private _postProcesses2;
  50984. private _includedOnlyMeshes;
  50985. private _excludedMeshes;
  50986. /**
  50987. * Callback used to let the user override the color selection on a per mesh basis
  50988. */
  50989. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50990. /**
  50991. * Callback used to let the user override the texture selection on a per mesh basis
  50992. */
  50993. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50994. /**
  50995. * Instantiates a new glow Layer and references it to the scene.
  50996. * @param name The name of the layer
  50997. * @param scene The scene to use the layer in
  50998. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50999. */
  51000. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51001. /**
  51002. * Get the effect name of the layer.
  51003. * @return The effect name
  51004. */
  51005. getEffectName(): string;
  51006. /**
  51007. * Create the merge effect. This is the shader use to blit the information back
  51008. * to the main canvas at the end of the scene rendering.
  51009. */
  51010. protected _createMergeEffect(): Effect;
  51011. /**
  51012. * Creates the render target textures and post processes used in the glow layer.
  51013. */
  51014. protected _createTextureAndPostProcesses(): void;
  51015. /**
  51016. * Checks for the readiness of the element composing the layer.
  51017. * @param subMesh the mesh to check for
  51018. * @param useInstances specify wether or not to use instances to render the mesh
  51019. * @param emissiveTexture the associated emissive texture used to generate the glow
  51020. * @return true if ready otherwise, false
  51021. */
  51022. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51023. /**
  51024. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51025. */
  51026. needStencil(): boolean;
  51027. /**
  51028. * Returns true if the mesh can be rendered, otherwise false.
  51029. * @param mesh The mesh to render
  51030. * @param material The material used on the mesh
  51031. * @returns true if it can be rendered otherwise false
  51032. */
  51033. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51034. /**
  51035. * Implementation specific of rendering the generating effect on the main canvas.
  51036. * @param effect The effect used to render through
  51037. */
  51038. protected _internalRender(effect: Effect): void;
  51039. /**
  51040. * Sets the required values for both the emissive texture and and the main color.
  51041. */
  51042. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51043. /**
  51044. * Returns true if the mesh should render, otherwise false.
  51045. * @param mesh The mesh to render
  51046. * @returns true if it should render otherwise false
  51047. */
  51048. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51049. /**
  51050. * Adds specific effects defines.
  51051. * @param defines The defines to add specifics to.
  51052. */
  51053. protected _addCustomEffectDefines(defines: string[]): void;
  51054. /**
  51055. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51056. * @param mesh The mesh to exclude from the glow layer
  51057. */
  51058. addExcludedMesh(mesh: Mesh): void;
  51059. /**
  51060. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51061. * @param mesh The mesh to remove
  51062. */
  51063. removeExcludedMesh(mesh: Mesh): void;
  51064. /**
  51065. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51066. * @param mesh The mesh to include in the glow layer
  51067. */
  51068. addIncludedOnlyMesh(mesh: Mesh): void;
  51069. /**
  51070. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51071. * @param mesh The mesh to remove
  51072. */
  51073. removeIncludedOnlyMesh(mesh: Mesh): void;
  51074. /**
  51075. * Determine if a given mesh will be used in the glow layer
  51076. * @param mesh The mesh to test
  51077. * @returns true if the mesh will be highlighted by the current glow layer
  51078. */
  51079. hasMesh(mesh: AbstractMesh): boolean;
  51080. /**
  51081. * Free any resources and references associated to a mesh.
  51082. * Internal use
  51083. * @param mesh The mesh to free.
  51084. * @hidden
  51085. */
  51086. _disposeMesh(mesh: Mesh): void;
  51087. /**
  51088. * Gets the class name of the effect layer
  51089. * @returns the string with the class name of the effect layer
  51090. */
  51091. getClassName(): string;
  51092. /**
  51093. * Serializes this glow layer
  51094. * @returns a serialized glow layer object
  51095. */
  51096. serialize(): any;
  51097. /**
  51098. * Creates a Glow Layer from parsed glow layer data
  51099. * @param parsedGlowLayer defines glow layer data
  51100. * @param scene defines the current scene
  51101. * @param rootUrl defines the root URL containing the glow layer information
  51102. * @returns a parsed Glow Layer
  51103. */
  51104. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51105. }
  51106. }
  51107. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51108. /** @hidden */
  51109. export var glowBlurPostProcessPixelShader: {
  51110. name: string;
  51111. shader: string;
  51112. };
  51113. }
  51114. declare module "babylonjs/Layers/highlightLayer" {
  51115. import { Observable } from "babylonjs/Misc/observable";
  51116. import { Nullable } from "babylonjs/types";
  51117. import { Camera } from "babylonjs/Cameras/camera";
  51118. import { Scene } from "babylonjs/scene";
  51119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51121. import { Mesh } from "babylonjs/Meshes/mesh";
  51122. import { Effect } from "babylonjs/Materials/effect";
  51123. import { Material } from "babylonjs/Materials/material";
  51124. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51125. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51126. import "babylonjs/Shaders/glowMapMerge.fragment";
  51127. import "babylonjs/Shaders/glowMapMerge.vertex";
  51128. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51129. module "babylonjs/abstractScene" {
  51130. interface AbstractScene {
  51131. /**
  51132. * Return a the first highlight layer of the scene with a given name.
  51133. * @param name The name of the highlight layer to look for.
  51134. * @return The highlight layer if found otherwise null.
  51135. */
  51136. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51137. }
  51138. }
  51139. /**
  51140. * Highlight layer options. This helps customizing the behaviour
  51141. * of the highlight layer.
  51142. */
  51143. export interface IHighlightLayerOptions {
  51144. /**
  51145. * Multiplication factor apply to the canvas size to compute the render target size
  51146. * used to generated the glowing objects (the smaller the faster).
  51147. */
  51148. mainTextureRatio: number;
  51149. /**
  51150. * Enforces a fixed size texture to ensure resize independant blur.
  51151. */
  51152. mainTextureFixedSize?: number;
  51153. /**
  51154. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51155. * of the picture to blur (the smaller the faster).
  51156. */
  51157. blurTextureSizeRatio: number;
  51158. /**
  51159. * How big in texel of the blur texture is the vertical blur.
  51160. */
  51161. blurVerticalSize: number;
  51162. /**
  51163. * How big in texel of the blur texture is the horizontal blur.
  51164. */
  51165. blurHorizontalSize: number;
  51166. /**
  51167. * Alpha blending mode used to apply the blur. Default is combine.
  51168. */
  51169. alphaBlendingMode: number;
  51170. /**
  51171. * The camera attached to the layer.
  51172. */
  51173. camera: Nullable<Camera>;
  51174. /**
  51175. * Should we display highlight as a solid stroke?
  51176. */
  51177. isStroke?: boolean;
  51178. /**
  51179. * The rendering group to draw the layer in.
  51180. */
  51181. renderingGroupId: number;
  51182. }
  51183. /**
  51184. * The highlight layer Helps adding a glow effect around a mesh.
  51185. *
  51186. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51187. * glowy meshes to your scene.
  51188. *
  51189. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51190. */
  51191. export class HighlightLayer extends EffectLayer {
  51192. name: string;
  51193. /**
  51194. * Effect Name of the highlight layer.
  51195. */
  51196. static readonly EffectName: string;
  51197. /**
  51198. * The neutral color used during the preparation of the glow effect.
  51199. * This is black by default as the blend operation is a blend operation.
  51200. */
  51201. static NeutralColor: Color4;
  51202. /**
  51203. * Stencil value used for glowing meshes.
  51204. */
  51205. static GlowingMeshStencilReference: number;
  51206. /**
  51207. * Stencil value used for the other meshes in the scene.
  51208. */
  51209. static NormalMeshStencilReference: number;
  51210. /**
  51211. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51212. */
  51213. innerGlow: boolean;
  51214. /**
  51215. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51216. */
  51217. outerGlow: boolean;
  51218. /**
  51219. * Specifies the horizontal size of the blur.
  51220. */
  51221. /**
  51222. * Gets the horizontal size of the blur.
  51223. */
  51224. blurHorizontalSize: number;
  51225. /**
  51226. * Specifies the vertical size of the blur.
  51227. */
  51228. /**
  51229. * Gets the vertical size of the blur.
  51230. */
  51231. blurVerticalSize: number;
  51232. /**
  51233. * An event triggered when the highlight layer is being blurred.
  51234. */
  51235. onBeforeBlurObservable: Observable<HighlightLayer>;
  51236. /**
  51237. * An event triggered when the highlight layer has been blurred.
  51238. */
  51239. onAfterBlurObservable: Observable<HighlightLayer>;
  51240. private _instanceGlowingMeshStencilReference;
  51241. private _options;
  51242. private _downSamplePostprocess;
  51243. private _horizontalBlurPostprocess;
  51244. private _verticalBlurPostprocess;
  51245. private _blurTexture;
  51246. private _meshes;
  51247. private _excludedMeshes;
  51248. /**
  51249. * Instantiates a new highlight Layer and references it to the scene..
  51250. * @param name The name of the layer
  51251. * @param scene The scene to use the layer in
  51252. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51253. */
  51254. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51255. /**
  51256. * Get the effect name of the layer.
  51257. * @return The effect name
  51258. */
  51259. getEffectName(): string;
  51260. /**
  51261. * Create the merge effect. This is the shader use to blit the information back
  51262. * to the main canvas at the end of the scene rendering.
  51263. */
  51264. protected _createMergeEffect(): Effect;
  51265. /**
  51266. * Creates the render target textures and post processes used in the highlight layer.
  51267. */
  51268. protected _createTextureAndPostProcesses(): void;
  51269. /**
  51270. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51271. */
  51272. needStencil(): boolean;
  51273. /**
  51274. * Checks for the readiness of the element composing the layer.
  51275. * @param subMesh the mesh to check for
  51276. * @param useInstances specify wether or not to use instances to render the mesh
  51277. * @param emissiveTexture the associated emissive texture used to generate the glow
  51278. * @return true if ready otherwise, false
  51279. */
  51280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51281. /**
  51282. * Implementation specific of rendering the generating effect on the main canvas.
  51283. * @param effect The effect used to render through
  51284. */
  51285. protected _internalRender(effect: Effect): void;
  51286. /**
  51287. * Returns true if the layer contains information to display, otherwise false.
  51288. */
  51289. shouldRender(): boolean;
  51290. /**
  51291. * Returns true if the mesh should render, otherwise false.
  51292. * @param mesh The mesh to render
  51293. * @returns true if it should render otherwise false
  51294. */
  51295. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51296. /**
  51297. * Sets the required values for both the emissive texture and and the main color.
  51298. */
  51299. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51300. /**
  51301. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51302. * @param mesh The mesh to exclude from the highlight layer
  51303. */
  51304. addExcludedMesh(mesh: Mesh): void;
  51305. /**
  51306. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51307. * @param mesh The mesh to highlight
  51308. */
  51309. removeExcludedMesh(mesh: Mesh): void;
  51310. /**
  51311. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51312. * @param mesh mesh to test
  51313. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51314. */
  51315. hasMesh(mesh: AbstractMesh): boolean;
  51316. /**
  51317. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51318. * @param mesh The mesh to highlight
  51319. * @param color The color of the highlight
  51320. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51321. */
  51322. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51323. /**
  51324. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51325. * @param mesh The mesh to highlight
  51326. */
  51327. removeMesh(mesh: Mesh): void;
  51328. /**
  51329. * Force the stencil to the normal expected value for none glowing parts
  51330. */
  51331. private _defaultStencilReference;
  51332. /**
  51333. * Free any resources and references associated to a mesh.
  51334. * Internal use
  51335. * @param mesh The mesh to free.
  51336. * @hidden
  51337. */
  51338. _disposeMesh(mesh: Mesh): void;
  51339. /**
  51340. * Dispose the highlight layer and free resources.
  51341. */
  51342. dispose(): void;
  51343. /**
  51344. * Gets the class name of the effect layer
  51345. * @returns the string with the class name of the effect layer
  51346. */
  51347. getClassName(): string;
  51348. /**
  51349. * Serializes this Highlight layer
  51350. * @returns a serialized Highlight layer object
  51351. */
  51352. serialize(): any;
  51353. /**
  51354. * Creates a Highlight layer from parsed Highlight layer data
  51355. * @param parsedHightlightLayer defines the Highlight layer data
  51356. * @param scene defines the current scene
  51357. * @param rootUrl defines the root URL containing the Highlight layer information
  51358. * @returns a parsed Highlight layer
  51359. */
  51360. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51361. }
  51362. }
  51363. declare module "babylonjs/Layers/layerSceneComponent" {
  51364. import { Scene } from "babylonjs/scene";
  51365. import { ISceneComponent } from "babylonjs/sceneComponent";
  51366. import { Layer } from "babylonjs/Layers/layer";
  51367. import { AbstractScene } from "babylonjs/abstractScene";
  51368. module "babylonjs/abstractScene" {
  51369. interface AbstractScene {
  51370. /**
  51371. * The list of layers (background and foreground) of the scene
  51372. */
  51373. layers: Array<Layer>;
  51374. }
  51375. }
  51376. /**
  51377. * Defines the layer scene component responsible to manage any layers
  51378. * in a given scene.
  51379. */
  51380. export class LayerSceneComponent implements ISceneComponent {
  51381. /**
  51382. * The component name helpfull to identify the component in the list of scene components.
  51383. */
  51384. readonly name: string;
  51385. /**
  51386. * The scene the component belongs to.
  51387. */
  51388. scene: Scene;
  51389. private _engine;
  51390. /**
  51391. * Creates a new instance of the component for the given scene
  51392. * @param scene Defines the scene to register the component in
  51393. */
  51394. constructor(scene: Scene);
  51395. /**
  51396. * Registers the component in a given scene
  51397. */
  51398. register(): void;
  51399. /**
  51400. * Rebuilds the elements related to this component in case of
  51401. * context lost for instance.
  51402. */
  51403. rebuild(): void;
  51404. /**
  51405. * Disposes the component and the associated ressources.
  51406. */
  51407. dispose(): void;
  51408. private _draw;
  51409. private _drawCameraPredicate;
  51410. private _drawCameraBackground;
  51411. private _drawCameraForeground;
  51412. private _drawRenderTargetPredicate;
  51413. private _drawRenderTargetBackground;
  51414. private _drawRenderTargetForeground;
  51415. /**
  51416. * Adds all the elements from the container to the scene
  51417. * @param container the container holding the elements
  51418. */
  51419. addFromContainer(container: AbstractScene): void;
  51420. /**
  51421. * Removes all the elements in the container from the scene
  51422. * @param container contains the elements to remove
  51423. * @param dispose if the removed element should be disposed (default: false)
  51424. */
  51425. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51426. }
  51427. }
  51428. declare module "babylonjs/Shaders/layer.fragment" {
  51429. /** @hidden */
  51430. export var layerPixelShader: {
  51431. name: string;
  51432. shader: string;
  51433. };
  51434. }
  51435. declare module "babylonjs/Shaders/layer.vertex" {
  51436. /** @hidden */
  51437. export var layerVertexShader: {
  51438. name: string;
  51439. shader: string;
  51440. };
  51441. }
  51442. declare module "babylonjs/Layers/layer" {
  51443. import { Observable } from "babylonjs/Misc/observable";
  51444. import { Nullable } from "babylonjs/types";
  51445. import { Scene } from "babylonjs/scene";
  51446. import { Vector2 } from "babylonjs/Maths/math.vector";
  51447. import { Color4 } from "babylonjs/Maths/math.color";
  51448. import { Texture } from "babylonjs/Materials/Textures/texture";
  51449. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51450. import "babylonjs/Shaders/layer.fragment";
  51451. import "babylonjs/Shaders/layer.vertex";
  51452. /**
  51453. * This represents a full screen 2d layer.
  51454. * This can be useful to display a picture in the background of your scene for instance.
  51455. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51456. */
  51457. export class Layer {
  51458. /**
  51459. * Define the name of the layer.
  51460. */
  51461. name: string;
  51462. /**
  51463. * Define the texture the layer should display.
  51464. */
  51465. texture: Nullable<Texture>;
  51466. /**
  51467. * Is the layer in background or foreground.
  51468. */
  51469. isBackground: boolean;
  51470. /**
  51471. * Define the color of the layer (instead of texture).
  51472. */
  51473. color: Color4;
  51474. /**
  51475. * Define the scale of the layer in order to zoom in out of the texture.
  51476. */
  51477. scale: Vector2;
  51478. /**
  51479. * Define an offset for the layer in order to shift the texture.
  51480. */
  51481. offset: Vector2;
  51482. /**
  51483. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51484. */
  51485. alphaBlendingMode: number;
  51486. /**
  51487. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51488. * Alpha test will not mix with the background color in case of transparency.
  51489. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51490. */
  51491. alphaTest: boolean;
  51492. /**
  51493. * Define a mask to restrict the layer to only some of the scene cameras.
  51494. */
  51495. layerMask: number;
  51496. /**
  51497. * Define the list of render target the layer is visible into.
  51498. */
  51499. renderTargetTextures: RenderTargetTexture[];
  51500. /**
  51501. * Define if the layer is only used in renderTarget or if it also
  51502. * renders in the main frame buffer of the canvas.
  51503. */
  51504. renderOnlyInRenderTargetTextures: boolean;
  51505. private _scene;
  51506. private _vertexBuffers;
  51507. private _indexBuffer;
  51508. private _effect;
  51509. private _alphaTestEffect;
  51510. /**
  51511. * An event triggered when the layer is disposed.
  51512. */
  51513. onDisposeObservable: Observable<Layer>;
  51514. private _onDisposeObserver;
  51515. /**
  51516. * Back compatibility with callback before the onDisposeObservable existed.
  51517. * The set callback will be triggered when the layer has been disposed.
  51518. */
  51519. onDispose: () => void;
  51520. /**
  51521. * An event triggered before rendering the scene
  51522. */
  51523. onBeforeRenderObservable: Observable<Layer>;
  51524. private _onBeforeRenderObserver;
  51525. /**
  51526. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51527. * The set callback will be triggered just before rendering the layer.
  51528. */
  51529. onBeforeRender: () => void;
  51530. /**
  51531. * An event triggered after rendering the scene
  51532. */
  51533. onAfterRenderObservable: Observable<Layer>;
  51534. private _onAfterRenderObserver;
  51535. /**
  51536. * Back compatibility with callback before the onAfterRenderObservable existed.
  51537. * The set callback will be triggered just after rendering the layer.
  51538. */
  51539. onAfterRender: () => void;
  51540. /**
  51541. * Instantiates a new layer.
  51542. * This represents a full screen 2d layer.
  51543. * This can be useful to display a picture in the background of your scene for instance.
  51544. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51545. * @param name Define the name of the layer in the scene
  51546. * @param imgUrl Define the url of the texture to display in the layer
  51547. * @param scene Define the scene the layer belongs to
  51548. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51549. * @param color Defines a color for the layer
  51550. */
  51551. constructor(
  51552. /**
  51553. * Define the name of the layer.
  51554. */
  51555. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51556. private _createIndexBuffer;
  51557. /** @hidden */
  51558. _rebuild(): void;
  51559. /**
  51560. * Renders the layer in the scene.
  51561. */
  51562. render(): void;
  51563. /**
  51564. * Disposes and releases the associated ressources.
  51565. */
  51566. dispose(): void;
  51567. }
  51568. }
  51569. declare module "babylonjs/Layers/index" {
  51570. export * from "babylonjs/Layers/effectLayer";
  51571. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51572. export * from "babylonjs/Layers/glowLayer";
  51573. export * from "babylonjs/Layers/highlightLayer";
  51574. export * from "babylonjs/Layers/layer";
  51575. export * from "babylonjs/Layers/layerSceneComponent";
  51576. }
  51577. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51578. /** @hidden */
  51579. export var lensFlarePixelShader: {
  51580. name: string;
  51581. shader: string;
  51582. };
  51583. }
  51584. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51585. /** @hidden */
  51586. export var lensFlareVertexShader: {
  51587. name: string;
  51588. shader: string;
  51589. };
  51590. }
  51591. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51592. import { Scene } from "babylonjs/scene";
  51593. import { Vector3 } from "babylonjs/Maths/math.vector";
  51594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51595. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51596. import "babylonjs/Shaders/lensFlare.fragment";
  51597. import "babylonjs/Shaders/lensFlare.vertex";
  51598. import { Viewport } from "babylonjs/Maths/math.viewport";
  51599. /**
  51600. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51601. * It is usually composed of several `lensFlare`.
  51602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51603. */
  51604. export class LensFlareSystem {
  51605. /**
  51606. * Define the name of the lens flare system
  51607. */
  51608. name: string;
  51609. /**
  51610. * List of lens flares used in this system.
  51611. */
  51612. lensFlares: LensFlare[];
  51613. /**
  51614. * Define a limit from the border the lens flare can be visible.
  51615. */
  51616. borderLimit: number;
  51617. /**
  51618. * Define a viewport border we do not want to see the lens flare in.
  51619. */
  51620. viewportBorder: number;
  51621. /**
  51622. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51623. */
  51624. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51625. /**
  51626. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51627. */
  51628. layerMask: number;
  51629. /**
  51630. * Define the id of the lens flare system in the scene.
  51631. * (equal to name by default)
  51632. */
  51633. id: string;
  51634. private _scene;
  51635. private _emitter;
  51636. private _vertexBuffers;
  51637. private _indexBuffer;
  51638. private _effect;
  51639. private _positionX;
  51640. private _positionY;
  51641. private _isEnabled;
  51642. /** @hidden */
  51643. static _SceneComponentInitialization: (scene: Scene) => void;
  51644. /**
  51645. * Instantiates a lens flare system.
  51646. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51647. * It is usually composed of several `lensFlare`.
  51648. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51649. * @param name Define the name of the lens flare system in the scene
  51650. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51651. * @param scene Define the scene the lens flare system belongs to
  51652. */
  51653. constructor(
  51654. /**
  51655. * Define the name of the lens flare system
  51656. */
  51657. name: string, emitter: any, scene: Scene);
  51658. /**
  51659. * Define if the lens flare system is enabled.
  51660. */
  51661. isEnabled: boolean;
  51662. /**
  51663. * Get the scene the effects belongs to.
  51664. * @returns the scene holding the lens flare system
  51665. */
  51666. getScene(): Scene;
  51667. /**
  51668. * Get the emitter of the lens flare system.
  51669. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51670. * @returns the emitter of the lens flare system
  51671. */
  51672. getEmitter(): any;
  51673. /**
  51674. * Set the emitter of the lens flare system.
  51675. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51676. * @param newEmitter Define the new emitter of the system
  51677. */
  51678. setEmitter(newEmitter: any): void;
  51679. /**
  51680. * Get the lens flare system emitter position.
  51681. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51682. * @returns the position
  51683. */
  51684. getEmitterPosition(): Vector3;
  51685. /**
  51686. * @hidden
  51687. */
  51688. computeEffectivePosition(globalViewport: Viewport): boolean;
  51689. /** @hidden */
  51690. _isVisible(): boolean;
  51691. /**
  51692. * @hidden
  51693. */
  51694. render(): boolean;
  51695. /**
  51696. * Dispose and release the lens flare with its associated resources.
  51697. */
  51698. dispose(): void;
  51699. /**
  51700. * Parse a lens flare system from a JSON repressentation
  51701. * @param parsedLensFlareSystem Define the JSON to parse
  51702. * @param scene Define the scene the parsed system should be instantiated in
  51703. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51704. * @returns the parsed system
  51705. */
  51706. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51707. /**
  51708. * Serialize the current Lens Flare System into a JSON representation.
  51709. * @returns the serialized JSON
  51710. */
  51711. serialize(): any;
  51712. }
  51713. }
  51714. declare module "babylonjs/LensFlares/lensFlare" {
  51715. import { Nullable } from "babylonjs/types";
  51716. import { Color3 } from "babylonjs/Maths/math.color";
  51717. import { Texture } from "babylonjs/Materials/Textures/texture";
  51718. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51719. /**
  51720. * This represents one of the lens effect in a `lensFlareSystem`.
  51721. * It controls one of the indiviual texture used in the effect.
  51722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51723. */
  51724. export class LensFlare {
  51725. /**
  51726. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51727. */
  51728. size: number;
  51729. /**
  51730. * 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.
  51731. */
  51732. position: number;
  51733. /**
  51734. * Define the lens color.
  51735. */
  51736. color: Color3;
  51737. /**
  51738. * Define the lens texture.
  51739. */
  51740. texture: Nullable<Texture>;
  51741. /**
  51742. * Define the alpha mode to render this particular lens.
  51743. */
  51744. alphaMode: number;
  51745. private _system;
  51746. /**
  51747. * Creates a new Lens Flare.
  51748. * This represents one of the lens effect in a `lensFlareSystem`.
  51749. * It controls one of the indiviual texture used in the effect.
  51750. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51751. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51752. * @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.
  51753. * @param color Define the lens color
  51754. * @param imgUrl Define the lens texture url
  51755. * @param system Define the `lensFlareSystem` this flare is part of
  51756. * @returns The newly created Lens Flare
  51757. */
  51758. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51759. /**
  51760. * Instantiates a new Lens Flare.
  51761. * This represents one of the lens effect in a `lensFlareSystem`.
  51762. * It controls one of the indiviual texture used in the effect.
  51763. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51764. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51765. * @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.
  51766. * @param color Define the lens color
  51767. * @param imgUrl Define the lens texture url
  51768. * @param system Define the `lensFlareSystem` this flare is part of
  51769. */
  51770. constructor(
  51771. /**
  51772. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51773. */
  51774. size: number,
  51775. /**
  51776. * 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.
  51777. */
  51778. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51779. /**
  51780. * Dispose and release the lens flare with its associated resources.
  51781. */
  51782. dispose(): void;
  51783. }
  51784. }
  51785. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51786. import { Nullable } from "babylonjs/types";
  51787. import { Scene } from "babylonjs/scene";
  51788. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51789. import { AbstractScene } from "babylonjs/abstractScene";
  51790. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51791. module "babylonjs/abstractScene" {
  51792. interface AbstractScene {
  51793. /**
  51794. * The list of lens flare system added to the scene
  51795. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51796. */
  51797. lensFlareSystems: Array<LensFlareSystem>;
  51798. /**
  51799. * Removes the given lens flare system from this scene.
  51800. * @param toRemove The lens flare system to remove
  51801. * @returns The index of the removed lens flare system
  51802. */
  51803. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51804. /**
  51805. * Adds the given lens flare system to this scene
  51806. * @param newLensFlareSystem The lens flare system to add
  51807. */
  51808. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51809. /**
  51810. * Gets a lens flare system using its name
  51811. * @param name defines the name to look for
  51812. * @returns the lens flare system or null if not found
  51813. */
  51814. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51815. /**
  51816. * Gets a lens flare system using its id
  51817. * @param id defines the id to look for
  51818. * @returns the lens flare system or null if not found
  51819. */
  51820. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51821. }
  51822. }
  51823. /**
  51824. * Defines the lens flare scene component responsible to manage any lens flares
  51825. * in a given scene.
  51826. */
  51827. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51828. /**
  51829. * The component name helpfull to identify the component in the list of scene components.
  51830. */
  51831. readonly name: string;
  51832. /**
  51833. * The scene the component belongs to.
  51834. */
  51835. scene: Scene;
  51836. /**
  51837. * Creates a new instance of the component for the given scene
  51838. * @param scene Defines the scene to register the component in
  51839. */
  51840. constructor(scene: Scene);
  51841. /**
  51842. * Registers the component in a given scene
  51843. */
  51844. register(): void;
  51845. /**
  51846. * Rebuilds the elements related to this component in case of
  51847. * context lost for instance.
  51848. */
  51849. rebuild(): void;
  51850. /**
  51851. * Adds all the elements from the container to the scene
  51852. * @param container the container holding the elements
  51853. */
  51854. addFromContainer(container: AbstractScene): void;
  51855. /**
  51856. * Removes all the elements in the container from the scene
  51857. * @param container contains the elements to remove
  51858. * @param dispose if the removed element should be disposed (default: false)
  51859. */
  51860. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51861. /**
  51862. * Serializes the component data to the specified json object
  51863. * @param serializationObject The object to serialize to
  51864. */
  51865. serialize(serializationObject: any): void;
  51866. /**
  51867. * Disposes the component and the associated ressources.
  51868. */
  51869. dispose(): void;
  51870. private _draw;
  51871. }
  51872. }
  51873. declare module "babylonjs/LensFlares/index" {
  51874. export * from "babylonjs/LensFlares/lensFlare";
  51875. export * from "babylonjs/LensFlares/lensFlareSystem";
  51876. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51877. }
  51878. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51879. import { Scene } from "babylonjs/scene";
  51880. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51881. import { AbstractScene } from "babylonjs/abstractScene";
  51882. /**
  51883. * Defines the shadow generator component responsible to manage any shadow generators
  51884. * in a given scene.
  51885. */
  51886. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51887. /**
  51888. * The component name helpfull to identify the component in the list of scene components.
  51889. */
  51890. readonly name: string;
  51891. /**
  51892. * The scene the component belongs to.
  51893. */
  51894. scene: Scene;
  51895. /**
  51896. * Creates a new instance of the component for the given scene
  51897. * @param scene Defines the scene to register the component in
  51898. */
  51899. constructor(scene: Scene);
  51900. /**
  51901. * Registers the component in a given scene
  51902. */
  51903. register(): void;
  51904. /**
  51905. * Rebuilds the elements related to this component in case of
  51906. * context lost for instance.
  51907. */
  51908. rebuild(): void;
  51909. /**
  51910. * Serializes the component data to the specified json object
  51911. * @param serializationObject The object to serialize to
  51912. */
  51913. serialize(serializationObject: any): void;
  51914. /**
  51915. * Adds all the elements from the container to the scene
  51916. * @param container the container holding the elements
  51917. */
  51918. addFromContainer(container: AbstractScene): void;
  51919. /**
  51920. * Removes all the elements in the container from the scene
  51921. * @param container contains the elements to remove
  51922. * @param dispose if the removed element should be disposed (default: false)
  51923. */
  51924. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51925. /**
  51926. * Rebuilds the elements related to this component in case of
  51927. * context lost for instance.
  51928. */
  51929. dispose(): void;
  51930. private _gatherRenderTargets;
  51931. }
  51932. }
  51933. declare module "babylonjs/Lights/Shadows/index" {
  51934. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51935. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51936. }
  51937. declare module "babylonjs/Lights/pointLight" {
  51938. import { Scene } from "babylonjs/scene";
  51939. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51941. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51942. import { Effect } from "babylonjs/Materials/effect";
  51943. /**
  51944. * A point light is a light defined by an unique point in world space.
  51945. * The light is emitted in every direction from this point.
  51946. * A good example of a point light is a standard light bulb.
  51947. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51948. */
  51949. export class PointLight extends ShadowLight {
  51950. private _shadowAngle;
  51951. /**
  51952. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51953. * This specifies what angle the shadow will use to be created.
  51954. *
  51955. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51956. */
  51957. /**
  51958. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51959. * This specifies what angle the shadow will use to be created.
  51960. *
  51961. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51962. */
  51963. shadowAngle: number;
  51964. /**
  51965. * Gets the direction if it has been set.
  51966. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51967. */
  51968. /**
  51969. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51970. */
  51971. direction: Vector3;
  51972. /**
  51973. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51974. * A PointLight emits the light in every direction.
  51975. * It can cast shadows.
  51976. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51977. * ```javascript
  51978. * var pointLight = new PointLight("pl", camera.position, scene);
  51979. * ```
  51980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51981. * @param name The light friendly name
  51982. * @param position The position of the point light in the scene
  51983. * @param scene The scene the lights belongs to
  51984. */
  51985. constructor(name: string, position: Vector3, scene: Scene);
  51986. /**
  51987. * Returns the string "PointLight"
  51988. * @returns the class name
  51989. */
  51990. getClassName(): string;
  51991. /**
  51992. * Returns the integer 0.
  51993. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51994. */
  51995. getTypeID(): number;
  51996. /**
  51997. * Specifies wether or not the shadowmap should be a cube texture.
  51998. * @returns true if the shadowmap needs to be a cube texture.
  51999. */
  52000. needCube(): boolean;
  52001. /**
  52002. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52003. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52004. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52005. */
  52006. getShadowDirection(faceIndex?: number): Vector3;
  52007. /**
  52008. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52009. * - fov = PI / 2
  52010. * - aspect ratio : 1.0
  52011. * - z-near and far equal to the active camera minZ and maxZ.
  52012. * Returns the PointLight.
  52013. */
  52014. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52015. protected _buildUniformLayout(): void;
  52016. /**
  52017. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52018. * @param effect The effect to update
  52019. * @param lightIndex The index of the light in the effect to update
  52020. * @returns The point light
  52021. */
  52022. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52023. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52024. /**
  52025. * Prepares the list of defines specific to the light type.
  52026. * @param defines the list of defines
  52027. * @param lightIndex defines the index of the light for the effect
  52028. */
  52029. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52030. }
  52031. }
  52032. declare module "babylonjs/Lights/index" {
  52033. export * from "babylonjs/Lights/light";
  52034. export * from "babylonjs/Lights/shadowLight";
  52035. export * from "babylonjs/Lights/Shadows/index";
  52036. export * from "babylonjs/Lights/directionalLight";
  52037. export * from "babylonjs/Lights/hemisphericLight";
  52038. export * from "babylonjs/Lights/pointLight";
  52039. export * from "babylonjs/Lights/spotLight";
  52040. }
  52041. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52042. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52043. /**
  52044. * Header information of HDR texture files.
  52045. */
  52046. export interface HDRInfo {
  52047. /**
  52048. * The height of the texture in pixels.
  52049. */
  52050. height: number;
  52051. /**
  52052. * The width of the texture in pixels.
  52053. */
  52054. width: number;
  52055. /**
  52056. * The index of the beginning of the data in the binary file.
  52057. */
  52058. dataPosition: number;
  52059. }
  52060. /**
  52061. * This groups tools to convert HDR texture to native colors array.
  52062. */
  52063. export class HDRTools {
  52064. private static Ldexp;
  52065. private static Rgbe2float;
  52066. private static readStringLine;
  52067. /**
  52068. * Reads header information from an RGBE texture stored in a native array.
  52069. * More information on this format are available here:
  52070. * https://en.wikipedia.org/wiki/RGBE_image_format
  52071. *
  52072. * @param uint8array The binary file stored in native array.
  52073. * @return The header information.
  52074. */
  52075. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52076. /**
  52077. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52078. * This RGBE texture needs to store the information as a panorama.
  52079. *
  52080. * More information on this format are available here:
  52081. * https://en.wikipedia.org/wiki/RGBE_image_format
  52082. *
  52083. * @param buffer The binary file stored in an array buffer.
  52084. * @param size The expected size of the extracted cubemap.
  52085. * @return The Cube Map information.
  52086. */
  52087. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52088. /**
  52089. * Returns the pixels data extracted from an RGBE texture.
  52090. * This pixels will be stored left to right up to down in the R G B order in one array.
  52091. *
  52092. * More information on this format are available here:
  52093. * https://en.wikipedia.org/wiki/RGBE_image_format
  52094. *
  52095. * @param uint8array The binary file stored in an array buffer.
  52096. * @param hdrInfo The header information of the file.
  52097. * @return The pixels data in RGB right to left up to down order.
  52098. */
  52099. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52100. private static RGBE_ReadPixels_RLE;
  52101. }
  52102. }
  52103. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52104. import { Nullable } from "babylonjs/types";
  52105. import { Scene } from "babylonjs/scene";
  52106. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52107. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52108. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52109. /**
  52110. * This represents a texture coming from an HDR input.
  52111. *
  52112. * The only supported format is currently panorama picture stored in RGBE format.
  52113. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52114. */
  52115. export class HDRCubeTexture extends BaseTexture {
  52116. private static _facesMapping;
  52117. private _generateHarmonics;
  52118. private _noMipmap;
  52119. private _textureMatrix;
  52120. private _size;
  52121. private _onLoad;
  52122. private _onError;
  52123. /**
  52124. * The texture URL.
  52125. */
  52126. url: string;
  52127. /**
  52128. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52129. */
  52130. coordinatesMode: number;
  52131. protected _isBlocking: boolean;
  52132. /**
  52133. * Sets wether or not the texture is blocking during loading.
  52134. */
  52135. /**
  52136. * Gets wether or not the texture is blocking during loading.
  52137. */
  52138. isBlocking: boolean;
  52139. protected _rotationY: number;
  52140. /**
  52141. * Sets texture matrix rotation angle around Y axis in radians.
  52142. */
  52143. /**
  52144. * Gets texture matrix rotation angle around Y axis radians.
  52145. */
  52146. rotationY: number;
  52147. /**
  52148. * Gets or sets the center of the bounding box associated with the cube texture
  52149. * It must define where the camera used to render the texture was set
  52150. */
  52151. boundingBoxPosition: Vector3;
  52152. private _boundingBoxSize;
  52153. /**
  52154. * Gets or sets the size of the bounding box associated with the cube texture
  52155. * When defined, the cubemap will switch to local mode
  52156. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52157. * @example https://www.babylonjs-playground.com/#RNASML
  52158. */
  52159. boundingBoxSize: Vector3;
  52160. /**
  52161. * Instantiates an HDRTexture from the following parameters.
  52162. *
  52163. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52164. * @param scene The scene the texture will be used in
  52165. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52166. * @param noMipmap Forces to not generate the mipmap if true
  52167. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52168. * @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)
  52169. * @param reserved Reserved flag for internal use.
  52170. */
  52171. 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>);
  52172. /**
  52173. * Get the current class name of the texture useful for serialization or dynamic coding.
  52174. * @returns "HDRCubeTexture"
  52175. */
  52176. getClassName(): string;
  52177. /**
  52178. * Occurs when the file is raw .hdr file.
  52179. */
  52180. private loadTexture;
  52181. clone(): HDRCubeTexture;
  52182. delayLoad(): void;
  52183. /**
  52184. * Get the texture reflection matrix used to rotate/transform the reflection.
  52185. * @returns the reflection matrix
  52186. */
  52187. getReflectionTextureMatrix(): Matrix;
  52188. /**
  52189. * Set the texture reflection matrix used to rotate/transform the reflection.
  52190. * @param value Define the reflection matrix to set
  52191. */
  52192. setReflectionTextureMatrix(value: Matrix): void;
  52193. /**
  52194. * Parses a JSON representation of an HDR Texture in order to create the texture
  52195. * @param parsedTexture Define the JSON representation
  52196. * @param scene Define the scene the texture should be created in
  52197. * @param rootUrl Define the root url in case we need to load relative dependencies
  52198. * @returns the newly created texture after parsing
  52199. */
  52200. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52201. serialize(): any;
  52202. }
  52203. }
  52204. declare module "babylonjs/Physics/physicsEngine" {
  52205. import { Nullable } from "babylonjs/types";
  52206. import { Vector3 } from "babylonjs/Maths/math.vector";
  52207. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52208. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52209. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52210. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52211. /**
  52212. * Class used to control physics engine
  52213. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52214. */
  52215. export class PhysicsEngine implements IPhysicsEngine {
  52216. private _physicsPlugin;
  52217. /**
  52218. * Global value used to control the smallest number supported by the simulation
  52219. */
  52220. static Epsilon: number;
  52221. private _impostors;
  52222. private _joints;
  52223. /**
  52224. * Gets the gravity vector used by the simulation
  52225. */
  52226. gravity: Vector3;
  52227. /**
  52228. * Factory used to create the default physics plugin.
  52229. * @returns The default physics plugin
  52230. */
  52231. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52232. /**
  52233. * Creates a new Physics Engine
  52234. * @param gravity defines the gravity vector used by the simulation
  52235. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52236. */
  52237. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52238. /**
  52239. * Sets the gravity vector used by the simulation
  52240. * @param gravity defines the gravity vector to use
  52241. */
  52242. setGravity(gravity: Vector3): void;
  52243. /**
  52244. * Set the time step of the physics engine.
  52245. * Default is 1/60.
  52246. * To slow it down, enter 1/600 for example.
  52247. * To speed it up, 1/30
  52248. * @param newTimeStep defines the new timestep to apply to this world.
  52249. */
  52250. setTimeStep(newTimeStep?: number): void;
  52251. /**
  52252. * Get the time step of the physics engine.
  52253. * @returns the current time step
  52254. */
  52255. getTimeStep(): number;
  52256. /**
  52257. * Release all resources
  52258. */
  52259. dispose(): void;
  52260. /**
  52261. * Gets the name of the current physics plugin
  52262. * @returns the name of the plugin
  52263. */
  52264. getPhysicsPluginName(): string;
  52265. /**
  52266. * Adding a new impostor for the impostor tracking.
  52267. * This will be done by the impostor itself.
  52268. * @param impostor the impostor to add
  52269. */
  52270. addImpostor(impostor: PhysicsImpostor): void;
  52271. /**
  52272. * Remove an impostor from the engine.
  52273. * This impostor and its mesh will not longer be updated by the physics engine.
  52274. * @param impostor the impostor to remove
  52275. */
  52276. removeImpostor(impostor: PhysicsImpostor): void;
  52277. /**
  52278. * Add a joint to the physics engine
  52279. * @param mainImpostor defines the main impostor to which the joint is added.
  52280. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52281. * @param joint defines the joint that will connect both impostors.
  52282. */
  52283. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52284. /**
  52285. * Removes a joint from the simulation
  52286. * @param mainImpostor defines the impostor used with the joint
  52287. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52288. * @param joint defines the joint to remove
  52289. */
  52290. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52291. /**
  52292. * Called by the scene. No need to call it.
  52293. * @param delta defines the timespam between frames
  52294. */
  52295. _step(delta: number): void;
  52296. /**
  52297. * Gets the current plugin used to run the simulation
  52298. * @returns current plugin
  52299. */
  52300. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52301. /**
  52302. * Gets the list of physic impostors
  52303. * @returns an array of PhysicsImpostor
  52304. */
  52305. getImpostors(): Array<PhysicsImpostor>;
  52306. /**
  52307. * Gets the impostor for a physics enabled object
  52308. * @param object defines the object impersonated by the impostor
  52309. * @returns the PhysicsImpostor or null if not found
  52310. */
  52311. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52312. /**
  52313. * Gets the impostor for a physics body object
  52314. * @param body defines physics body used by the impostor
  52315. * @returns the PhysicsImpostor or null if not found
  52316. */
  52317. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52318. /**
  52319. * Does a raycast in the physics world
  52320. * @param from when should the ray start?
  52321. * @param to when should the ray end?
  52322. * @returns PhysicsRaycastResult
  52323. */
  52324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52325. }
  52326. }
  52327. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52328. import { Nullable } from "babylonjs/types";
  52329. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52331. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52332. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52333. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52334. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52335. /** @hidden */
  52336. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52337. private _useDeltaForWorldStep;
  52338. world: any;
  52339. name: string;
  52340. private _physicsMaterials;
  52341. private _fixedTimeStep;
  52342. private _cannonRaycastResult;
  52343. private _raycastResult;
  52344. private _physicsBodysToRemoveAfterStep;
  52345. BJSCANNON: any;
  52346. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52347. setGravity(gravity: Vector3): void;
  52348. setTimeStep(timeStep: number): void;
  52349. getTimeStep(): number;
  52350. executeStep(delta: number): void;
  52351. private _removeMarkedPhysicsBodiesFromWorld;
  52352. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52353. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52354. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52355. private _processChildMeshes;
  52356. removePhysicsBody(impostor: PhysicsImpostor): void;
  52357. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52358. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52359. private _addMaterial;
  52360. private _checkWithEpsilon;
  52361. private _createShape;
  52362. private _createHeightmap;
  52363. private _minus90X;
  52364. private _plus90X;
  52365. private _tmpPosition;
  52366. private _tmpDeltaPosition;
  52367. private _tmpUnityRotation;
  52368. private _updatePhysicsBodyTransformation;
  52369. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52370. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52371. isSupported(): boolean;
  52372. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52373. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52374. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52375. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52376. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52377. getBodyMass(impostor: PhysicsImpostor): number;
  52378. getBodyFriction(impostor: PhysicsImpostor): number;
  52379. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52380. getBodyRestitution(impostor: PhysicsImpostor): number;
  52381. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52382. sleepBody(impostor: PhysicsImpostor): void;
  52383. wakeUpBody(impostor: PhysicsImpostor): void;
  52384. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52385. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52386. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52387. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52388. getRadius(impostor: PhysicsImpostor): number;
  52389. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52390. dispose(): void;
  52391. private _extendNamespace;
  52392. /**
  52393. * Does a raycast in the physics world
  52394. * @param from when should the ray start?
  52395. * @param to when should the ray end?
  52396. * @returns PhysicsRaycastResult
  52397. */
  52398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52399. }
  52400. }
  52401. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52402. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52403. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52404. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52406. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52407. import { Nullable } from "babylonjs/types";
  52408. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52409. /** @hidden */
  52410. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52411. world: any;
  52412. name: string;
  52413. BJSOIMO: any;
  52414. private _raycastResult;
  52415. constructor(iterations?: number, oimoInjection?: any);
  52416. setGravity(gravity: Vector3): void;
  52417. setTimeStep(timeStep: number): void;
  52418. getTimeStep(): number;
  52419. private _tmpImpostorsArray;
  52420. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52422. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52423. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52424. private _tmpPositionVector;
  52425. removePhysicsBody(impostor: PhysicsImpostor): void;
  52426. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52427. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52428. isSupported(): boolean;
  52429. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52430. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52431. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52432. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52433. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52434. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52435. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52436. getBodyMass(impostor: PhysicsImpostor): number;
  52437. getBodyFriction(impostor: PhysicsImpostor): number;
  52438. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52439. getBodyRestitution(impostor: PhysicsImpostor): number;
  52440. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52441. sleepBody(impostor: PhysicsImpostor): void;
  52442. wakeUpBody(impostor: PhysicsImpostor): void;
  52443. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52444. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52445. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52447. getRadius(impostor: PhysicsImpostor): number;
  52448. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52449. dispose(): void;
  52450. /**
  52451. * Does a raycast in the physics world
  52452. * @param from when should the ray start?
  52453. * @param to when should the ray end?
  52454. * @returns PhysicsRaycastResult
  52455. */
  52456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52457. }
  52458. }
  52459. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52460. import { Nullable } from "babylonjs/types";
  52461. import { Scene } from "babylonjs/scene";
  52462. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52463. import { Color4 } from "babylonjs/Maths/math.color";
  52464. import { Mesh } from "babylonjs/Meshes/mesh";
  52465. /**
  52466. * Class containing static functions to help procedurally build meshes
  52467. */
  52468. export class RibbonBuilder {
  52469. /**
  52470. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52471. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52472. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52473. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52474. * * 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
  52475. * * 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
  52476. * * 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
  52477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52480. * * 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
  52481. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52482. * * 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
  52483. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52485. * @param name defines the name of the mesh
  52486. * @param options defines the options used to create the mesh
  52487. * @param scene defines the hosting scene
  52488. * @returns the ribbon mesh
  52489. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52491. */
  52492. static CreateRibbon(name: string, options: {
  52493. pathArray: Vector3[][];
  52494. closeArray?: boolean;
  52495. closePath?: boolean;
  52496. offset?: number;
  52497. updatable?: boolean;
  52498. sideOrientation?: number;
  52499. frontUVs?: Vector4;
  52500. backUVs?: Vector4;
  52501. instance?: Mesh;
  52502. invertUV?: boolean;
  52503. uvs?: Vector2[];
  52504. colors?: Color4[];
  52505. }, scene?: Nullable<Scene>): Mesh;
  52506. }
  52507. }
  52508. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52509. import { Nullable } from "babylonjs/types";
  52510. import { Scene } from "babylonjs/scene";
  52511. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52512. import { Mesh } from "babylonjs/Meshes/mesh";
  52513. /**
  52514. * Class containing static functions to help procedurally build meshes
  52515. */
  52516. export class ShapeBuilder {
  52517. /**
  52518. * 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.
  52519. * * 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.
  52520. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52521. * * 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.
  52522. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52523. * * 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
  52524. * * 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
  52525. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52530. * @param name defines the name of the mesh
  52531. * @param options defines the options used to create the mesh
  52532. * @param scene defines the hosting scene
  52533. * @returns the extruded shape mesh
  52534. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52536. */
  52537. static ExtrudeShape(name: string, options: {
  52538. shape: Vector3[];
  52539. path: Vector3[];
  52540. scale?: number;
  52541. rotation?: number;
  52542. cap?: number;
  52543. updatable?: boolean;
  52544. sideOrientation?: number;
  52545. frontUVs?: Vector4;
  52546. backUVs?: Vector4;
  52547. instance?: Mesh;
  52548. invertUV?: boolean;
  52549. }, scene?: Nullable<Scene>): Mesh;
  52550. /**
  52551. * Creates an custom extruded shape mesh.
  52552. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52553. * * 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.
  52554. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52555. * * 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
  52556. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52557. * * 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
  52558. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52559. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52560. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52561. * * 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
  52562. * * 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
  52563. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52568. * @param name defines the name of the mesh
  52569. * @param options defines the options used to create the mesh
  52570. * @param scene defines the hosting scene
  52571. * @returns the custom extruded shape mesh
  52572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52573. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52575. */
  52576. static ExtrudeShapeCustom(name: string, options: {
  52577. shape: Vector3[];
  52578. path: Vector3[];
  52579. scaleFunction?: any;
  52580. rotationFunction?: any;
  52581. ribbonCloseArray?: boolean;
  52582. ribbonClosePath?: boolean;
  52583. cap?: number;
  52584. updatable?: boolean;
  52585. sideOrientation?: number;
  52586. frontUVs?: Vector4;
  52587. backUVs?: Vector4;
  52588. instance?: Mesh;
  52589. invertUV?: boolean;
  52590. }, scene?: Nullable<Scene>): Mesh;
  52591. private static _ExtrudeShapeGeneric;
  52592. }
  52593. }
  52594. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52595. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52596. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52597. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52598. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52599. import { Nullable } from "babylonjs/types";
  52600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52601. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52602. /**
  52603. * AmmoJS Physics plugin
  52604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52605. * @see https://github.com/kripken/ammo.js/
  52606. */
  52607. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52608. private _useDeltaForWorldStep;
  52609. /**
  52610. * Reference to the Ammo library
  52611. */
  52612. bjsAMMO: any;
  52613. /**
  52614. * Created ammoJS world which physics bodies are added to
  52615. */
  52616. world: any;
  52617. /**
  52618. * Name of the plugin
  52619. */
  52620. name: string;
  52621. private _timeStep;
  52622. private _fixedTimeStep;
  52623. private _maxSteps;
  52624. private _tmpQuaternion;
  52625. private _tmpAmmoTransform;
  52626. private _tmpAmmoQuaternion;
  52627. private _tmpAmmoConcreteContactResultCallback;
  52628. private _collisionConfiguration;
  52629. private _dispatcher;
  52630. private _overlappingPairCache;
  52631. private _solver;
  52632. private _softBodySolver;
  52633. private _tmpAmmoVectorA;
  52634. private _tmpAmmoVectorB;
  52635. private _tmpAmmoVectorC;
  52636. private _tmpAmmoVectorD;
  52637. private _tmpContactCallbackResult;
  52638. private _tmpAmmoVectorRCA;
  52639. private _tmpAmmoVectorRCB;
  52640. private _raycastResult;
  52641. private static readonly DISABLE_COLLISION_FLAG;
  52642. private static readonly KINEMATIC_FLAG;
  52643. private static readonly DISABLE_DEACTIVATION_FLAG;
  52644. /**
  52645. * Initializes the ammoJS plugin
  52646. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52647. * @param ammoInjection can be used to inject your own ammo reference
  52648. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52649. */
  52650. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52651. /**
  52652. * Sets the gravity of the physics world (m/(s^2))
  52653. * @param gravity Gravity to set
  52654. */
  52655. setGravity(gravity: Vector3): void;
  52656. /**
  52657. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52658. * @param timeStep timestep to use in seconds
  52659. */
  52660. setTimeStep(timeStep: number): void;
  52661. /**
  52662. * 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)
  52663. * @param fixedTimeStep fixedTimeStep to use in seconds
  52664. */
  52665. setFixedTimeStep(fixedTimeStep: number): void;
  52666. /**
  52667. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52668. * @param maxSteps the maximum number of steps by the physics engine per frame
  52669. */
  52670. setMaxSteps(maxSteps: number): void;
  52671. /**
  52672. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52673. * @returns the current timestep in seconds
  52674. */
  52675. getTimeStep(): number;
  52676. private _isImpostorInContact;
  52677. private _isImpostorPairInContact;
  52678. private _stepSimulation;
  52679. /**
  52680. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52681. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52682. * After the step the babylon meshes are set to the position of the physics imposters
  52683. * @param delta amount of time to step forward
  52684. * @param impostors array of imposters to update before/after the step
  52685. */
  52686. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52687. /**
  52688. * Update babylon mesh to match physics world object
  52689. * @param impostor imposter to match
  52690. */
  52691. private _afterSoftStep;
  52692. /**
  52693. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52694. * @param impostor imposter to match
  52695. */
  52696. private _ropeStep;
  52697. /**
  52698. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52699. * @param impostor imposter to match
  52700. */
  52701. private _softbodyOrClothStep;
  52702. private _tmpVector;
  52703. private _tmpMatrix;
  52704. /**
  52705. * Applies an impulse on the imposter
  52706. * @param impostor imposter to apply impulse to
  52707. * @param force amount of force to be applied to the imposter
  52708. * @param contactPoint the location to apply the impulse on the imposter
  52709. */
  52710. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52711. /**
  52712. * Applies a force on the imposter
  52713. * @param impostor imposter to apply force
  52714. * @param force amount of force to be applied to the imposter
  52715. * @param contactPoint the location to apply the force on the imposter
  52716. */
  52717. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52718. /**
  52719. * Creates a physics body using the plugin
  52720. * @param impostor the imposter to create the physics body on
  52721. */
  52722. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52723. /**
  52724. * Removes the physics body from the imposter and disposes of the body's memory
  52725. * @param impostor imposter to remove the physics body from
  52726. */
  52727. removePhysicsBody(impostor: PhysicsImpostor): void;
  52728. /**
  52729. * Generates a joint
  52730. * @param impostorJoint the imposter joint to create the joint with
  52731. */
  52732. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52733. /**
  52734. * Removes a joint
  52735. * @param impostorJoint the imposter joint to remove the joint from
  52736. */
  52737. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52738. private _addMeshVerts;
  52739. /**
  52740. * Initialise the soft body vertices to match its object's (mesh) vertices
  52741. * Softbody vertices (nodes) are in world space and to match this
  52742. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52743. * @param impostor to create the softbody for
  52744. */
  52745. private _softVertexData;
  52746. /**
  52747. * Create an impostor's soft body
  52748. * @param impostor to create the softbody for
  52749. */
  52750. private _createSoftbody;
  52751. /**
  52752. * Create cloth for an impostor
  52753. * @param impostor to create the softbody for
  52754. */
  52755. private _createCloth;
  52756. /**
  52757. * Create rope for an impostor
  52758. * @param impostor to create the softbody for
  52759. */
  52760. private _createRope;
  52761. private _addHullVerts;
  52762. private _createShape;
  52763. /**
  52764. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52765. * @param impostor imposter containing the physics body and babylon object
  52766. */
  52767. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52768. /**
  52769. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52770. * @param impostor imposter containing the physics body and babylon object
  52771. * @param newPosition new position
  52772. * @param newRotation new rotation
  52773. */
  52774. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52775. /**
  52776. * If this plugin is supported
  52777. * @returns true if its supported
  52778. */
  52779. isSupported(): boolean;
  52780. /**
  52781. * Sets the linear velocity of the physics body
  52782. * @param impostor imposter to set the velocity on
  52783. * @param velocity velocity to set
  52784. */
  52785. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52786. /**
  52787. * Sets the angular velocity of the physics body
  52788. * @param impostor imposter to set the velocity on
  52789. * @param velocity velocity to set
  52790. */
  52791. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52792. /**
  52793. * gets the linear velocity
  52794. * @param impostor imposter to get linear velocity from
  52795. * @returns linear velocity
  52796. */
  52797. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52798. /**
  52799. * gets the angular velocity
  52800. * @param impostor imposter to get angular velocity from
  52801. * @returns angular velocity
  52802. */
  52803. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52804. /**
  52805. * Sets the mass of physics body
  52806. * @param impostor imposter to set the mass on
  52807. * @param mass mass to set
  52808. */
  52809. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52810. /**
  52811. * Gets the mass of the physics body
  52812. * @param impostor imposter to get the mass from
  52813. * @returns mass
  52814. */
  52815. getBodyMass(impostor: PhysicsImpostor): number;
  52816. /**
  52817. * Gets friction of the impostor
  52818. * @param impostor impostor to get friction from
  52819. * @returns friction value
  52820. */
  52821. getBodyFriction(impostor: PhysicsImpostor): number;
  52822. /**
  52823. * Sets friction of the impostor
  52824. * @param impostor impostor to set friction on
  52825. * @param friction friction value
  52826. */
  52827. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52828. /**
  52829. * Gets restitution of the impostor
  52830. * @param impostor impostor to get restitution from
  52831. * @returns restitution value
  52832. */
  52833. getBodyRestitution(impostor: PhysicsImpostor): number;
  52834. /**
  52835. * Sets resitution of the impostor
  52836. * @param impostor impostor to set resitution on
  52837. * @param restitution resitution value
  52838. */
  52839. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52840. /**
  52841. * Gets pressure inside the impostor
  52842. * @param impostor impostor to get pressure from
  52843. * @returns pressure value
  52844. */
  52845. getBodyPressure(impostor: PhysicsImpostor): number;
  52846. /**
  52847. * Sets pressure inside a soft body impostor
  52848. * Cloth and rope must remain 0 pressure
  52849. * @param impostor impostor to set pressure on
  52850. * @param pressure pressure value
  52851. */
  52852. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52853. /**
  52854. * Gets stiffness of the impostor
  52855. * @param impostor impostor to get stiffness from
  52856. * @returns pressure value
  52857. */
  52858. getBodyStiffness(impostor: PhysicsImpostor): number;
  52859. /**
  52860. * Sets stiffness of the impostor
  52861. * @param impostor impostor to set stiffness on
  52862. * @param stiffness stiffness value from 0 to 1
  52863. */
  52864. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52865. /**
  52866. * Gets velocityIterations of the impostor
  52867. * @param impostor impostor to get velocity iterations from
  52868. * @returns velocityIterations value
  52869. */
  52870. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52871. /**
  52872. * Sets velocityIterations of the impostor
  52873. * @param impostor impostor to set velocity iterations on
  52874. * @param velocityIterations velocityIterations value
  52875. */
  52876. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52877. /**
  52878. * Gets positionIterations of the impostor
  52879. * @param impostor impostor to get position iterations from
  52880. * @returns positionIterations value
  52881. */
  52882. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52883. /**
  52884. * Sets positionIterations of the impostor
  52885. * @param impostor impostor to set position on
  52886. * @param positionIterations positionIterations value
  52887. */
  52888. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52889. /**
  52890. * Append an anchor to a cloth object
  52891. * @param impostor is the cloth impostor to add anchor to
  52892. * @param otherImpostor is the rigid impostor to anchor to
  52893. * @param width ratio across width from 0 to 1
  52894. * @param height ratio up height from 0 to 1
  52895. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52896. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52897. */
  52898. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52899. /**
  52900. * Append an hook to a rope object
  52901. * @param impostor is the rope impostor to add hook to
  52902. * @param otherImpostor is the rigid impostor to hook to
  52903. * @param length ratio along the rope from 0 to 1
  52904. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52905. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52906. */
  52907. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52908. /**
  52909. * Sleeps the physics body and stops it from being active
  52910. * @param impostor impostor to sleep
  52911. */
  52912. sleepBody(impostor: PhysicsImpostor): void;
  52913. /**
  52914. * Activates the physics body
  52915. * @param impostor impostor to activate
  52916. */
  52917. wakeUpBody(impostor: PhysicsImpostor): void;
  52918. /**
  52919. * Updates the distance parameters of the joint
  52920. * @param joint joint to update
  52921. * @param maxDistance maximum distance of the joint
  52922. * @param minDistance minimum distance of the joint
  52923. */
  52924. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52925. /**
  52926. * Sets a motor on the joint
  52927. * @param joint joint to set motor on
  52928. * @param speed speed of the motor
  52929. * @param maxForce maximum force of the motor
  52930. * @param motorIndex index of the motor
  52931. */
  52932. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52933. /**
  52934. * Sets the motors limit
  52935. * @param joint joint to set limit on
  52936. * @param upperLimit upper limit
  52937. * @param lowerLimit lower limit
  52938. */
  52939. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52940. /**
  52941. * Syncs the position and rotation of a mesh with the impostor
  52942. * @param mesh mesh to sync
  52943. * @param impostor impostor to update the mesh with
  52944. */
  52945. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52946. /**
  52947. * Gets the radius of the impostor
  52948. * @param impostor impostor to get radius from
  52949. * @returns the radius
  52950. */
  52951. getRadius(impostor: PhysicsImpostor): number;
  52952. /**
  52953. * Gets the box size of the impostor
  52954. * @param impostor impostor to get box size from
  52955. * @param result the resulting box size
  52956. */
  52957. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52958. /**
  52959. * Disposes of the impostor
  52960. */
  52961. dispose(): void;
  52962. /**
  52963. * Does a raycast in the physics world
  52964. * @param from when should the ray start?
  52965. * @param to when should the ray end?
  52966. * @returns PhysicsRaycastResult
  52967. */
  52968. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52969. }
  52970. }
  52971. declare module "babylonjs/Probes/reflectionProbe" {
  52972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52973. import { Vector3 } from "babylonjs/Maths/math.vector";
  52974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52975. import { Nullable } from "babylonjs/types";
  52976. import { Scene } from "babylonjs/scene";
  52977. module "babylonjs/abstractScene" {
  52978. interface AbstractScene {
  52979. /**
  52980. * The list of reflection probes added to the scene
  52981. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52982. */
  52983. reflectionProbes: Array<ReflectionProbe>;
  52984. /**
  52985. * Removes the given reflection probe from this scene.
  52986. * @param toRemove The reflection probe to remove
  52987. * @returns The index of the removed reflection probe
  52988. */
  52989. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52990. /**
  52991. * Adds the given reflection probe to this scene.
  52992. * @param newReflectionProbe The reflection probe to add
  52993. */
  52994. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52995. }
  52996. }
  52997. /**
  52998. * Class used to generate realtime reflection / refraction cube textures
  52999. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53000. */
  53001. export class ReflectionProbe {
  53002. /** defines the name of the probe */
  53003. name: string;
  53004. private _scene;
  53005. private _renderTargetTexture;
  53006. private _projectionMatrix;
  53007. private _viewMatrix;
  53008. private _target;
  53009. private _add;
  53010. private _attachedMesh;
  53011. private _invertYAxis;
  53012. /** Gets or sets probe position (center of the cube map) */
  53013. position: Vector3;
  53014. /**
  53015. * Creates a new reflection probe
  53016. * @param name defines the name of the probe
  53017. * @param size defines the texture resolution (for each face)
  53018. * @param scene defines the hosting scene
  53019. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53020. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53021. */
  53022. constructor(
  53023. /** defines the name of the probe */
  53024. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53025. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53026. samples: number;
  53027. /** Gets or sets the refresh rate to use (on every frame by default) */
  53028. refreshRate: number;
  53029. /**
  53030. * Gets the hosting scene
  53031. * @returns a Scene
  53032. */
  53033. getScene(): Scene;
  53034. /** Gets the internal CubeTexture used to render to */
  53035. readonly cubeTexture: RenderTargetTexture;
  53036. /** Gets the list of meshes to render */
  53037. readonly renderList: Nullable<AbstractMesh[]>;
  53038. /**
  53039. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53040. * @param mesh defines the mesh to attach to
  53041. */
  53042. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53043. /**
  53044. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53045. * @param renderingGroupId The rendering group id corresponding to its index
  53046. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53047. */
  53048. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53049. /**
  53050. * Clean all associated resources
  53051. */
  53052. dispose(): void;
  53053. /**
  53054. * Converts the reflection probe information to a readable string for debug purpose.
  53055. * @param fullDetails Supports for multiple levels of logging within scene loading
  53056. * @returns the human readable reflection probe info
  53057. */
  53058. toString(fullDetails?: boolean): string;
  53059. /**
  53060. * Get the class name of the relfection probe.
  53061. * @returns "ReflectionProbe"
  53062. */
  53063. getClassName(): string;
  53064. /**
  53065. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53066. * @returns The JSON representation of the texture
  53067. */
  53068. serialize(): any;
  53069. /**
  53070. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53071. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53072. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53073. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53074. * @returns The parsed reflection probe if successful
  53075. */
  53076. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53077. }
  53078. }
  53079. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53080. /** @hidden */
  53081. export var _BabylonLoaderRegistered: boolean;
  53082. }
  53083. declare module "babylonjs/Loading/Plugins/index" {
  53084. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53085. }
  53086. declare module "babylonjs/Loading/index" {
  53087. export * from "babylonjs/Loading/loadingScreen";
  53088. export * from "babylonjs/Loading/Plugins/index";
  53089. export * from "babylonjs/Loading/sceneLoader";
  53090. export * from "babylonjs/Loading/sceneLoaderFlags";
  53091. }
  53092. declare module "babylonjs/Materials/Background/index" {
  53093. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53094. }
  53095. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53096. import { Scene } from "babylonjs/scene";
  53097. import { Color3 } from "babylonjs/Maths/math.color";
  53098. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53100. /**
  53101. * The Physically based simple base material of BJS.
  53102. *
  53103. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53104. * It is used as the base class for both the specGloss and metalRough conventions.
  53105. */
  53106. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53107. /**
  53108. * Number of Simultaneous lights allowed on the material.
  53109. */
  53110. maxSimultaneousLights: number;
  53111. /**
  53112. * If sets to true, disables all the lights affecting the material.
  53113. */
  53114. disableLighting: boolean;
  53115. /**
  53116. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53117. */
  53118. environmentTexture: BaseTexture;
  53119. /**
  53120. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53121. */
  53122. invertNormalMapX: boolean;
  53123. /**
  53124. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53125. */
  53126. invertNormalMapY: boolean;
  53127. /**
  53128. * Normal map used in the model.
  53129. */
  53130. normalTexture: BaseTexture;
  53131. /**
  53132. * Emissivie color used to self-illuminate the model.
  53133. */
  53134. emissiveColor: Color3;
  53135. /**
  53136. * Emissivie texture used to self-illuminate the model.
  53137. */
  53138. emissiveTexture: BaseTexture;
  53139. /**
  53140. * Occlusion Channel Strenght.
  53141. */
  53142. occlusionStrength: number;
  53143. /**
  53144. * Occlusion Texture of the material (adding extra occlusion effects).
  53145. */
  53146. occlusionTexture: BaseTexture;
  53147. /**
  53148. * Defines the alpha limits in alpha test mode.
  53149. */
  53150. alphaCutOff: number;
  53151. /**
  53152. * Gets the current double sided mode.
  53153. */
  53154. /**
  53155. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53156. */
  53157. doubleSided: boolean;
  53158. /**
  53159. * Stores the pre-calculated light information of a mesh in a texture.
  53160. */
  53161. lightmapTexture: BaseTexture;
  53162. /**
  53163. * If true, the light map contains occlusion information instead of lighting info.
  53164. */
  53165. useLightmapAsShadowmap: boolean;
  53166. /**
  53167. * Instantiates a new PBRMaterial instance.
  53168. *
  53169. * @param name The material name
  53170. * @param scene The scene the material will be use in.
  53171. */
  53172. constructor(name: string, scene: Scene);
  53173. getClassName(): string;
  53174. }
  53175. }
  53176. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53177. import { Scene } from "babylonjs/scene";
  53178. import { Color3 } from "babylonjs/Maths/math.color";
  53179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53180. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53181. /**
  53182. * The PBR material of BJS following the metal roughness convention.
  53183. *
  53184. * This fits to the PBR convention in the GLTF definition:
  53185. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53186. */
  53187. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53188. /**
  53189. * The base color has two different interpretations depending on the value of metalness.
  53190. * When the material is a metal, the base color is the specific measured reflectance value
  53191. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53192. * of the material.
  53193. */
  53194. baseColor: Color3;
  53195. /**
  53196. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53197. * well as opacity information in the alpha channel.
  53198. */
  53199. baseTexture: BaseTexture;
  53200. /**
  53201. * Specifies the metallic scalar value of the material.
  53202. * Can also be used to scale the metalness values of the metallic texture.
  53203. */
  53204. metallic: number;
  53205. /**
  53206. * Specifies the roughness scalar value of the material.
  53207. * Can also be used to scale the roughness values of the metallic texture.
  53208. */
  53209. roughness: number;
  53210. /**
  53211. * Texture containing both the metallic value in the B channel and the
  53212. * roughness value in the G channel to keep better precision.
  53213. */
  53214. metallicRoughnessTexture: BaseTexture;
  53215. /**
  53216. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53217. *
  53218. * @param name The material name
  53219. * @param scene The scene the material will be use in.
  53220. */
  53221. constructor(name: string, scene: Scene);
  53222. /**
  53223. * Return the currrent class name of the material.
  53224. */
  53225. getClassName(): string;
  53226. /**
  53227. * Makes a duplicate of the current material.
  53228. * @param name - name to use for the new material.
  53229. */
  53230. clone(name: string): PBRMetallicRoughnessMaterial;
  53231. /**
  53232. * Serialize the material to a parsable JSON object.
  53233. */
  53234. serialize(): any;
  53235. /**
  53236. * Parses a JSON object correponding to the serialize function.
  53237. */
  53238. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53239. }
  53240. }
  53241. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53242. import { Scene } from "babylonjs/scene";
  53243. import { Color3 } from "babylonjs/Maths/math.color";
  53244. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53245. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53246. /**
  53247. * The PBR material of BJS following the specular glossiness convention.
  53248. *
  53249. * This fits to the PBR convention in the GLTF definition:
  53250. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53251. */
  53252. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53253. /**
  53254. * Specifies the diffuse color of the material.
  53255. */
  53256. diffuseColor: Color3;
  53257. /**
  53258. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53259. * channel.
  53260. */
  53261. diffuseTexture: BaseTexture;
  53262. /**
  53263. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53264. */
  53265. specularColor: Color3;
  53266. /**
  53267. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53268. */
  53269. glossiness: number;
  53270. /**
  53271. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53272. */
  53273. specularGlossinessTexture: BaseTexture;
  53274. /**
  53275. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53276. *
  53277. * @param name The material name
  53278. * @param scene The scene the material will be use in.
  53279. */
  53280. constructor(name: string, scene: Scene);
  53281. /**
  53282. * Return the currrent class name of the material.
  53283. */
  53284. getClassName(): string;
  53285. /**
  53286. * Makes a duplicate of the current material.
  53287. * @param name - name to use for the new material.
  53288. */
  53289. clone(name: string): PBRSpecularGlossinessMaterial;
  53290. /**
  53291. * Serialize the material to a parsable JSON object.
  53292. */
  53293. serialize(): any;
  53294. /**
  53295. * Parses a JSON object correponding to the serialize function.
  53296. */
  53297. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53298. }
  53299. }
  53300. declare module "babylonjs/Materials/PBR/index" {
  53301. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53302. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53303. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53304. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53305. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53306. }
  53307. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53308. import { Nullable } from "babylonjs/types";
  53309. import { Scene } from "babylonjs/scene";
  53310. import { Matrix } from "babylonjs/Maths/math.vector";
  53311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53312. /**
  53313. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53314. * It can help converting any input color in a desired output one. This can then be used to create effects
  53315. * from sepia, black and white to sixties or futuristic rendering...
  53316. *
  53317. * The only supported format is currently 3dl.
  53318. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53319. */
  53320. export class ColorGradingTexture extends BaseTexture {
  53321. /**
  53322. * The current texture matrix. (will always be identity in color grading texture)
  53323. */
  53324. private _textureMatrix;
  53325. /**
  53326. * The texture URL.
  53327. */
  53328. url: string;
  53329. /**
  53330. * Empty line regex stored for GC.
  53331. */
  53332. private static _noneEmptyLineRegex;
  53333. private _engine;
  53334. /**
  53335. * Instantiates a ColorGradingTexture from the following parameters.
  53336. *
  53337. * @param url The location of the color gradind data (currently only supporting 3dl)
  53338. * @param scene The scene the texture will be used in
  53339. */
  53340. constructor(url: string, scene: Scene);
  53341. /**
  53342. * Returns the texture matrix used in most of the material.
  53343. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53344. */
  53345. getTextureMatrix(): Matrix;
  53346. /**
  53347. * Occurs when the file being loaded is a .3dl LUT file.
  53348. */
  53349. private load3dlTexture;
  53350. /**
  53351. * Starts the loading process of the texture.
  53352. */
  53353. private loadTexture;
  53354. /**
  53355. * Clones the color gradind texture.
  53356. */
  53357. clone(): ColorGradingTexture;
  53358. /**
  53359. * Called during delayed load for textures.
  53360. */
  53361. delayLoad(): void;
  53362. /**
  53363. * Parses a color grading texture serialized by Babylon.
  53364. * @param parsedTexture The texture information being parsedTexture
  53365. * @param scene The scene to load the texture in
  53366. * @param rootUrl The root url of the data assets to load
  53367. * @return A color gradind texture
  53368. */
  53369. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53370. /**
  53371. * Serializes the LUT texture to json format.
  53372. */
  53373. serialize(): any;
  53374. }
  53375. }
  53376. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53378. import { Scene } from "babylonjs/scene";
  53379. import { Nullable } from "babylonjs/types";
  53380. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53381. /**
  53382. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53383. */
  53384. export class EquiRectangularCubeTexture extends BaseTexture {
  53385. /** The six faces of the cube. */
  53386. private static _FacesMapping;
  53387. private _noMipmap;
  53388. private _onLoad;
  53389. private _onError;
  53390. /** The size of the cubemap. */
  53391. private _size;
  53392. /** The buffer of the image. */
  53393. private _buffer;
  53394. /** The width of the input image. */
  53395. private _width;
  53396. /** The height of the input image. */
  53397. private _height;
  53398. /** The URL to the image. */
  53399. url: string;
  53400. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53401. coordinatesMode: number;
  53402. /**
  53403. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53404. * @param url The location of the image
  53405. * @param scene The scene the texture will be used in
  53406. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53407. * @param noMipmap Forces to not generate the mipmap if true
  53408. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53409. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53410. * @param onLoad — defines a callback called when texture is loaded
  53411. * @param onError — defines a callback called if there is an error
  53412. */
  53413. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53414. /**
  53415. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53416. */
  53417. private loadImage;
  53418. /**
  53419. * Convert the image buffer into a cubemap and create a CubeTexture.
  53420. */
  53421. private loadTexture;
  53422. /**
  53423. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53424. * @param buffer The ArrayBuffer that should be converted.
  53425. * @returns The buffer as Float32Array.
  53426. */
  53427. private getFloat32ArrayFromArrayBuffer;
  53428. /**
  53429. * Get the current class name of the texture useful for serialization or dynamic coding.
  53430. * @returns "EquiRectangularCubeTexture"
  53431. */
  53432. getClassName(): string;
  53433. /**
  53434. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53435. * @returns A clone of the current EquiRectangularCubeTexture.
  53436. */
  53437. clone(): EquiRectangularCubeTexture;
  53438. }
  53439. }
  53440. declare module "babylonjs/Misc/tga" {
  53441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53442. /**
  53443. * Based on jsTGALoader - Javascript loader for TGA file
  53444. * By Vincent Thibault
  53445. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53446. */
  53447. export class TGATools {
  53448. private static _TYPE_INDEXED;
  53449. private static _TYPE_RGB;
  53450. private static _TYPE_GREY;
  53451. private static _TYPE_RLE_INDEXED;
  53452. private static _TYPE_RLE_RGB;
  53453. private static _TYPE_RLE_GREY;
  53454. private static _ORIGIN_MASK;
  53455. private static _ORIGIN_SHIFT;
  53456. private static _ORIGIN_BL;
  53457. private static _ORIGIN_BR;
  53458. private static _ORIGIN_UL;
  53459. private static _ORIGIN_UR;
  53460. /**
  53461. * Gets the header of a TGA file
  53462. * @param data defines the TGA data
  53463. * @returns the header
  53464. */
  53465. static GetTGAHeader(data: Uint8Array): any;
  53466. /**
  53467. * Uploads TGA content to a Babylon Texture
  53468. * @hidden
  53469. */
  53470. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53471. /** @hidden */
  53472. 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;
  53473. /** @hidden */
  53474. 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;
  53475. /** @hidden */
  53476. 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;
  53477. /** @hidden */
  53478. 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;
  53479. /** @hidden */
  53480. 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;
  53481. /** @hidden */
  53482. 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;
  53483. }
  53484. }
  53485. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53486. import { Nullable } from "babylonjs/types";
  53487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53488. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53489. /**
  53490. * Implementation of the TGA Texture Loader.
  53491. * @hidden
  53492. */
  53493. export class _TGATextureLoader implements IInternalTextureLoader {
  53494. /**
  53495. * Defines wether the loader supports cascade loading the different faces.
  53496. */
  53497. readonly supportCascades: boolean;
  53498. /**
  53499. * This returns if the loader support the current file information.
  53500. * @param extension defines the file extension of the file being loaded
  53501. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53502. * @param fallback defines the fallback internal texture if any
  53503. * @param isBase64 defines whether the texture is encoded as a base64
  53504. * @param isBuffer defines whether the texture data are stored as a buffer
  53505. * @returns true if the loader can load the specified file
  53506. */
  53507. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53508. /**
  53509. * Transform the url before loading if required.
  53510. * @param rootUrl the url of the texture
  53511. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53512. * @returns the transformed texture
  53513. */
  53514. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53515. /**
  53516. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53517. * @param rootUrl the url of the texture
  53518. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53519. * @returns the fallback texture
  53520. */
  53521. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53522. /**
  53523. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53524. * @param data contains the texture data
  53525. * @param texture defines the BabylonJS internal texture
  53526. * @param createPolynomials will be true if polynomials have been requested
  53527. * @param onLoad defines the callback to trigger once the texture is ready
  53528. * @param onError defines the callback to trigger in case of error
  53529. */
  53530. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53531. /**
  53532. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53533. * @param data contains the texture data
  53534. * @param texture defines the BabylonJS internal texture
  53535. * @param callback defines the method to call once ready to upload
  53536. */
  53537. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53538. }
  53539. }
  53540. declare module "babylonjs/Misc/basis" {
  53541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53542. /**
  53543. * Info about the .basis files
  53544. */
  53545. class BasisFileInfo {
  53546. /**
  53547. * If the file has alpha
  53548. */
  53549. hasAlpha: boolean;
  53550. /**
  53551. * Info about each image of the basis file
  53552. */
  53553. images: Array<{
  53554. levels: Array<{
  53555. width: number;
  53556. height: number;
  53557. transcodedPixels: ArrayBufferView;
  53558. }>;
  53559. }>;
  53560. }
  53561. /**
  53562. * Result of transcoding a basis file
  53563. */
  53564. class TranscodeResult {
  53565. /**
  53566. * Info about the .basis file
  53567. */
  53568. fileInfo: BasisFileInfo;
  53569. /**
  53570. * Format to use when loading the file
  53571. */
  53572. format: number;
  53573. }
  53574. /**
  53575. * Configuration options for the Basis transcoder
  53576. */
  53577. export class BasisTranscodeConfiguration {
  53578. /**
  53579. * Supported compression formats used to determine the supported output format of the transcoder
  53580. */
  53581. supportedCompressionFormats?: {
  53582. /**
  53583. * etc1 compression format
  53584. */
  53585. etc1?: boolean;
  53586. /**
  53587. * s3tc compression format
  53588. */
  53589. s3tc?: boolean;
  53590. /**
  53591. * pvrtc compression format
  53592. */
  53593. pvrtc?: boolean;
  53594. /**
  53595. * etc2 compression format
  53596. */
  53597. etc2?: boolean;
  53598. };
  53599. /**
  53600. * If mipmap levels should be loaded for transcoded images (Default: true)
  53601. */
  53602. loadMipmapLevels?: boolean;
  53603. /**
  53604. * Index of a single image to load (Default: all images)
  53605. */
  53606. loadSingleImage?: number;
  53607. }
  53608. /**
  53609. * Used to load .Basis files
  53610. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53611. */
  53612. export class BasisTools {
  53613. private static _IgnoreSupportedFormats;
  53614. /**
  53615. * URL to use when loading the basis transcoder
  53616. */
  53617. static JSModuleURL: string;
  53618. /**
  53619. * URL to use when loading the wasm module for the transcoder
  53620. */
  53621. static WasmModuleURL: string;
  53622. /**
  53623. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53624. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53625. * @returns internal format corresponding to the Basis format
  53626. */
  53627. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53628. private static _WorkerPromise;
  53629. private static _Worker;
  53630. private static _actionId;
  53631. private static _CreateWorkerAsync;
  53632. /**
  53633. * Transcodes a loaded image file to compressed pixel data
  53634. * @param imageData image data to transcode
  53635. * @param config configuration options for the transcoding
  53636. * @returns a promise resulting in the transcoded image
  53637. */
  53638. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53639. /**
  53640. * Loads a texture from the transcode result
  53641. * @param texture texture load to
  53642. * @param transcodeResult the result of transcoding the basis file to load from
  53643. */
  53644. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53645. }
  53646. }
  53647. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53648. import { Nullable } from "babylonjs/types";
  53649. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53650. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53651. /**
  53652. * Loader for .basis file format
  53653. */
  53654. export class _BasisTextureLoader implements IInternalTextureLoader {
  53655. /**
  53656. * Defines whether the loader supports cascade loading the different faces.
  53657. */
  53658. readonly supportCascades: boolean;
  53659. /**
  53660. * This returns if the loader support the current file information.
  53661. * @param extension defines the file extension of the file being loaded
  53662. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53663. * @param fallback defines the fallback internal texture if any
  53664. * @param isBase64 defines whether the texture is encoded as a base64
  53665. * @param isBuffer defines whether the texture data are stored as a buffer
  53666. * @returns true if the loader can load the specified file
  53667. */
  53668. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53669. /**
  53670. * Transform the url before loading if required.
  53671. * @param rootUrl the url of the texture
  53672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53673. * @returns the transformed texture
  53674. */
  53675. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53676. /**
  53677. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53678. * @param rootUrl the url of the texture
  53679. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53680. * @returns the fallback texture
  53681. */
  53682. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53683. /**
  53684. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53685. * @param data contains the texture data
  53686. * @param texture defines the BabylonJS internal texture
  53687. * @param createPolynomials will be true if polynomials have been requested
  53688. * @param onLoad defines the callback to trigger once the texture is ready
  53689. * @param onError defines the callback to trigger in case of error
  53690. */
  53691. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53692. /**
  53693. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53694. * @param data contains the texture data
  53695. * @param texture defines the BabylonJS internal texture
  53696. * @param callback defines the method to call once ready to upload
  53697. */
  53698. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53699. }
  53700. }
  53701. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53702. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53703. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53704. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53705. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53706. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53707. }
  53708. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53709. import { Scene } from "babylonjs/scene";
  53710. import { Texture } from "babylonjs/Materials/Textures/texture";
  53711. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53712. /**
  53713. * 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.
  53714. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53715. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53716. */
  53717. export class CustomProceduralTexture extends ProceduralTexture {
  53718. private _animate;
  53719. private _time;
  53720. private _config;
  53721. private _texturePath;
  53722. /**
  53723. * Instantiates a new Custom Procedural Texture.
  53724. * 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.
  53725. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53726. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53727. * @param name Define the name of the texture
  53728. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53729. * @param size Define the size of the texture to create
  53730. * @param scene Define the scene the texture belongs to
  53731. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53732. * @param generateMipMaps Define if the texture should creates mip maps or not
  53733. */
  53734. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53735. private _loadJson;
  53736. /**
  53737. * Is the texture ready to be used ? (rendered at least once)
  53738. * @returns true if ready, otherwise, false.
  53739. */
  53740. isReady(): boolean;
  53741. /**
  53742. * Render the texture to its associated render target.
  53743. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53744. */
  53745. render(useCameraPostProcess?: boolean): void;
  53746. /**
  53747. * Update the list of dependant textures samplers in the shader.
  53748. */
  53749. updateTextures(): void;
  53750. /**
  53751. * Update the uniform values of the procedural texture in the shader.
  53752. */
  53753. updateShaderUniforms(): void;
  53754. /**
  53755. * Define if the texture animates or not.
  53756. */
  53757. animate: boolean;
  53758. }
  53759. }
  53760. declare module "babylonjs/Shaders/noise.fragment" {
  53761. /** @hidden */
  53762. export var noisePixelShader: {
  53763. name: string;
  53764. shader: string;
  53765. };
  53766. }
  53767. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53768. import { Nullable } from "babylonjs/types";
  53769. import { Scene } from "babylonjs/scene";
  53770. import { Texture } from "babylonjs/Materials/Textures/texture";
  53771. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53772. import "babylonjs/Shaders/noise.fragment";
  53773. /**
  53774. * Class used to generate noise procedural textures
  53775. */
  53776. export class NoiseProceduralTexture extends ProceduralTexture {
  53777. private _time;
  53778. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53779. brightness: number;
  53780. /** Defines the number of octaves to process */
  53781. octaves: number;
  53782. /** Defines the level of persistence (0.8 by default) */
  53783. persistence: number;
  53784. /** Gets or sets animation speed factor (default is 1) */
  53785. animationSpeedFactor: number;
  53786. /**
  53787. * Creates a new NoiseProceduralTexture
  53788. * @param name defines the name fo the texture
  53789. * @param size defines the size of the texture (default is 256)
  53790. * @param scene defines the hosting scene
  53791. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53792. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53793. */
  53794. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53795. private _updateShaderUniforms;
  53796. protected _getDefines(): string;
  53797. /** Generate the current state of the procedural texture */
  53798. render(useCameraPostProcess?: boolean): void;
  53799. /**
  53800. * Serializes this noise procedural texture
  53801. * @returns a serialized noise procedural texture object
  53802. */
  53803. serialize(): any;
  53804. /**
  53805. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53806. * @param parsedTexture defines parsed texture data
  53807. * @param scene defines the current scene
  53808. * @param rootUrl defines the root URL containing noise procedural texture information
  53809. * @returns a parsed NoiseProceduralTexture
  53810. */
  53811. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53812. }
  53813. }
  53814. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53815. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53816. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53817. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53818. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53819. }
  53820. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53821. import { Nullable } from "babylonjs/types";
  53822. import { Scene } from "babylonjs/scene";
  53823. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53825. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53826. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53827. /**
  53828. * Raw cube texture where the raw buffers are passed in
  53829. */
  53830. export class RawCubeTexture extends CubeTexture {
  53831. /**
  53832. * Creates a cube texture where the raw buffers are passed in.
  53833. * @param scene defines the scene the texture is attached to
  53834. * @param data defines the array of data to use to create each face
  53835. * @param size defines the size of the textures
  53836. * @param format defines the format of the data
  53837. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53838. * @param generateMipMaps defines if the engine should generate the mip levels
  53839. * @param invertY defines if data must be stored with Y axis inverted
  53840. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53841. * @param compression defines the compression used (null by default)
  53842. */
  53843. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53844. /**
  53845. * Updates the raw cube texture.
  53846. * @param data defines the data to store
  53847. * @param format defines the data format
  53848. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53849. * @param invertY defines if data must be stored with Y axis inverted
  53850. * @param compression defines the compression used (null by default)
  53851. * @param level defines which level of the texture to update
  53852. */
  53853. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53854. /**
  53855. * Updates a raw cube texture with RGBD encoded data.
  53856. * @param data defines the array of data [mipmap][face] to use to create each face
  53857. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53858. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53859. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53860. * @returns a promsie that resolves when the operation is complete
  53861. */
  53862. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53863. /**
  53864. * Clones the raw cube texture.
  53865. * @return a new cube texture
  53866. */
  53867. clone(): CubeTexture;
  53868. /** @hidden */
  53869. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53870. }
  53871. }
  53872. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53873. import { Scene } from "babylonjs/scene";
  53874. import { Texture } from "babylonjs/Materials/Textures/texture";
  53875. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53876. /**
  53877. * Class used to store 3D textures containing user data
  53878. */
  53879. export class RawTexture3D extends Texture {
  53880. /** Gets or sets the texture format to use */
  53881. format: number;
  53882. private _engine;
  53883. /**
  53884. * Create a new RawTexture3D
  53885. * @param data defines the data of the texture
  53886. * @param width defines the width of the texture
  53887. * @param height defines the height of the texture
  53888. * @param depth defines the depth of the texture
  53889. * @param format defines the texture format to use
  53890. * @param scene defines the hosting scene
  53891. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53892. * @param invertY defines if texture must be stored with Y axis inverted
  53893. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53894. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53895. */
  53896. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53897. /** Gets or sets the texture format to use */
  53898. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53899. /**
  53900. * Update the texture with new data
  53901. * @param data defines the data to store in the texture
  53902. */
  53903. update(data: ArrayBufferView): void;
  53904. }
  53905. }
  53906. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53907. import { Scene } from "babylonjs/scene";
  53908. import { Plane } from "babylonjs/Maths/math.plane";
  53909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53910. /**
  53911. * Creates a refraction texture used by refraction channel of the standard material.
  53912. * It is like a mirror but to see through a material.
  53913. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53914. */
  53915. export class RefractionTexture extends RenderTargetTexture {
  53916. /**
  53917. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53918. * 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.
  53919. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53920. */
  53921. refractionPlane: Plane;
  53922. /**
  53923. * Define how deep under the surface we should see.
  53924. */
  53925. depth: number;
  53926. /**
  53927. * Creates a refraction texture used by refraction channel of the standard material.
  53928. * It is like a mirror but to see through a material.
  53929. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53930. * @param name Define the texture name
  53931. * @param size Define the size of the underlying texture
  53932. * @param scene Define the scene the refraction belongs to
  53933. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53934. */
  53935. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53936. /**
  53937. * Clone the refraction texture.
  53938. * @returns the cloned texture
  53939. */
  53940. clone(): RefractionTexture;
  53941. /**
  53942. * Serialize the texture to a JSON representation you could use in Parse later on
  53943. * @returns the serialized JSON representation
  53944. */
  53945. serialize(): any;
  53946. }
  53947. }
  53948. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53949. import { Nullable } from "babylonjs/types";
  53950. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53951. import { Matrix } from "babylonjs/Maths/math.vector";
  53952. import { Engine } from "babylonjs/Engines/engine";
  53953. import { Scene } from "babylonjs/scene";
  53954. /**
  53955. * Defines the options related to the creation of an HtmlElementTexture
  53956. */
  53957. export interface IHtmlElementTextureOptions {
  53958. /**
  53959. * Defines wether mip maps should be created or not.
  53960. */
  53961. generateMipMaps?: boolean;
  53962. /**
  53963. * Defines the sampling mode of the texture.
  53964. */
  53965. samplingMode?: number;
  53966. /**
  53967. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53968. */
  53969. engine: Nullable<Engine>;
  53970. /**
  53971. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53972. */
  53973. scene: Nullable<Scene>;
  53974. }
  53975. /**
  53976. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53977. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53978. * is automatically managed.
  53979. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53980. * in your application.
  53981. *
  53982. * As the update is not automatic, you need to call them manually.
  53983. */
  53984. export class HtmlElementTexture extends BaseTexture {
  53985. /**
  53986. * The texture URL.
  53987. */
  53988. element: HTMLVideoElement | HTMLCanvasElement;
  53989. private static readonly DefaultOptions;
  53990. private _textureMatrix;
  53991. private _engine;
  53992. private _isVideo;
  53993. private _generateMipMaps;
  53994. private _samplingMode;
  53995. /**
  53996. * Instantiates a HtmlElementTexture from the following parameters.
  53997. *
  53998. * @param name Defines the name of the texture
  53999. * @param element Defines the video or canvas the texture is filled with
  54000. * @param options Defines the other none mandatory texture creation options
  54001. */
  54002. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54003. private _createInternalTexture;
  54004. /**
  54005. * Returns the texture matrix used in most of the material.
  54006. */
  54007. getTextureMatrix(): Matrix;
  54008. /**
  54009. * Updates the content of the texture.
  54010. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54011. */
  54012. update(invertY?: Nullable<boolean>): void;
  54013. }
  54014. }
  54015. declare module "babylonjs/Materials/Textures/index" {
  54016. export * from "babylonjs/Materials/Textures/baseTexture";
  54017. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54018. export * from "babylonjs/Materials/Textures/cubeTexture";
  54019. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54020. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54021. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54022. export * from "babylonjs/Materials/Textures/internalTexture";
  54023. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54024. export * from "babylonjs/Materials/Textures/Loaders/index";
  54025. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54026. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54027. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54028. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54029. export * from "babylonjs/Materials/Textures/rawTexture";
  54030. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54031. export * from "babylonjs/Materials/Textures/refractionTexture";
  54032. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54033. export * from "babylonjs/Materials/Textures/texture";
  54034. export * from "babylonjs/Materials/Textures/videoTexture";
  54035. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54036. }
  54037. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54038. /**
  54039. * Enum used to define the target of a block
  54040. */
  54041. export enum NodeMaterialBlockTargets {
  54042. /** Vertex shader */
  54043. Vertex = 1,
  54044. /** Fragment shader */
  54045. Fragment = 2,
  54046. /** Neutral */
  54047. Neutral = 4,
  54048. /** Vertex and Fragment */
  54049. VertexAndFragment = 3
  54050. }
  54051. }
  54052. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54053. /**
  54054. * Defines the kind of connection point for node based material
  54055. */
  54056. export enum NodeMaterialBlockConnectionPointTypes {
  54057. /** Float */
  54058. Float = 1,
  54059. /** Int */
  54060. Int = 2,
  54061. /** Vector2 */
  54062. Vector2 = 4,
  54063. /** Vector3 */
  54064. Vector3 = 8,
  54065. /** Vector4 */
  54066. Vector4 = 16,
  54067. /** Color3 */
  54068. Color3 = 32,
  54069. /** Color4 */
  54070. Color4 = 64,
  54071. /** Matrix */
  54072. Matrix = 128,
  54073. /** Detect type based on connection */
  54074. AutoDetect = 1024,
  54075. /** Output type that will be defined by input type */
  54076. BasedOnInput = 2048
  54077. }
  54078. }
  54079. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54081. /**
  54082. * Root class for all node material optimizers
  54083. */
  54084. export class NodeMaterialOptimizer {
  54085. /**
  54086. * Function used to optimize a NodeMaterial graph
  54087. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54088. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54089. */
  54090. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54091. }
  54092. }
  54093. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54097. import { Scene } from "babylonjs/scene";
  54098. /**
  54099. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54100. */
  54101. export class TransformBlock extends NodeMaterialBlock {
  54102. /**
  54103. * Defines the value to use to complement W value to transform it to a Vector4
  54104. */
  54105. complementW: number;
  54106. /**
  54107. * Defines the value to use to complement z value to transform it to a Vector4
  54108. */
  54109. complementZ: number;
  54110. /**
  54111. * Creates a new TransformBlock
  54112. * @param name defines the block name
  54113. */
  54114. constructor(name: string);
  54115. /**
  54116. * Gets the current class name
  54117. * @returns the class name
  54118. */
  54119. getClassName(): string;
  54120. /**
  54121. * Gets the vector input
  54122. */
  54123. readonly vector: NodeMaterialConnectionPoint;
  54124. /**
  54125. * Gets the output component
  54126. */
  54127. readonly output: NodeMaterialConnectionPoint;
  54128. /**
  54129. * Gets the matrix transform input
  54130. */
  54131. readonly transform: NodeMaterialConnectionPoint;
  54132. protected _buildBlock(state: NodeMaterialBuildState): this;
  54133. serialize(): any;
  54134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54135. protected _dumpPropertiesCode(): string;
  54136. }
  54137. }
  54138. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54142. /**
  54143. * Block used to output the vertex position
  54144. */
  54145. export class VertexOutputBlock extends NodeMaterialBlock {
  54146. /**
  54147. * Creates a new VertexOutputBlock
  54148. * @param name defines the block name
  54149. */
  54150. constructor(name: string);
  54151. /**
  54152. * Gets the current class name
  54153. * @returns the class name
  54154. */
  54155. getClassName(): string;
  54156. /**
  54157. * Gets the vector input component
  54158. */
  54159. readonly vector: NodeMaterialConnectionPoint;
  54160. protected _buildBlock(state: NodeMaterialBuildState): this;
  54161. }
  54162. }
  54163. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54167. /**
  54168. * Block used to output the final color
  54169. */
  54170. export class FragmentOutputBlock extends NodeMaterialBlock {
  54171. /**
  54172. * Create a new FragmentOutputBlock
  54173. * @param name defines the block name
  54174. */
  54175. constructor(name: string);
  54176. /**
  54177. * Gets the current class name
  54178. * @returns the class name
  54179. */
  54180. getClassName(): string;
  54181. /**
  54182. * Gets the rgba input component
  54183. */
  54184. readonly rgba: NodeMaterialConnectionPoint;
  54185. /**
  54186. * Gets the rgb input component
  54187. */
  54188. readonly rgb: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the a input component
  54191. */
  54192. readonly a: NodeMaterialConnectionPoint;
  54193. protected _buildBlock(state: NodeMaterialBuildState): this;
  54194. }
  54195. }
  54196. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54197. /**
  54198. * Enum used to define well known values e.g. values automatically provided by the system
  54199. */
  54200. export enum NodeMaterialWellKnownValues {
  54201. /** World */
  54202. World = 1,
  54203. /** View */
  54204. View = 2,
  54205. /** Projection */
  54206. Projection = 3,
  54207. /** ViewProjection */
  54208. ViewProjection = 4,
  54209. /** WorldView */
  54210. WorldView = 5,
  54211. /** WorldViewProjection */
  54212. WorldViewProjection = 6,
  54213. /** CameraPosition */
  54214. CameraPosition = 7,
  54215. /** Fog Color */
  54216. FogColor = 8
  54217. }
  54218. }
  54219. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54222. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54226. import { Effect } from "babylonjs/Materials/effect";
  54227. import { Mesh } from "babylonjs/Meshes/mesh";
  54228. import { Nullable } from "babylonjs/types";
  54229. import { Scene } from "babylonjs/scene";
  54230. /**
  54231. * Block used to read a reflection texture from a sampler
  54232. */
  54233. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54234. private _define3DName;
  54235. private _defineCubicName;
  54236. private _defineExplicitName;
  54237. private _defineProjectionName;
  54238. private _defineLocalCubicName;
  54239. private _defineSphericalName;
  54240. private _definePlanarName;
  54241. private _defineEquirectangularName;
  54242. private _defineMirroredEquirectangularFixedName;
  54243. private _defineEquirectangularFixedName;
  54244. private _defineSkyboxName;
  54245. private _cubeSamplerName;
  54246. private _2DSamplerName;
  54247. private _positionUVWName;
  54248. private _directionWName;
  54249. private _reflectionCoordsName;
  54250. private _reflection2DCoordsName;
  54251. private _reflectionColorName;
  54252. private _reflectionMatrixName;
  54253. /**
  54254. * Gets or sets the texture associated with the node
  54255. */
  54256. texture: Nullable<BaseTexture>;
  54257. /**
  54258. * Create a new TextureBlock
  54259. * @param name defines the block name
  54260. */
  54261. constructor(name: string);
  54262. /**
  54263. * Gets the current class name
  54264. * @returns the class name
  54265. */
  54266. getClassName(): string;
  54267. /**
  54268. * Gets the world position input component
  54269. */
  54270. readonly position: NodeMaterialConnectionPoint;
  54271. /**
  54272. * Gets the world position input component
  54273. */
  54274. readonly worldPosition: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the world normal input component
  54277. */
  54278. readonly worldNormal: NodeMaterialConnectionPoint;
  54279. /**
  54280. * Gets the world input component
  54281. */
  54282. readonly world: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the camera (or eye) position component
  54285. */
  54286. readonly cameraPosition: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the view input component
  54289. */
  54290. readonly view: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the rgb output component
  54293. */
  54294. readonly rgb: NodeMaterialConnectionPoint;
  54295. /**
  54296. * Gets the r output component
  54297. */
  54298. readonly r: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the g output component
  54301. */
  54302. readonly g: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the b output component
  54305. */
  54306. readonly b: NodeMaterialConnectionPoint;
  54307. autoConfigure(material: NodeMaterial): void;
  54308. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54309. isReady(): boolean;
  54310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54311. private _injectVertexCode;
  54312. private _writeOutput;
  54313. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54314. serialize(): any;
  54315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54316. }
  54317. }
  54318. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54320. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54321. import { Scene } from "babylonjs/scene";
  54322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54323. import { Matrix } from "babylonjs/Maths/math.vector";
  54324. import { Mesh } from "babylonjs/Meshes/mesh";
  54325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54326. import { Observable } from "babylonjs/Misc/observable";
  54327. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54328. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54329. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54330. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54331. import { Nullable } from "babylonjs/types";
  54332. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54333. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54334. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54335. /**
  54336. * Interface used to configure the node material editor
  54337. */
  54338. export interface INodeMaterialEditorOptions {
  54339. /** Define the URl to load node editor script */
  54340. editorURL?: string;
  54341. }
  54342. /** @hidden */
  54343. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54344. /** BONES */
  54345. NUM_BONE_INFLUENCERS: number;
  54346. BonesPerMesh: number;
  54347. BONETEXTURE: boolean;
  54348. /** MORPH TARGETS */
  54349. MORPHTARGETS: boolean;
  54350. MORPHTARGETS_NORMAL: boolean;
  54351. MORPHTARGETS_TANGENT: boolean;
  54352. MORPHTARGETS_UV: boolean;
  54353. NUM_MORPH_INFLUENCERS: number;
  54354. /** IMAGE PROCESSING */
  54355. IMAGEPROCESSING: boolean;
  54356. VIGNETTE: boolean;
  54357. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54358. VIGNETTEBLENDMODEOPAQUE: boolean;
  54359. TONEMAPPING: boolean;
  54360. TONEMAPPING_ACES: boolean;
  54361. CONTRAST: boolean;
  54362. EXPOSURE: boolean;
  54363. COLORCURVES: boolean;
  54364. COLORGRADING: boolean;
  54365. COLORGRADING3D: boolean;
  54366. SAMPLER3DGREENDEPTH: boolean;
  54367. SAMPLER3DBGRMAP: boolean;
  54368. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54369. constructor();
  54370. setValue(name: string, value: boolean): void;
  54371. }
  54372. /**
  54373. * Class used to configure NodeMaterial
  54374. */
  54375. export interface INodeMaterialOptions {
  54376. /**
  54377. * Defines if blocks should emit comments
  54378. */
  54379. emitComments: boolean;
  54380. }
  54381. /**
  54382. * Class used to create a node based material built by assembling shader blocks
  54383. */
  54384. export class NodeMaterial extends PushMaterial {
  54385. private static _BuildIdGenerator;
  54386. private _options;
  54387. private _vertexCompilationState;
  54388. private _fragmentCompilationState;
  54389. private _sharedData;
  54390. private _buildId;
  54391. private _buildWasSuccessful;
  54392. private _cachedWorldViewMatrix;
  54393. private _cachedWorldViewProjectionMatrix;
  54394. private _optimizers;
  54395. private _animationFrame;
  54396. /** Define the URl to load node editor script */
  54397. static EditorURL: string;
  54398. private BJSNODEMATERIALEDITOR;
  54399. /** Get the inspector from bundle or global */
  54400. private _getGlobalNodeMaterialEditor;
  54401. /**
  54402. * 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)
  54403. */
  54404. ignoreAlpha: boolean;
  54405. /**
  54406. * Defines the maximum number of lights that can be used in the material
  54407. */
  54408. maxSimultaneousLights: number;
  54409. /**
  54410. * Observable raised when the material is built
  54411. */
  54412. onBuildObservable: Observable<NodeMaterial>;
  54413. /**
  54414. * Gets or sets the root nodes of the material vertex shader
  54415. */
  54416. _vertexOutputNodes: NodeMaterialBlock[];
  54417. /**
  54418. * Gets or sets the root nodes of the material fragment (pixel) shader
  54419. */
  54420. _fragmentOutputNodes: NodeMaterialBlock[];
  54421. /** Gets or sets options to control the node material overall behavior */
  54422. options: INodeMaterialOptions;
  54423. /**
  54424. * Default configuration related to image processing available in the standard Material.
  54425. */
  54426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54427. /**
  54428. * Gets the image processing configuration used either in this material.
  54429. */
  54430. /**
  54431. * Sets the Default image processing configuration used either in the this material.
  54432. *
  54433. * If sets to null, the scene one is in use.
  54434. */
  54435. imageProcessingConfiguration: ImageProcessingConfiguration;
  54436. /**
  54437. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54438. */
  54439. attachedBlocks: NodeMaterialBlock[];
  54440. /**
  54441. * Create a new node based material
  54442. * @param name defines the material name
  54443. * @param scene defines the hosting scene
  54444. * @param options defines creation option
  54445. */
  54446. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54447. /**
  54448. * Gets the current class name of the material e.g. "NodeMaterial"
  54449. * @returns the class name
  54450. */
  54451. getClassName(): string;
  54452. /**
  54453. * Keep track of the image processing observer to allow dispose and replace.
  54454. */
  54455. private _imageProcessingObserver;
  54456. /**
  54457. * Attaches a new image processing configuration to the Standard Material.
  54458. * @param configuration
  54459. */
  54460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54461. /**
  54462. * Get a block by its name
  54463. * @param name defines the name of the block to retrieve
  54464. * @returns the required block or null if not found
  54465. */
  54466. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54467. /**
  54468. * Get a block by its name
  54469. * @param predicate defines the predicate used to find the good candidate
  54470. * @returns the required block or null if not found
  54471. */
  54472. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54473. /**
  54474. * Get an input block by its name
  54475. * @param predicate defines the predicate used to find the good candidate
  54476. * @returns the required input block or null if not found
  54477. */
  54478. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54479. /**
  54480. * Gets the list of input blocks attached to this material
  54481. * @returns an array of InputBlocks
  54482. */
  54483. getInputBlocks(): InputBlock[];
  54484. /**
  54485. * Adds a new optimizer to the list of optimizers
  54486. * @param optimizer defines the optimizers to add
  54487. * @returns the current material
  54488. */
  54489. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54490. /**
  54491. * Remove an optimizer from the list of optimizers
  54492. * @param optimizer defines the optimizers to remove
  54493. * @returns the current material
  54494. */
  54495. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54496. /**
  54497. * Add a new block to the list of output nodes
  54498. * @param node defines the node to add
  54499. * @returns the current material
  54500. */
  54501. addOutputNode(node: NodeMaterialBlock): this;
  54502. /**
  54503. * Remove a block from the list of root nodes
  54504. * @param node defines the node to remove
  54505. * @returns the current material
  54506. */
  54507. removeOutputNode(node: NodeMaterialBlock): this;
  54508. private _addVertexOutputNode;
  54509. private _removeVertexOutputNode;
  54510. private _addFragmentOutputNode;
  54511. private _removeFragmentOutputNode;
  54512. /**
  54513. * Specifies if the material will require alpha blending
  54514. * @returns a boolean specifying if alpha blending is needed
  54515. */
  54516. needAlphaBlending(): boolean;
  54517. /**
  54518. * Specifies if this material should be rendered in alpha test mode
  54519. * @returns a boolean specifying if an alpha test is needed.
  54520. */
  54521. needAlphaTesting(): boolean;
  54522. private _initializeBlock;
  54523. private _resetDualBlocks;
  54524. /**
  54525. * Build the material and generates the inner effect
  54526. * @param verbose defines if the build should log activity
  54527. */
  54528. build(verbose?: boolean): void;
  54529. /**
  54530. * Runs an otpimization phase to try to improve the shader code
  54531. */
  54532. optimize(): void;
  54533. private _prepareDefinesForAttributes;
  54534. /**
  54535. * Get if the submesh is ready to be used and all its information available.
  54536. * Child classes can use it to update shaders
  54537. * @param mesh defines the mesh to check
  54538. * @param subMesh defines which submesh to check
  54539. * @param useInstances specifies that instances should be used
  54540. * @returns a boolean indicating that the submesh is ready or not
  54541. */
  54542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54543. /**
  54544. * Get a string representing the shaders built by the current node graph
  54545. */
  54546. readonly compiledShaders: string;
  54547. /**
  54548. * Binds the world matrix to the material
  54549. * @param world defines the world transformation matrix
  54550. */
  54551. bindOnlyWorldMatrix(world: Matrix): void;
  54552. /**
  54553. * Binds the submesh to this material by preparing the effect and shader to draw
  54554. * @param world defines the world transformation matrix
  54555. * @param mesh defines the mesh containing the submesh
  54556. * @param subMesh defines the submesh to bind the material to
  54557. */
  54558. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54559. /**
  54560. * Gets the active textures from the material
  54561. * @returns an array of textures
  54562. */
  54563. getActiveTextures(): BaseTexture[];
  54564. /**
  54565. * Gets the list of texture blocks
  54566. * @returns an array of texture blocks
  54567. */
  54568. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54569. /**
  54570. * Specifies if the material uses a texture
  54571. * @param texture defines the texture to check against the material
  54572. * @returns a boolean specifying if the material uses the texture
  54573. */
  54574. hasTexture(texture: BaseTexture): boolean;
  54575. /**
  54576. * Disposes the material
  54577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54579. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54580. */
  54581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54582. /** Creates the node editor window. */
  54583. private _createNodeEditor;
  54584. /**
  54585. * Launch the node material editor
  54586. * @param config Define the configuration of the editor
  54587. * @return a promise fulfilled when the node editor is visible
  54588. */
  54589. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54590. /**
  54591. * Clear the current material
  54592. */
  54593. clear(): void;
  54594. /**
  54595. * Clear the current material and set it to a default state
  54596. */
  54597. setToDefault(): void;
  54598. /**
  54599. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54600. * @param url defines the url to load from
  54601. * @returns a promise that will fullfil when the material is fully loaded
  54602. */
  54603. loadAsync(url: string): Promise<unknown>;
  54604. private _gatherBlocks;
  54605. /**
  54606. * Generate a string containing the code declaration required to create an equivalent of this material
  54607. * @returns a string
  54608. */
  54609. generateCode(): string;
  54610. /**
  54611. * Serializes this material in a JSON representation
  54612. * @returns the serialized material object
  54613. */
  54614. serialize(): any;
  54615. private _restoreConnections;
  54616. /**
  54617. * Clear the current graph and load a new one from a serialization object
  54618. * @param source defines the JSON representation of the material
  54619. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54620. */
  54621. loadFromSerialization(source: any, rootUrl?: string): void;
  54622. /**
  54623. * Creates a node material from parsed material data
  54624. * @param source defines the JSON representation of the material
  54625. * @param scene defines the hosting scene
  54626. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54627. * @returns a new node material
  54628. */
  54629. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54630. /**
  54631. * Creates a new node material set to default basic configuration
  54632. * @param name defines the name of the material
  54633. * @param scene defines the hosting scene
  54634. * @returns a new NodeMaterial
  54635. */
  54636. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54637. }
  54638. }
  54639. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54642. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54646. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54647. import { Effect } from "babylonjs/Materials/effect";
  54648. import { Mesh } from "babylonjs/Meshes/mesh";
  54649. import { Nullable } from "babylonjs/types";
  54650. import { Scene } from "babylonjs/scene";
  54651. /**
  54652. * Block used to read a texture from a sampler
  54653. */
  54654. export class TextureBlock extends NodeMaterialBlock {
  54655. private _defineName;
  54656. private _samplerName;
  54657. private _transformedUVName;
  54658. private _textureTransformName;
  54659. private _textureInfoName;
  54660. private _mainUVName;
  54661. private _mainUVDefineName;
  54662. /**
  54663. * Gets or sets the texture associated with the node
  54664. */
  54665. texture: Nullable<BaseTexture>;
  54666. /**
  54667. * Create a new TextureBlock
  54668. * @param name defines the block name
  54669. */
  54670. constructor(name: string);
  54671. /**
  54672. * Gets the current class name
  54673. * @returns the class name
  54674. */
  54675. getClassName(): string;
  54676. /**
  54677. * Gets the uv input component
  54678. */
  54679. readonly uv: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the rgba output component
  54682. */
  54683. readonly rgba: NodeMaterialConnectionPoint;
  54684. /**
  54685. * Gets the rgb output component
  54686. */
  54687. readonly rgb: NodeMaterialConnectionPoint;
  54688. /**
  54689. * Gets the r output component
  54690. */
  54691. readonly r: NodeMaterialConnectionPoint;
  54692. /**
  54693. * Gets the g output component
  54694. */
  54695. readonly g: NodeMaterialConnectionPoint;
  54696. /**
  54697. * Gets the b output component
  54698. */
  54699. readonly b: NodeMaterialConnectionPoint;
  54700. /**
  54701. * Gets the a output component
  54702. */
  54703. readonly a: NodeMaterialConnectionPoint;
  54704. readonly target: NodeMaterialBlockTargets;
  54705. autoConfigure(material: NodeMaterial): void;
  54706. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54708. isReady(): boolean;
  54709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54710. private readonly _isMixed;
  54711. private _injectVertexCode;
  54712. private _writeOutput;
  54713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54714. protected _dumpPropertiesCode(): string;
  54715. serialize(): any;
  54716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54717. }
  54718. }
  54719. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54722. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54723. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54724. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54725. /**
  54726. * Class used to store shared data between 2 NodeMaterialBuildState
  54727. */
  54728. export class NodeMaterialBuildStateSharedData {
  54729. /**
  54730. * Gets the list of emitted varyings
  54731. */
  54732. temps: string[];
  54733. /**
  54734. * Gets the list of emitted varyings
  54735. */
  54736. varyings: string[];
  54737. /**
  54738. * Gets the varying declaration string
  54739. */
  54740. varyingDeclaration: string;
  54741. /**
  54742. * Input blocks
  54743. */
  54744. inputBlocks: InputBlock[];
  54745. /**
  54746. * Input blocks
  54747. */
  54748. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54749. /**
  54750. * Bindable blocks (Blocks that need to set data to the effect)
  54751. */
  54752. bindableBlocks: NodeMaterialBlock[];
  54753. /**
  54754. * List of blocks that can provide a compilation fallback
  54755. */
  54756. blocksWithFallbacks: NodeMaterialBlock[];
  54757. /**
  54758. * List of blocks that can provide a define update
  54759. */
  54760. blocksWithDefines: NodeMaterialBlock[];
  54761. /**
  54762. * List of blocks that can provide a repeatable content
  54763. */
  54764. repeatableContentBlocks: NodeMaterialBlock[];
  54765. /**
  54766. * List of blocks that can provide a dynamic list of uniforms
  54767. */
  54768. dynamicUniformBlocks: NodeMaterialBlock[];
  54769. /**
  54770. * List of blocks that can block the isReady function for the material
  54771. */
  54772. blockingBlocks: NodeMaterialBlock[];
  54773. /**
  54774. * Gets the list of animated inputs
  54775. */
  54776. animatedInputs: InputBlock[];
  54777. /**
  54778. * Build Id used to avoid multiple recompilations
  54779. */
  54780. buildId: number;
  54781. /** List of emitted variables */
  54782. variableNames: {
  54783. [key: string]: number;
  54784. };
  54785. /** List of emitted defines */
  54786. defineNames: {
  54787. [key: string]: number;
  54788. };
  54789. /** Should emit comments? */
  54790. emitComments: boolean;
  54791. /** Emit build activity */
  54792. verbose: boolean;
  54793. /**
  54794. * Gets the compilation hints emitted at compilation time
  54795. */
  54796. hints: {
  54797. needWorldViewMatrix: boolean;
  54798. needWorldViewProjectionMatrix: boolean;
  54799. needAlphaBlending: boolean;
  54800. needAlphaTesting: boolean;
  54801. };
  54802. /**
  54803. * List of compilation checks
  54804. */
  54805. checks: {
  54806. emitVertex: boolean;
  54807. emitFragment: boolean;
  54808. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54809. };
  54810. /** Creates a new shared data */
  54811. constructor();
  54812. /**
  54813. * Emits console errors and exceptions if there is a failing check
  54814. */
  54815. emitErrors(): void;
  54816. }
  54817. }
  54818. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54819. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54820. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54821. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54822. /**
  54823. * Class used to store node based material build state
  54824. */
  54825. export class NodeMaterialBuildState {
  54826. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54827. supportUniformBuffers: boolean;
  54828. /**
  54829. * Gets the list of emitted attributes
  54830. */
  54831. attributes: string[];
  54832. /**
  54833. * Gets the list of emitted uniforms
  54834. */
  54835. uniforms: string[];
  54836. /**
  54837. * Gets the list of emitted uniform buffers
  54838. */
  54839. uniformBuffers: string[];
  54840. /**
  54841. * Gets the list of emitted samplers
  54842. */
  54843. samplers: string[];
  54844. /**
  54845. * Gets the list of emitted functions
  54846. */
  54847. functions: {
  54848. [key: string]: string;
  54849. };
  54850. /**
  54851. * Gets the target of the compilation state
  54852. */
  54853. target: NodeMaterialBlockTargets;
  54854. /**
  54855. * Gets the list of emitted counters
  54856. */
  54857. counters: {
  54858. [key: string]: number;
  54859. };
  54860. /**
  54861. * Shared data between multiple NodeMaterialBuildState instances
  54862. */
  54863. sharedData: NodeMaterialBuildStateSharedData;
  54864. /** @hidden */
  54865. _vertexState: NodeMaterialBuildState;
  54866. /** @hidden */
  54867. _attributeDeclaration: string;
  54868. /** @hidden */
  54869. _uniformDeclaration: string;
  54870. /** @hidden */
  54871. _samplerDeclaration: string;
  54872. /** @hidden */
  54873. _varyingTransfer: string;
  54874. private _repeatableContentAnchorIndex;
  54875. /** @hidden */
  54876. _builtCompilationString: string;
  54877. /**
  54878. * Gets the emitted compilation strings
  54879. */
  54880. compilationString: string;
  54881. /**
  54882. * Finalize the compilation strings
  54883. * @param state defines the current compilation state
  54884. */
  54885. finalize(state: NodeMaterialBuildState): void;
  54886. /** @hidden */
  54887. readonly _repeatableContentAnchor: string;
  54888. /** @hidden */
  54889. _getFreeVariableName(prefix: string): string;
  54890. /** @hidden */
  54891. _getFreeDefineName(prefix: string): string;
  54892. /** @hidden */
  54893. _excludeVariableName(name: string): void;
  54894. /** @hidden */
  54895. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54896. /** @hidden */
  54897. _emitFunction(name: string, code: string, comments: string): void;
  54898. /** @hidden */
  54899. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54900. replaceStrings?: {
  54901. search: RegExp;
  54902. replace: string;
  54903. }[];
  54904. repeatKey?: string;
  54905. }): string;
  54906. /** @hidden */
  54907. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54908. repeatKey?: string;
  54909. removeAttributes?: boolean;
  54910. removeUniforms?: boolean;
  54911. removeVaryings?: boolean;
  54912. removeIfDef?: boolean;
  54913. replaceStrings?: {
  54914. search: RegExp;
  54915. replace: string;
  54916. }[];
  54917. }, storeKey?: string): void;
  54918. /** @hidden */
  54919. _registerTempVariable(name: string): boolean;
  54920. /** @hidden */
  54921. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54922. /** @hidden */
  54923. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54924. }
  54925. }
  54926. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54927. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54929. import { Nullable } from "babylonjs/types";
  54930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54931. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54932. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54934. import { Mesh } from "babylonjs/Meshes/mesh";
  54935. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54936. import { Scene } from "babylonjs/scene";
  54937. /**
  54938. * Defines a block that can be used inside a node based material
  54939. */
  54940. export class NodeMaterialBlock {
  54941. private _buildId;
  54942. private _buildTarget;
  54943. private _target;
  54944. private _isFinalMerger;
  54945. private _isInput;
  54946. /** @hidden */
  54947. _codeVariableName: string;
  54948. /** @hidden */
  54949. _inputs: NodeMaterialConnectionPoint[];
  54950. /** @hidden */
  54951. _outputs: NodeMaterialConnectionPoint[];
  54952. /** @hidden */
  54953. _preparationId: number;
  54954. /**
  54955. * Gets or sets the name of the block
  54956. */
  54957. name: string;
  54958. /**
  54959. * Gets or sets the unique id of the node
  54960. */
  54961. uniqueId: number;
  54962. /**
  54963. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54964. */
  54965. readonly isFinalMerger: boolean;
  54966. /**
  54967. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54968. */
  54969. readonly isInput: boolean;
  54970. /**
  54971. * Gets or sets the build Id
  54972. */
  54973. buildId: number;
  54974. /**
  54975. * Gets or sets the target of the block
  54976. */
  54977. target: NodeMaterialBlockTargets;
  54978. /**
  54979. * Gets the list of input points
  54980. */
  54981. readonly inputs: NodeMaterialConnectionPoint[];
  54982. /** Gets the list of output points */
  54983. readonly outputs: NodeMaterialConnectionPoint[];
  54984. /**
  54985. * Find an input by its name
  54986. * @param name defines the name of the input to look for
  54987. * @returns the input or null if not found
  54988. */
  54989. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54990. /**
  54991. * Find an output by its name
  54992. * @param name defines the name of the outputto look for
  54993. * @returns the output or null if not found
  54994. */
  54995. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54996. /**
  54997. * Creates a new NodeMaterialBlock
  54998. * @param name defines the block name
  54999. * @param target defines the target of that block (Vertex by default)
  55000. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55001. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55002. */
  55003. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55004. /**
  55005. * Initialize the block and prepare the context for build
  55006. * @param state defines the state that will be used for the build
  55007. */
  55008. initialize(state: NodeMaterialBuildState): void;
  55009. /**
  55010. * Bind data to effect. Will only be called for blocks with isBindable === true
  55011. * @param effect defines the effect to bind data to
  55012. * @param nodeMaterial defines the hosting NodeMaterial
  55013. * @param mesh defines the mesh that will be rendered
  55014. */
  55015. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55016. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55017. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55018. protected _writeFloat(value: number): string;
  55019. /**
  55020. * Gets the current class name e.g. "NodeMaterialBlock"
  55021. * @returns the class name
  55022. */
  55023. getClassName(): string;
  55024. /**
  55025. * Register a new input. Must be called inside a block constructor
  55026. * @param name defines the connection point name
  55027. * @param type defines the connection point type
  55028. * @param isOptional defines a boolean indicating that this input can be omitted
  55029. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55030. * @returns the current block
  55031. */
  55032. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55033. /**
  55034. * Register a new output. Must be called inside a block constructor
  55035. * @param name defines the connection point name
  55036. * @param type defines the connection point type
  55037. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55038. * @returns the current block
  55039. */
  55040. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55041. /**
  55042. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55043. * @param forOutput defines an optional connection point to check compatibility with
  55044. * @returns the first available input or null
  55045. */
  55046. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55047. /**
  55048. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55049. * @param forBlock defines an optional block to check compatibility with
  55050. * @returns the first available input or null
  55051. */
  55052. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55053. /**
  55054. * Gets the sibling of the given output
  55055. * @param current defines the current output
  55056. * @returns the next output in the list or null
  55057. */
  55058. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55059. /**
  55060. * Connect current block with another block
  55061. * @param other defines the block to connect with
  55062. * @param options define the various options to help pick the right connections
  55063. * @returns the current block
  55064. */
  55065. connectTo(other: NodeMaterialBlock, options?: {
  55066. input?: string;
  55067. output?: string;
  55068. outputSwizzle?: string;
  55069. }): this | undefined;
  55070. protected _buildBlock(state: NodeMaterialBuildState): void;
  55071. /**
  55072. * Add uniforms, samplers and uniform buffers at compilation time
  55073. * @param state defines the state to update
  55074. * @param nodeMaterial defines the node material requesting the update
  55075. * @param defines defines the material defines to update
  55076. */
  55077. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55078. /**
  55079. * Add potential fallbacks if shader compilation fails
  55080. * @param mesh defines the mesh to be rendered
  55081. * @param fallbacks defines the current prioritized list of fallbacks
  55082. */
  55083. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55084. /**
  55085. * Update defines for shader compilation
  55086. * @param mesh defines the mesh to be rendered
  55087. * @param nodeMaterial defines the node material requesting the update
  55088. * @param defines defines the material defines to update
  55089. * @param useInstances specifies that instances should be used
  55090. */
  55091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55092. /**
  55093. * Initialize defines for shader compilation
  55094. * @param mesh defines the mesh to be rendered
  55095. * @param nodeMaterial defines the node material requesting the update
  55096. * @param defines defines the material defines to be prepared
  55097. * @param useInstances specifies that instances should be used
  55098. */
  55099. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55100. /**
  55101. * Lets the block try to connect some inputs automatically
  55102. * @param material defines the hosting NodeMaterial
  55103. */
  55104. autoConfigure(material: NodeMaterial): void;
  55105. /**
  55106. * Function called when a block is declared as repeatable content generator
  55107. * @param vertexShaderState defines the current compilation state for the vertex shader
  55108. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55109. * @param mesh defines the mesh to be rendered
  55110. * @param defines defines the material defines to update
  55111. */
  55112. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55113. /**
  55114. * Checks if the block is ready
  55115. * @param mesh defines the mesh to be rendered
  55116. * @param nodeMaterial defines the node material requesting the update
  55117. * @param defines defines the material defines to update
  55118. * @param useInstances specifies that instances should be used
  55119. * @returns true if the block is ready
  55120. */
  55121. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55122. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55123. private _processBuild;
  55124. /**
  55125. * Compile the current node and generate the shader code
  55126. * @param state defines the current compilation state (uniforms, samplers, current string)
  55127. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55128. * @returns true if already built
  55129. */
  55130. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55131. protected _inputRename(name: string): string;
  55132. protected _outputRename(name: string): string;
  55133. protected _dumpPropertiesCode(): string;
  55134. /** @hidden */
  55135. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55136. /**
  55137. * Clone the current block to a new identical block
  55138. * @param scene defines the hosting scene
  55139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55140. * @returns a copy of the current block
  55141. */
  55142. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55143. /**
  55144. * Serializes this block in a JSON representation
  55145. * @returns the serialized block object
  55146. */
  55147. serialize(): any;
  55148. /** @hidden */
  55149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55150. }
  55151. }
  55152. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55153. /**
  55154. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55155. */
  55156. export enum NodeMaterialBlockConnectionPointMode {
  55157. /** Value is an uniform */
  55158. Uniform = 0,
  55159. /** Value is a mesh attribute */
  55160. Attribute = 1,
  55161. /** Value is a varying between vertex and fragment shaders */
  55162. Varying = 2,
  55163. /** Mode is undefined */
  55164. Undefined = 3
  55165. }
  55166. }
  55167. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55168. /**
  55169. * Enum defining the type of animations supported by InputBlock
  55170. */
  55171. export enum AnimatedInputBlockTypes {
  55172. /** No animation */
  55173. None = 0,
  55174. /** Time based animation. Will only work for floats */
  55175. Time = 1
  55176. }
  55177. }
  55178. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55180. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55181. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55182. import { Nullable } from "babylonjs/types";
  55183. import { Effect } from "babylonjs/Materials/effect";
  55184. import { Matrix } from "babylonjs/Maths/math.vector";
  55185. import { Scene } from "babylonjs/scene";
  55186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55188. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55189. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55190. /**
  55191. * Block used to expose an input value
  55192. */
  55193. export class InputBlock extends NodeMaterialBlock {
  55194. private _mode;
  55195. private _associatedVariableName;
  55196. private _storedValue;
  55197. private _valueCallback;
  55198. private _type;
  55199. private _animationType;
  55200. /** @hidden */
  55201. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55202. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55203. visibleInInspector: boolean;
  55204. /**
  55205. * Gets or sets the connection point type (default is float)
  55206. */
  55207. readonly type: NodeMaterialBlockConnectionPointTypes;
  55208. /**
  55209. * Creates a new InputBlock
  55210. * @param name defines the block name
  55211. * @param target defines the target of that block (Vertex by default)
  55212. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55213. */
  55214. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55215. /**
  55216. * Gets the output component
  55217. */
  55218. readonly output: NodeMaterialConnectionPoint;
  55219. /**
  55220. * Set the source of this connection point to a vertex attribute
  55221. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55222. * @returns the current connection point
  55223. */
  55224. setAsAttribute(attributeName?: string): InputBlock;
  55225. /**
  55226. * Set the source of this connection point to a well known value
  55227. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55228. * @returns the current connection point
  55229. */
  55230. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55231. /**
  55232. * Gets or sets the value of that point.
  55233. * Please note that this value will be ignored if valueCallback is defined
  55234. */
  55235. value: any;
  55236. /**
  55237. * Gets or sets a callback used to get the value of that point.
  55238. * Please note that setting this value will force the connection point to ignore the value property
  55239. */
  55240. valueCallback: () => any;
  55241. /**
  55242. * Gets or sets the associated variable name in the shader
  55243. */
  55244. associatedVariableName: string;
  55245. /** Gets or sets the type of animation applied to the input */
  55246. animationType: AnimatedInputBlockTypes;
  55247. /**
  55248. * Gets a boolean indicating that this connection point not defined yet
  55249. */
  55250. readonly isUndefined: boolean;
  55251. /**
  55252. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55253. * In this case the connection point name must be the name of the uniform to use.
  55254. * Can only be set on inputs
  55255. */
  55256. isUniform: boolean;
  55257. /**
  55258. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55259. * In this case the connection point name must be the name of the attribute to use
  55260. * Can only be set on inputs
  55261. */
  55262. isAttribute: boolean;
  55263. /**
  55264. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55265. * Can only be set on exit points
  55266. */
  55267. isVarying: boolean;
  55268. /**
  55269. * Gets a boolean indicating that the current connection point is a well known value
  55270. */
  55271. readonly isWellKnownValue: boolean;
  55272. /**
  55273. * Gets or sets the current well known value or null if not defined as well know value
  55274. */
  55275. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55276. /**
  55277. * Gets the current class name
  55278. * @returns the class name
  55279. */
  55280. getClassName(): string;
  55281. /**
  55282. * Animate the input if animationType !== None
  55283. * @param scene defines the rendering scene
  55284. */
  55285. animate(scene: Scene): void;
  55286. private _emitDefine;
  55287. /**
  55288. * Set the input block to its default value (based on its type)
  55289. */
  55290. setDefaultValue(): void;
  55291. protected _dumpPropertiesCode(): string;
  55292. private _emit;
  55293. /** @hidden */
  55294. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55295. /** @hidden */
  55296. _transmit(effect: Effect, scene: Scene): void;
  55297. protected _buildBlock(state: NodeMaterialBuildState): void;
  55298. serialize(): any;
  55299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55300. }
  55301. }
  55302. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55303. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55304. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55305. import { Nullable } from "babylonjs/types";
  55306. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55308. /**
  55309. * Defines a connection point for a block
  55310. */
  55311. export class NodeMaterialConnectionPoint {
  55312. /** @hidden */
  55313. _ownerBlock: NodeMaterialBlock;
  55314. /** @hidden */
  55315. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55316. private _endpoints;
  55317. private _associatedVariableName;
  55318. /** @hidden */
  55319. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55320. /** @hidden */
  55321. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55322. private _type;
  55323. /** @hidden */
  55324. _enforceAssociatedVariableName: boolean;
  55325. /**
  55326. * Gets or sets the additional types supported byt this connection point
  55327. */
  55328. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55329. /**
  55330. * Gets or sets the associated variable name in the shader
  55331. */
  55332. associatedVariableName: string;
  55333. /**
  55334. * Gets or sets the connection point type (default is float)
  55335. */
  55336. type: NodeMaterialBlockConnectionPointTypes;
  55337. /**
  55338. * Gets or sets the connection point name
  55339. */
  55340. name: string;
  55341. /**
  55342. * Gets or sets a boolean indicating that this connection point can be omitted
  55343. */
  55344. isOptional: boolean;
  55345. /**
  55346. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55347. */
  55348. define: string;
  55349. /** Gets or sets the target of that connection point */
  55350. target: NodeMaterialBlockTargets;
  55351. /**
  55352. * Gets a boolean indicating that the current point is connected
  55353. */
  55354. readonly isConnected: boolean;
  55355. /**
  55356. * Gets a boolean indicating that the current point is connected to an input block
  55357. */
  55358. readonly isConnectedToInputBlock: boolean;
  55359. /**
  55360. * Gets a the connected input block (if any)
  55361. */
  55362. readonly connectInputBlock: Nullable<InputBlock>;
  55363. /** Get the other side of the connection (if any) */
  55364. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55365. /** Get the block that owns this connection point */
  55366. readonly ownerBlock: NodeMaterialBlock;
  55367. /** Get the block connected on the other side of this connection (if any) */
  55368. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55369. /** Get the block connected on the endpoints of this connection (if any) */
  55370. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55371. /** Gets the list of connected endpoints */
  55372. readonly endpoints: NodeMaterialConnectionPoint[];
  55373. /** Gets a boolean indicating if that output point is connected to at least one input */
  55374. readonly hasEndpoints: boolean;
  55375. /**
  55376. * Creates a new connection point
  55377. * @param name defines the connection point name
  55378. * @param ownerBlock defines the block hosting this connection point
  55379. */
  55380. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55381. /**
  55382. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55383. * @returns the class name
  55384. */
  55385. getClassName(): string;
  55386. /**
  55387. * Gets an boolean indicating if the current point can be connected to another point
  55388. * @param connectionPoint defines the other connection point
  55389. * @returns true if the connection is possible
  55390. */
  55391. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55392. /**
  55393. * Connect this point to another connection point
  55394. * @param connectionPoint defines the other connection point
  55395. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55396. * @returns the current connection point
  55397. */
  55398. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55399. /**
  55400. * Disconnect this point from one of his endpoint
  55401. * @param endpoint defines the other connection point
  55402. * @returns the current connection point
  55403. */
  55404. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55405. /**
  55406. * Serializes this point in a JSON representation
  55407. * @returns the serialized point object
  55408. */
  55409. serialize(): any;
  55410. }
  55411. }
  55412. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55416. import { Mesh } from "babylonjs/Meshes/mesh";
  55417. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55419. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55420. /**
  55421. * Block used to add support for vertex skinning (bones)
  55422. */
  55423. export class BonesBlock extends NodeMaterialBlock {
  55424. /**
  55425. * Creates a new BonesBlock
  55426. * @param name defines the block name
  55427. */
  55428. constructor(name: string);
  55429. /**
  55430. * Initialize the block and prepare the context for build
  55431. * @param state defines the state that will be used for the build
  55432. */
  55433. initialize(state: NodeMaterialBuildState): void;
  55434. /**
  55435. * Gets the current class name
  55436. * @returns the class name
  55437. */
  55438. getClassName(): string;
  55439. /**
  55440. * Gets the matrix indices input component
  55441. */
  55442. readonly matricesIndices: NodeMaterialConnectionPoint;
  55443. /**
  55444. * Gets the matrix weights input component
  55445. */
  55446. readonly matricesWeights: NodeMaterialConnectionPoint;
  55447. /**
  55448. * Gets the extra matrix indices input component
  55449. */
  55450. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Gets the extra matrix weights input component
  55453. */
  55454. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55455. /**
  55456. * Gets the world input component
  55457. */
  55458. readonly world: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Gets the output component
  55461. */
  55462. readonly output: NodeMaterialConnectionPoint;
  55463. autoConfigure(material: NodeMaterial): void;
  55464. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55465. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55467. protected _buildBlock(state: NodeMaterialBuildState): this;
  55468. }
  55469. }
  55470. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55475. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55476. /**
  55477. * Block used to add support for instances
  55478. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55479. */
  55480. export class InstancesBlock extends NodeMaterialBlock {
  55481. /**
  55482. * Creates a new InstancesBlock
  55483. * @param name defines the block name
  55484. */
  55485. constructor(name: string);
  55486. /**
  55487. * Gets the current class name
  55488. * @returns the class name
  55489. */
  55490. getClassName(): string;
  55491. /**
  55492. * Gets the first world row input component
  55493. */
  55494. readonly world0: NodeMaterialConnectionPoint;
  55495. /**
  55496. * Gets the second world row input component
  55497. */
  55498. readonly world1: NodeMaterialConnectionPoint;
  55499. /**
  55500. * Gets the third world row input component
  55501. */
  55502. readonly world2: NodeMaterialConnectionPoint;
  55503. /**
  55504. * Gets the forth world row input component
  55505. */
  55506. readonly world3: NodeMaterialConnectionPoint;
  55507. /**
  55508. * Gets the world input component
  55509. */
  55510. readonly world: NodeMaterialConnectionPoint;
  55511. /**
  55512. * Gets the output component
  55513. */
  55514. readonly output: NodeMaterialConnectionPoint;
  55515. autoConfigure(material: NodeMaterial): void;
  55516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55517. protected _buildBlock(state: NodeMaterialBuildState): this;
  55518. }
  55519. }
  55520. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55525. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55526. import { Effect } from "babylonjs/Materials/effect";
  55527. import { Mesh } from "babylonjs/Meshes/mesh";
  55528. /**
  55529. * Block used to add morph targets support to vertex shader
  55530. */
  55531. export class MorphTargetsBlock extends NodeMaterialBlock {
  55532. private _repeatableContentAnchor;
  55533. private _repeatebleContentGenerated;
  55534. /**
  55535. * Create a new MorphTargetsBlock
  55536. * @param name defines the block name
  55537. */
  55538. constructor(name: string);
  55539. /**
  55540. * Gets the current class name
  55541. * @returns the class name
  55542. */
  55543. getClassName(): string;
  55544. /**
  55545. * Gets the position input component
  55546. */
  55547. readonly position: NodeMaterialConnectionPoint;
  55548. /**
  55549. * Gets the normal input component
  55550. */
  55551. readonly normal: NodeMaterialConnectionPoint;
  55552. /**
  55553. * Gets the tangent input component
  55554. */
  55555. readonly tangent: NodeMaterialConnectionPoint;
  55556. /**
  55557. * Gets the tangent input component
  55558. */
  55559. readonly uv: NodeMaterialConnectionPoint;
  55560. /**
  55561. * Gets the position output component
  55562. */
  55563. readonly positionOutput: NodeMaterialConnectionPoint;
  55564. /**
  55565. * Gets the normal output component
  55566. */
  55567. readonly normalOutput: NodeMaterialConnectionPoint;
  55568. /**
  55569. * Gets the tangent output component
  55570. */
  55571. readonly tangentOutput: NodeMaterialConnectionPoint;
  55572. /**
  55573. * Gets the tangent output component
  55574. */
  55575. readonly uvOutput: NodeMaterialConnectionPoint;
  55576. initialize(state: NodeMaterialBuildState): void;
  55577. autoConfigure(material: NodeMaterial): void;
  55578. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55580. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55581. protected _buildBlock(state: NodeMaterialBuildState): this;
  55582. }
  55583. }
  55584. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55588. import { Nullable } from "babylonjs/types";
  55589. import { Scene } from "babylonjs/scene";
  55590. import { Effect } from "babylonjs/Materials/effect";
  55591. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55592. import { Mesh } from "babylonjs/Meshes/mesh";
  55593. import { Light } from "babylonjs/Lights/light";
  55594. /**
  55595. * Block used to get data information from a light
  55596. */
  55597. export class LightInformationBlock extends NodeMaterialBlock {
  55598. private _lightDataDefineName;
  55599. private _lightColorDefineName;
  55600. /**
  55601. * Gets or sets the light associated with this block
  55602. */
  55603. light: Nullable<Light>;
  55604. /**
  55605. * Creates a new LightInformationBlock
  55606. * @param name defines the block name
  55607. */
  55608. constructor(name: string);
  55609. /**
  55610. * Gets the current class name
  55611. * @returns the class name
  55612. */
  55613. getClassName(): string;
  55614. /**
  55615. * Gets the world position input component
  55616. */
  55617. readonly worldPosition: NodeMaterialConnectionPoint;
  55618. /**
  55619. * Gets the direction output component
  55620. */
  55621. readonly direction: NodeMaterialConnectionPoint;
  55622. /**
  55623. * Gets the direction output component
  55624. */
  55625. readonly color: NodeMaterialConnectionPoint;
  55626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55627. protected _buildBlock(state: NodeMaterialBuildState): this;
  55628. serialize(): any;
  55629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55630. }
  55631. }
  55632. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55633. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55634. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55635. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55636. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55637. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  55638. }
  55639. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55643. import { Scene } from "babylonjs/scene";
  55644. /**
  55645. * Block used to add an alpha test in the fragment shader
  55646. */
  55647. export class AlphaTestBlock extends NodeMaterialBlock {
  55648. /**
  55649. * Gets or sets the alpha value where alpha testing happens
  55650. */
  55651. alphaCutOff: number;
  55652. /**
  55653. * Create a new AlphaTestBlock
  55654. * @param name defines the block name
  55655. */
  55656. constructor(name: string);
  55657. /**
  55658. * Gets the current class name
  55659. * @returns the class name
  55660. */
  55661. getClassName(): string;
  55662. /**
  55663. * Gets the color input component
  55664. */
  55665. readonly color: NodeMaterialConnectionPoint;
  55666. /**
  55667. * Gets the alpha input component
  55668. */
  55669. readonly alpha: NodeMaterialConnectionPoint;
  55670. protected _buildBlock(state: NodeMaterialBuildState): this;
  55671. protected _dumpPropertiesCode(): string;
  55672. serialize(): any;
  55673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55674. }
  55675. }
  55676. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55681. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55682. import { Effect } from "babylonjs/Materials/effect";
  55683. import { Mesh } from "babylonjs/Meshes/mesh";
  55684. /**
  55685. * Block used to add image processing support to fragment shader
  55686. */
  55687. export class ImageProcessingBlock extends NodeMaterialBlock {
  55688. /**
  55689. * Create a new ImageProcessingBlock
  55690. * @param name defines the block name
  55691. */
  55692. constructor(name: string);
  55693. /**
  55694. * Gets the current class name
  55695. * @returns the class name
  55696. */
  55697. getClassName(): string;
  55698. /**
  55699. * Gets the color input component
  55700. */
  55701. readonly color: NodeMaterialConnectionPoint;
  55702. /**
  55703. * Gets the output component
  55704. */
  55705. readonly output: NodeMaterialConnectionPoint;
  55706. /**
  55707. * Initialize the block and prepare the context for build
  55708. * @param state defines the state that will be used for the build
  55709. */
  55710. initialize(state: NodeMaterialBuildState): void;
  55711. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55713. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55714. protected _buildBlock(state: NodeMaterialBuildState): this;
  55715. }
  55716. }
  55717. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55718. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55719. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55720. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55721. }
  55722. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55725. import { Mesh } from "babylonjs/Meshes/mesh";
  55726. import { Effect } from "babylonjs/Materials/effect";
  55727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55729. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55730. /**
  55731. * Block used to add support for scene fog
  55732. */
  55733. export class FogBlock extends NodeMaterialBlock {
  55734. private _fogDistanceName;
  55735. private _fogParameters;
  55736. /**
  55737. * Create a new FogBlock
  55738. * @param name defines the block name
  55739. */
  55740. constructor(name: string);
  55741. /**
  55742. * Gets the current class name
  55743. * @returns the class name
  55744. */
  55745. getClassName(): string;
  55746. /**
  55747. * Gets the world position input component
  55748. */
  55749. readonly worldPosition: NodeMaterialConnectionPoint;
  55750. /**
  55751. * Gets the view input component
  55752. */
  55753. readonly view: NodeMaterialConnectionPoint;
  55754. /**
  55755. * Gets the color input component
  55756. */
  55757. readonly input: NodeMaterialConnectionPoint;
  55758. /**
  55759. * Gets the fog color input component
  55760. */
  55761. readonly fogColor: NodeMaterialConnectionPoint;
  55762. /**
  55763. * Gets the output component
  55764. */
  55765. readonly output: NodeMaterialConnectionPoint;
  55766. autoConfigure(material: NodeMaterial): void;
  55767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55769. protected _buildBlock(state: NodeMaterialBuildState): this;
  55770. }
  55771. }
  55772. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55778. import { Effect } from "babylonjs/Materials/effect";
  55779. import { Mesh } from "babylonjs/Meshes/mesh";
  55780. import { Light } from "babylonjs/Lights/light";
  55781. import { Nullable } from "babylonjs/types";
  55782. import { Scene } from "babylonjs/scene";
  55783. /**
  55784. * Block used to add light in the fragment shader
  55785. */
  55786. export class LightBlock extends NodeMaterialBlock {
  55787. private _lightId;
  55788. /**
  55789. * Gets or sets the light associated with this block
  55790. */
  55791. light: Nullable<Light>;
  55792. /**
  55793. * Create a new LightBlock
  55794. * @param name defines the block name
  55795. */
  55796. constructor(name: string);
  55797. /**
  55798. * Gets the current class name
  55799. * @returns the class name
  55800. */
  55801. getClassName(): string;
  55802. /**
  55803. * Gets the world position input component
  55804. */
  55805. readonly worldPosition: NodeMaterialConnectionPoint;
  55806. /**
  55807. * Gets the world normal input component
  55808. */
  55809. readonly worldNormal: NodeMaterialConnectionPoint;
  55810. /**
  55811. * Gets the camera (or eye) position component
  55812. */
  55813. readonly cameraPosition: NodeMaterialConnectionPoint;
  55814. /**
  55815. * Gets the diffuse output component
  55816. */
  55817. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55818. /**
  55819. * Gets the specular output component
  55820. */
  55821. readonly specularOutput: NodeMaterialConnectionPoint;
  55822. autoConfigure(material: NodeMaterial): void;
  55823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55824. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55826. private _injectVertexCode;
  55827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55828. serialize(): any;
  55829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55830. }
  55831. }
  55832. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55833. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55834. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55835. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55836. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55837. }
  55838. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55839. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55840. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55841. }
  55842. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55846. /**
  55847. * Block used to multiply 2 values
  55848. */
  55849. export class MultiplyBlock extends NodeMaterialBlock {
  55850. /**
  55851. * Creates a new MultiplyBlock
  55852. * @param name defines the block name
  55853. */
  55854. constructor(name: string);
  55855. /**
  55856. * Gets the current class name
  55857. * @returns the class name
  55858. */
  55859. getClassName(): string;
  55860. /**
  55861. * Gets the left operand input component
  55862. */
  55863. readonly left: NodeMaterialConnectionPoint;
  55864. /**
  55865. * Gets the right operand input component
  55866. */
  55867. readonly right: NodeMaterialConnectionPoint;
  55868. /**
  55869. * Gets the output component
  55870. */
  55871. readonly output: NodeMaterialConnectionPoint;
  55872. protected _buildBlock(state: NodeMaterialBuildState): this;
  55873. }
  55874. }
  55875. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55879. /**
  55880. * Block used to add 2 vectors
  55881. */
  55882. export class AddBlock extends NodeMaterialBlock {
  55883. /**
  55884. * Creates a new AddBlock
  55885. * @param name defines the block name
  55886. */
  55887. constructor(name: string);
  55888. /**
  55889. * Gets the current class name
  55890. * @returns the class name
  55891. */
  55892. getClassName(): string;
  55893. /**
  55894. * Gets the left operand input component
  55895. */
  55896. readonly left: NodeMaterialConnectionPoint;
  55897. /**
  55898. * Gets the right operand input component
  55899. */
  55900. readonly right: NodeMaterialConnectionPoint;
  55901. /**
  55902. * Gets the output component
  55903. */
  55904. readonly output: NodeMaterialConnectionPoint;
  55905. protected _buildBlock(state: NodeMaterialBuildState): this;
  55906. }
  55907. }
  55908. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55912. /**
  55913. * Block used to scale a vector by a float
  55914. */
  55915. export class ScaleBlock extends NodeMaterialBlock {
  55916. /**
  55917. * Creates a new ScaleBlock
  55918. * @param name defines the block name
  55919. */
  55920. constructor(name: string);
  55921. /**
  55922. * Gets the current class name
  55923. * @returns the class name
  55924. */
  55925. getClassName(): string;
  55926. /**
  55927. * Gets the input component
  55928. */
  55929. readonly input: NodeMaterialConnectionPoint;
  55930. /**
  55931. * Gets the factor input component
  55932. */
  55933. readonly factor: NodeMaterialConnectionPoint;
  55934. /**
  55935. * Gets the output component
  55936. */
  55937. readonly output: NodeMaterialConnectionPoint;
  55938. protected _buildBlock(state: NodeMaterialBuildState): this;
  55939. }
  55940. }
  55941. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55945. import { Scene } from "babylonjs/scene";
  55946. /**
  55947. * Block used to clamp a float
  55948. */
  55949. export class ClampBlock extends NodeMaterialBlock {
  55950. /** Gets or sets the minimum range */
  55951. minimum: number;
  55952. /** Gets or sets the maximum range */
  55953. maximum: number;
  55954. /**
  55955. * Creates a new ClampBlock
  55956. * @param name defines the block name
  55957. */
  55958. constructor(name: string);
  55959. /**
  55960. * Gets the current class name
  55961. * @returns the class name
  55962. */
  55963. getClassName(): string;
  55964. /**
  55965. * Gets the value input component
  55966. */
  55967. readonly value: NodeMaterialConnectionPoint;
  55968. /**
  55969. * Gets the output component
  55970. */
  55971. readonly output: NodeMaterialConnectionPoint;
  55972. protected _buildBlock(state: NodeMaterialBuildState): this;
  55973. protected _dumpPropertiesCode(): string;
  55974. serialize(): any;
  55975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55976. }
  55977. }
  55978. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55982. /**
  55983. * Block used to apply a cross product between 2 vectors
  55984. */
  55985. export class CrossBlock extends NodeMaterialBlock {
  55986. /**
  55987. * Creates a new CrossBlock
  55988. * @param name defines the block name
  55989. */
  55990. constructor(name: string);
  55991. /**
  55992. * Gets the current class name
  55993. * @returns the class name
  55994. */
  55995. getClassName(): string;
  55996. /**
  55997. * Gets the left operand input component
  55998. */
  55999. readonly left: NodeMaterialConnectionPoint;
  56000. /**
  56001. * Gets the right operand input component
  56002. */
  56003. readonly right: NodeMaterialConnectionPoint;
  56004. /**
  56005. * Gets the output component
  56006. */
  56007. readonly output: NodeMaterialConnectionPoint;
  56008. protected _buildBlock(state: NodeMaterialBuildState): this;
  56009. }
  56010. }
  56011. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56015. /**
  56016. * Block used to apply a dot product between 2 vectors
  56017. */
  56018. export class DotBlock extends NodeMaterialBlock {
  56019. /**
  56020. * Creates a new DotBlock
  56021. * @param name defines the block name
  56022. */
  56023. constructor(name: string);
  56024. /**
  56025. * Gets the current class name
  56026. * @returns the class name
  56027. */
  56028. getClassName(): string;
  56029. /**
  56030. * Gets the left operand input component
  56031. */
  56032. readonly left: NodeMaterialConnectionPoint;
  56033. /**
  56034. * Gets the right operand input component
  56035. */
  56036. readonly right: NodeMaterialConnectionPoint;
  56037. /**
  56038. * Gets the output component
  56039. */
  56040. readonly output: NodeMaterialConnectionPoint;
  56041. protected _buildBlock(state: NodeMaterialBuildState): this;
  56042. }
  56043. }
  56044. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56048. import { Vector2 } from "babylonjs/Maths/math.vector";
  56049. import { Scene } from "babylonjs/scene";
  56050. /**
  56051. * Block used to remap a float from a range to a new one
  56052. */
  56053. export class RemapBlock extends NodeMaterialBlock {
  56054. /**
  56055. * Gets or sets the source range
  56056. */
  56057. sourceRange: Vector2;
  56058. /**
  56059. * Gets or sets the target range
  56060. */
  56061. targetRange: Vector2;
  56062. /**
  56063. * Creates a new RemapBlock
  56064. * @param name defines the block name
  56065. */
  56066. constructor(name: string);
  56067. /**
  56068. * Gets the current class name
  56069. * @returns the class name
  56070. */
  56071. getClassName(): string;
  56072. /**
  56073. * Gets the input component
  56074. */
  56075. readonly input: NodeMaterialConnectionPoint;
  56076. /**
  56077. * Gets the output component
  56078. */
  56079. readonly output: NodeMaterialConnectionPoint;
  56080. protected _buildBlock(state: NodeMaterialBuildState): this;
  56081. protected _dumpPropertiesCode(): string;
  56082. serialize(): any;
  56083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56084. }
  56085. }
  56086. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56090. /**
  56091. * Block used to normalize a vector
  56092. */
  56093. export class NormalizeBlock extends NodeMaterialBlock {
  56094. /**
  56095. * Creates a new NormalizeBlock
  56096. * @param name defines the block name
  56097. */
  56098. constructor(name: string);
  56099. /**
  56100. * Gets the current class name
  56101. * @returns the class name
  56102. */
  56103. getClassName(): string;
  56104. /**
  56105. * Gets the input component
  56106. */
  56107. readonly input: NodeMaterialConnectionPoint;
  56108. /**
  56109. * Gets the output component
  56110. */
  56111. readonly output: NodeMaterialConnectionPoint;
  56112. protected _buildBlock(state: NodeMaterialBuildState): this;
  56113. }
  56114. }
  56115. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56119. /**
  56120. * Operations supported by the Trigonometry block
  56121. */
  56122. export enum TrigonometryBlockOperations {
  56123. /** Cos */
  56124. Cos = 0,
  56125. /** Sin */
  56126. Sin = 1,
  56127. /** Abs */
  56128. Abs = 2,
  56129. /** Exp */
  56130. Exp = 3,
  56131. /** Exp2 */
  56132. Exp2 = 4,
  56133. /** Round */
  56134. Round = 5,
  56135. /** Floor */
  56136. Floor = 6,
  56137. /** Ceiling */
  56138. Ceiling = 7
  56139. }
  56140. /**
  56141. * Block used to apply trigonometry operation to floats
  56142. */
  56143. export class TrigonometryBlock extends NodeMaterialBlock {
  56144. /**
  56145. * Gets or sets the operation applied by the block
  56146. */
  56147. operation: TrigonometryBlockOperations;
  56148. /**
  56149. * Creates a new TrigonometryBlock
  56150. * @param name defines the block name
  56151. */
  56152. constructor(name: string);
  56153. /**
  56154. * Gets the current class name
  56155. * @returns the class name
  56156. */
  56157. getClassName(): string;
  56158. /**
  56159. * Gets the input component
  56160. */
  56161. readonly input: NodeMaterialConnectionPoint;
  56162. /**
  56163. * Gets the output component
  56164. */
  56165. readonly output: NodeMaterialConnectionPoint;
  56166. protected _buildBlock(state: NodeMaterialBuildState): this;
  56167. }
  56168. }
  56169. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56173. /**
  56174. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56175. */
  56176. export class ColorMergerBlock extends NodeMaterialBlock {
  56177. /**
  56178. * Create a new ColorMergerBlock
  56179. * @param name defines the block name
  56180. */
  56181. constructor(name: string);
  56182. /**
  56183. * Gets the current class name
  56184. * @returns the class name
  56185. */
  56186. getClassName(): string;
  56187. /**
  56188. * Gets the r component (input)
  56189. */
  56190. readonly r: NodeMaterialConnectionPoint;
  56191. /**
  56192. * Gets the g component (input)
  56193. */
  56194. readonly g: NodeMaterialConnectionPoint;
  56195. /**
  56196. * Gets the b component (input)
  56197. */
  56198. readonly b: NodeMaterialConnectionPoint;
  56199. /**
  56200. * Gets the a component (input)
  56201. */
  56202. readonly a: NodeMaterialConnectionPoint;
  56203. /**
  56204. * Gets the rgba component (output)
  56205. */
  56206. readonly rgba: NodeMaterialConnectionPoint;
  56207. /**
  56208. * Gets the rgb component (output)
  56209. */
  56210. readonly rgb: NodeMaterialConnectionPoint;
  56211. protected _buildBlock(state: NodeMaterialBuildState): this;
  56212. }
  56213. }
  56214. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56218. /**
  56219. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56220. */
  56221. export class VectorMergerBlock extends NodeMaterialBlock {
  56222. /**
  56223. * Create a new VectorMergerBlock
  56224. * @param name defines the block name
  56225. */
  56226. constructor(name: string);
  56227. /**
  56228. * Gets the current class name
  56229. * @returns the class name
  56230. */
  56231. getClassName(): string;
  56232. /**
  56233. * Gets the x component (input)
  56234. */
  56235. readonly x: NodeMaterialConnectionPoint;
  56236. /**
  56237. * Gets the y component (input)
  56238. */
  56239. readonly y: NodeMaterialConnectionPoint;
  56240. /**
  56241. * Gets the z component (input)
  56242. */
  56243. readonly z: NodeMaterialConnectionPoint;
  56244. /**
  56245. * Gets the w component (input)
  56246. */
  56247. readonly w: NodeMaterialConnectionPoint;
  56248. /**
  56249. * Gets the xyzw component (output)
  56250. */
  56251. readonly xyzw: NodeMaterialConnectionPoint;
  56252. /**
  56253. * Gets the xyz component (output)
  56254. */
  56255. readonly xyz: NodeMaterialConnectionPoint;
  56256. /**
  56257. * Gets the xy component (output)
  56258. */
  56259. readonly xy: NodeMaterialConnectionPoint;
  56260. protected _buildBlock(state: NodeMaterialBuildState): this;
  56261. }
  56262. }
  56263. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56267. /**
  56268. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56269. */
  56270. export class ColorSplitterBlock extends NodeMaterialBlock {
  56271. /**
  56272. * Create a new ColorSplitterBlock
  56273. * @param name defines the block name
  56274. */
  56275. constructor(name: string);
  56276. /**
  56277. * Gets the current class name
  56278. * @returns the class name
  56279. */
  56280. getClassName(): string;
  56281. /**
  56282. * Gets the rgba component (input)
  56283. */
  56284. readonly rgba: NodeMaterialConnectionPoint;
  56285. /**
  56286. * Gets the rgb component (input)
  56287. */
  56288. readonly rgbIn: NodeMaterialConnectionPoint;
  56289. /**
  56290. * Gets the rgb component (output)
  56291. */
  56292. readonly rgbOut: NodeMaterialConnectionPoint;
  56293. /**
  56294. * Gets the r component (output)
  56295. */
  56296. readonly r: NodeMaterialConnectionPoint;
  56297. /**
  56298. * Gets the g component (output)
  56299. */
  56300. readonly g: NodeMaterialConnectionPoint;
  56301. /**
  56302. * Gets the b component (output)
  56303. */
  56304. readonly b: NodeMaterialConnectionPoint;
  56305. /**
  56306. * Gets the a component (output)
  56307. */
  56308. readonly a: NodeMaterialConnectionPoint;
  56309. protected _inputRename(name: string): string;
  56310. protected _outputRename(name: string): string;
  56311. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56312. }
  56313. }
  56314. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56318. /**
  56319. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56320. */
  56321. export class VectorSplitterBlock extends NodeMaterialBlock {
  56322. /**
  56323. * Create a new VectorSplitterBlock
  56324. * @param name defines the block name
  56325. */
  56326. constructor(name: string);
  56327. /**
  56328. * Gets the current class name
  56329. * @returns the class name
  56330. */
  56331. getClassName(): string;
  56332. /**
  56333. * Gets the xyzw component (input)
  56334. */
  56335. readonly xyzw: NodeMaterialConnectionPoint;
  56336. /**
  56337. * Gets the xyz component (input)
  56338. */
  56339. readonly xyzIn: NodeMaterialConnectionPoint;
  56340. /**
  56341. * Gets the xy component (input)
  56342. */
  56343. readonly xyIn: NodeMaterialConnectionPoint;
  56344. /**
  56345. * Gets the xyz component (output)
  56346. */
  56347. readonly xyzOut: NodeMaterialConnectionPoint;
  56348. /**
  56349. * Gets the xy component (output)
  56350. */
  56351. readonly xyOut: NodeMaterialConnectionPoint;
  56352. /**
  56353. * Gets the x component (output)
  56354. */
  56355. readonly x: NodeMaterialConnectionPoint;
  56356. /**
  56357. * Gets the y component (output)
  56358. */
  56359. readonly y: NodeMaterialConnectionPoint;
  56360. /**
  56361. * Gets the z component (output)
  56362. */
  56363. readonly z: NodeMaterialConnectionPoint;
  56364. /**
  56365. * Gets the w component (output)
  56366. */
  56367. readonly w: NodeMaterialConnectionPoint;
  56368. protected _inputRename(name: string): string;
  56369. protected _outputRename(name: string): string;
  56370. protected _buildBlock(state: NodeMaterialBuildState): this;
  56371. }
  56372. }
  56373. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56377. /**
  56378. * Block used to lerp 2 values
  56379. */
  56380. export class LerpBlock extends NodeMaterialBlock {
  56381. /**
  56382. * Creates a new LerpBlock
  56383. * @param name defines the block name
  56384. */
  56385. constructor(name: string);
  56386. /**
  56387. * Gets the current class name
  56388. * @returns the class name
  56389. */
  56390. getClassName(): string;
  56391. /**
  56392. * Gets the left operand input component
  56393. */
  56394. readonly left: NodeMaterialConnectionPoint;
  56395. /**
  56396. * Gets the right operand input component
  56397. */
  56398. readonly right: NodeMaterialConnectionPoint;
  56399. /**
  56400. * Gets the gradient operand input component
  56401. */
  56402. readonly gradient: NodeMaterialConnectionPoint;
  56403. /**
  56404. * Gets the output component
  56405. */
  56406. readonly output: NodeMaterialConnectionPoint;
  56407. protected _buildBlock(state: NodeMaterialBuildState): this;
  56408. }
  56409. }
  56410. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56414. /**
  56415. * Block used to divide 2 vectors
  56416. */
  56417. export class DivideBlock extends NodeMaterialBlock {
  56418. /**
  56419. * Creates a new DivideBlock
  56420. * @param name defines the block name
  56421. */
  56422. constructor(name: string);
  56423. /**
  56424. * Gets the current class name
  56425. * @returns the class name
  56426. */
  56427. getClassName(): string;
  56428. /**
  56429. * Gets the left operand input component
  56430. */
  56431. readonly left: NodeMaterialConnectionPoint;
  56432. /**
  56433. * Gets the right operand input component
  56434. */
  56435. readonly right: NodeMaterialConnectionPoint;
  56436. /**
  56437. * Gets the output component
  56438. */
  56439. readonly output: NodeMaterialConnectionPoint;
  56440. protected _buildBlock(state: NodeMaterialBuildState): this;
  56441. }
  56442. }
  56443. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56447. /**
  56448. * Block used to subtract 2 vectors
  56449. */
  56450. export class SubtractBlock extends NodeMaterialBlock {
  56451. /**
  56452. * Creates a new SubtractBlock
  56453. * @param name defines the block name
  56454. */
  56455. constructor(name: string);
  56456. /**
  56457. * Gets the current class name
  56458. * @returns the class name
  56459. */
  56460. getClassName(): string;
  56461. /**
  56462. * Gets the left operand input component
  56463. */
  56464. readonly left: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the right operand input component
  56467. */
  56468. readonly right: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the output component
  56471. */
  56472. readonly output: NodeMaterialConnectionPoint;
  56473. protected _buildBlock(state: NodeMaterialBuildState): this;
  56474. }
  56475. }
  56476. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56480. /**
  56481. * Block used to step a value
  56482. */
  56483. export class StepBlock extends NodeMaterialBlock {
  56484. /**
  56485. * Creates a new AddBlock
  56486. * @param name defines the block name
  56487. */
  56488. constructor(name: string);
  56489. /**
  56490. * Gets the current class name
  56491. * @returns the class name
  56492. */
  56493. getClassName(): string;
  56494. /**
  56495. * Gets the value operand input component
  56496. */
  56497. readonly value: NodeMaterialConnectionPoint;
  56498. /**
  56499. * Gets the edge operand input component
  56500. */
  56501. readonly edge: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the output component
  56504. */
  56505. readonly output: NodeMaterialConnectionPoint;
  56506. protected _buildBlock(state: NodeMaterialBuildState): this;
  56507. }
  56508. }
  56509. declare module "babylonjs/Materials/Node/Blocks/oppositeBlock" {
  56510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56513. /**
  56514. * Block used to get the opposite of a value
  56515. */
  56516. export class OppositeBlock extends NodeMaterialBlock {
  56517. /**
  56518. * Creates a new OppositeBlock
  56519. * @param name defines the block name
  56520. */
  56521. constructor(name: string);
  56522. /**
  56523. * Gets the current class name
  56524. * @returns the class name
  56525. */
  56526. getClassName(): string;
  56527. /**
  56528. * Gets the input component
  56529. */
  56530. readonly input: NodeMaterialConnectionPoint;
  56531. /**
  56532. * Gets the output component
  56533. */
  56534. readonly output: NodeMaterialConnectionPoint;
  56535. protected _buildBlock(state: NodeMaterialBuildState): this;
  56536. }
  56537. }
  56538. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  56539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56542. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56543. /**
  56544. * Block used to get the view direction
  56545. */
  56546. export class ViewDirectionBlock extends NodeMaterialBlock {
  56547. /**
  56548. * Creates a new ViewDirectionBlock
  56549. * @param name defines the block name
  56550. */
  56551. constructor(name: string);
  56552. /**
  56553. * Gets the current class name
  56554. * @returns the class name
  56555. */
  56556. getClassName(): string;
  56557. /**
  56558. * Gets the world position component
  56559. */
  56560. readonly worldPosition: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the camera position component
  56563. */
  56564. readonly cameraPosition: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the output component
  56567. */
  56568. readonly output: NodeMaterialConnectionPoint;
  56569. autoConfigure(material: NodeMaterial): void;
  56570. protected _buildBlock(state: NodeMaterialBuildState): this;
  56571. }
  56572. }
  56573. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  56574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56577. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56578. /**
  56579. * Block used to compute fresnel value
  56580. */
  56581. export class FresnelBlock extends NodeMaterialBlock {
  56582. /**
  56583. * Create a new FresnelBlock
  56584. * @param name defines the block name
  56585. */
  56586. constructor(name: string);
  56587. /**
  56588. * Gets the current class name
  56589. * @returns the class name
  56590. */
  56591. getClassName(): string;
  56592. /**
  56593. * Gets the world normal input component
  56594. */
  56595. readonly worldNormal: NodeMaterialConnectionPoint;
  56596. /**
  56597. * Gets the view direction input component
  56598. */
  56599. readonly viewDirection: NodeMaterialConnectionPoint;
  56600. /**
  56601. * Gets the bias input component
  56602. */
  56603. readonly bias: NodeMaterialConnectionPoint;
  56604. /**
  56605. * Gets the camera (or eye) position component
  56606. */
  56607. readonly power: NodeMaterialConnectionPoint;
  56608. /**
  56609. * Gets the fresnel output component
  56610. */
  56611. readonly fresnel: NodeMaterialConnectionPoint;
  56612. autoConfigure(material: NodeMaterial): void;
  56613. protected _buildBlock(state: NodeMaterialBuildState): this;
  56614. }
  56615. }
  56616. declare module "babylonjs/Materials/Node/Blocks/index" {
  56617. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56618. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56619. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56620. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56621. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56622. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56623. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56624. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56625. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56626. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56627. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56628. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56629. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56630. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56631. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  56632. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  56633. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  56634. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  56635. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  56636. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  56637. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  56638. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  56639. export * from "babylonjs/Materials/Node/Blocks/oppositeBlock";
  56640. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  56641. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  56642. }
  56643. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56644. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56645. }
  56646. declare module "babylonjs/Materials/Node/index" {
  56647. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56648. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56649. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56650. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56651. export * from "babylonjs/Materials/Node/nodeMaterial";
  56652. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56653. export * from "babylonjs/Materials/Node/Blocks/index";
  56654. export * from "babylonjs/Materials/Node/Optimizers/index";
  56655. }
  56656. declare module "babylonjs/Materials/effectRenderer" {
  56657. import { Nullable } from "babylonjs/types";
  56658. import { Texture } from "babylonjs/Materials/Textures/texture";
  56659. import { Engine } from "babylonjs/Engines/engine";
  56660. import { Viewport } from "babylonjs/Maths/math.viewport";
  56661. import { Observable } from "babylonjs/Misc/observable";
  56662. import { Effect } from "babylonjs/Materials/effect";
  56663. import "babylonjs/Shaders/postprocess.vertex";
  56664. /**
  56665. * Effect Render Options
  56666. */
  56667. export interface IEffectRendererOptions {
  56668. /**
  56669. * Defines the vertices positions.
  56670. */
  56671. positions?: number[];
  56672. /**
  56673. * Defines the indices.
  56674. */
  56675. indices?: number[];
  56676. }
  56677. /**
  56678. * Helper class to render one or more effects
  56679. */
  56680. export class EffectRenderer {
  56681. private engine;
  56682. private static _DefaultOptions;
  56683. private _vertexBuffers;
  56684. private _indexBuffer;
  56685. private _ringBufferIndex;
  56686. private _ringScreenBuffer;
  56687. private _fullscreenViewport;
  56688. private _getNextFrameBuffer;
  56689. /**
  56690. * Creates an effect renderer
  56691. * @param engine the engine to use for rendering
  56692. * @param options defines the options of the effect renderer
  56693. */
  56694. constructor(engine: Engine, options?: IEffectRendererOptions);
  56695. /**
  56696. * Sets the current viewport in normalized coordinates 0-1
  56697. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56698. */
  56699. setViewport(viewport?: Viewport): void;
  56700. /**
  56701. * Sets the current effect wrapper to use during draw.
  56702. * The effect needs to be ready before calling this api.
  56703. * This also sets the default full screen position attribute.
  56704. * @param effectWrapper Defines the effect to draw with
  56705. */
  56706. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56707. /**
  56708. * Draws a full screen quad.
  56709. */
  56710. draw(): void;
  56711. /**
  56712. * renders one or more effects to a specified texture
  56713. * @param effectWrappers list of effects to renderer
  56714. * @param outputTexture texture to draw to, if null it will render to the screen
  56715. */
  56716. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56717. /**
  56718. * Disposes of the effect renderer
  56719. */
  56720. dispose(): void;
  56721. }
  56722. /**
  56723. * Options to create an EffectWrapper
  56724. */
  56725. interface EffectWrapperCreationOptions {
  56726. /**
  56727. * Engine to use to create the effect
  56728. */
  56729. engine: Engine;
  56730. /**
  56731. * Fragment shader for the effect
  56732. */
  56733. fragmentShader: string;
  56734. /**
  56735. * Vertex shader for the effect
  56736. */
  56737. vertexShader?: string;
  56738. /**
  56739. * Attributes to use in the shader
  56740. */
  56741. attributeNames?: Array<string>;
  56742. /**
  56743. * Uniforms to use in the shader
  56744. */
  56745. uniformNames?: Array<string>;
  56746. /**
  56747. * Texture sampler names to use in the shader
  56748. */
  56749. samplerNames?: Array<string>;
  56750. /**
  56751. * The friendly name of the effect displayed in Spector.
  56752. */
  56753. name?: string;
  56754. }
  56755. /**
  56756. * Wraps an effect to be used for rendering
  56757. */
  56758. export class EffectWrapper {
  56759. /**
  56760. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56761. */
  56762. onApplyObservable: Observable<{}>;
  56763. /**
  56764. * The underlying effect
  56765. */
  56766. effect: Effect;
  56767. /**
  56768. * Creates an effect to be renderer
  56769. * @param creationOptions options to create the effect
  56770. */
  56771. constructor(creationOptions: EffectWrapperCreationOptions);
  56772. /**
  56773. * Disposes of the effect wrapper
  56774. */
  56775. dispose(): void;
  56776. }
  56777. }
  56778. declare module "babylonjs/Materials/index" {
  56779. export * from "babylonjs/Materials/Background/index";
  56780. export * from "babylonjs/Materials/colorCurves";
  56781. export * from "babylonjs/Materials/effect";
  56782. export * from "babylonjs/Materials/fresnelParameters";
  56783. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56784. export * from "babylonjs/Materials/material";
  56785. export * from "babylonjs/Materials/materialDefines";
  56786. export * from "babylonjs/Materials/materialHelper";
  56787. export * from "babylonjs/Materials/multiMaterial";
  56788. export * from "babylonjs/Materials/PBR/index";
  56789. export * from "babylonjs/Materials/pushMaterial";
  56790. export * from "babylonjs/Materials/shaderMaterial";
  56791. export * from "babylonjs/Materials/standardMaterial";
  56792. export * from "babylonjs/Materials/Textures/index";
  56793. export * from "babylonjs/Materials/uniformBuffer";
  56794. export * from "babylonjs/Materials/materialFlags";
  56795. export * from "babylonjs/Materials/Node/index";
  56796. export * from "babylonjs/Materials/effectRenderer";
  56797. }
  56798. declare module "babylonjs/Maths/index" {
  56799. export * from "babylonjs/Maths/math.scalar";
  56800. export * from "babylonjs/Maths/math";
  56801. export * from "babylonjs/Maths/sphericalPolynomial";
  56802. }
  56803. declare module "babylonjs/Misc/workerPool" {
  56804. import { IDisposable } from "babylonjs/scene";
  56805. /**
  56806. * Helper class to push actions to a pool of workers.
  56807. */
  56808. export class WorkerPool implements IDisposable {
  56809. private _workerInfos;
  56810. private _pendingActions;
  56811. /**
  56812. * Constructor
  56813. * @param workers Array of workers to use for actions
  56814. */
  56815. constructor(workers: Array<Worker>);
  56816. /**
  56817. * Terminates all workers and clears any pending actions.
  56818. */
  56819. dispose(): void;
  56820. /**
  56821. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56822. * pended until a worker has completed its action.
  56823. * @param action The action to perform. Call onComplete when the action is complete.
  56824. */
  56825. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56826. private _execute;
  56827. }
  56828. }
  56829. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56830. import { IDisposable } from "babylonjs/scene";
  56831. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56832. /**
  56833. * Configuration for Draco compression
  56834. */
  56835. export interface IDracoCompressionConfiguration {
  56836. /**
  56837. * Configuration for the decoder.
  56838. */
  56839. decoder: {
  56840. /**
  56841. * The url to the WebAssembly module.
  56842. */
  56843. wasmUrl?: string;
  56844. /**
  56845. * The url to the WebAssembly binary.
  56846. */
  56847. wasmBinaryUrl?: string;
  56848. /**
  56849. * The url to the fallback JavaScript module.
  56850. */
  56851. fallbackUrl?: string;
  56852. };
  56853. }
  56854. /**
  56855. * Draco compression (https://google.github.io/draco/)
  56856. *
  56857. * This class wraps the Draco module.
  56858. *
  56859. * **Encoder**
  56860. *
  56861. * The encoder is not currently implemented.
  56862. *
  56863. * **Decoder**
  56864. *
  56865. * 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.
  56866. *
  56867. * To update the configuration, use the following code:
  56868. * ```javascript
  56869. * DracoCompression.Configuration = {
  56870. * decoder: {
  56871. * wasmUrl: "<url to the WebAssembly library>",
  56872. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56873. * fallbackUrl: "<url to the fallback JavaScript library>",
  56874. * }
  56875. * };
  56876. * ```
  56877. *
  56878. * 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.
  56879. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56880. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56881. *
  56882. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56883. * ```javascript
  56884. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56885. * ```
  56886. *
  56887. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56888. */
  56889. export class DracoCompression implements IDisposable {
  56890. private _workerPoolPromise?;
  56891. private _decoderModulePromise?;
  56892. /**
  56893. * The configuration. Defaults to the following urls:
  56894. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56895. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56896. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56897. */
  56898. static Configuration: IDracoCompressionConfiguration;
  56899. /**
  56900. * Returns true if the decoder configuration is available.
  56901. */
  56902. static readonly DecoderAvailable: boolean;
  56903. /**
  56904. * Default number of workers to create when creating the draco compression object.
  56905. */
  56906. static DefaultNumWorkers: number;
  56907. private static GetDefaultNumWorkers;
  56908. private static _Default;
  56909. /**
  56910. * Default instance for the draco compression object.
  56911. */
  56912. static readonly Default: DracoCompression;
  56913. /**
  56914. * Constructor
  56915. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56916. */
  56917. constructor(numWorkers?: number);
  56918. /**
  56919. * Stop all async operations and release resources.
  56920. */
  56921. dispose(): void;
  56922. /**
  56923. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56924. * @returns a promise that resolves when ready
  56925. */
  56926. whenReadyAsync(): Promise<void>;
  56927. /**
  56928. * Decode Draco compressed mesh data to vertex data.
  56929. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56930. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56931. * @returns A promise that resolves with the decoded vertex data
  56932. */
  56933. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56934. [kind: string]: number;
  56935. }): Promise<VertexData>;
  56936. }
  56937. }
  56938. declare module "babylonjs/Meshes/Compression/index" {
  56939. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56940. }
  56941. declare module "babylonjs/Meshes/csg" {
  56942. import { Nullable } from "babylonjs/types";
  56943. import { Scene } from "babylonjs/scene";
  56944. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56945. import { Mesh } from "babylonjs/Meshes/mesh";
  56946. import { Material } from "babylonjs/Materials/material";
  56947. /**
  56948. * Class for building Constructive Solid Geometry
  56949. */
  56950. export class CSG {
  56951. private polygons;
  56952. /**
  56953. * The world matrix
  56954. */
  56955. matrix: Matrix;
  56956. /**
  56957. * Stores the position
  56958. */
  56959. position: Vector3;
  56960. /**
  56961. * Stores the rotation
  56962. */
  56963. rotation: Vector3;
  56964. /**
  56965. * Stores the rotation quaternion
  56966. */
  56967. rotationQuaternion: Nullable<Quaternion>;
  56968. /**
  56969. * Stores the scaling vector
  56970. */
  56971. scaling: Vector3;
  56972. /**
  56973. * Convert the Mesh to CSG
  56974. * @param mesh The Mesh to convert to CSG
  56975. * @returns A new CSG from the Mesh
  56976. */
  56977. static FromMesh(mesh: Mesh): CSG;
  56978. /**
  56979. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56980. * @param polygons Polygons used to construct a CSG solid
  56981. */
  56982. private static FromPolygons;
  56983. /**
  56984. * Clones, or makes a deep copy, of the CSG
  56985. * @returns A new CSG
  56986. */
  56987. clone(): CSG;
  56988. /**
  56989. * Unions this CSG with another CSG
  56990. * @param csg The CSG to union against this CSG
  56991. * @returns The unioned CSG
  56992. */
  56993. union(csg: CSG): CSG;
  56994. /**
  56995. * Unions this CSG with another CSG in place
  56996. * @param csg The CSG to union against this CSG
  56997. */
  56998. unionInPlace(csg: CSG): void;
  56999. /**
  57000. * Subtracts this CSG with another CSG
  57001. * @param csg The CSG to subtract against this CSG
  57002. * @returns A new CSG
  57003. */
  57004. subtract(csg: CSG): CSG;
  57005. /**
  57006. * Subtracts this CSG with another CSG in place
  57007. * @param csg The CSG to subtact against this CSG
  57008. */
  57009. subtractInPlace(csg: CSG): void;
  57010. /**
  57011. * Intersect this CSG with another CSG
  57012. * @param csg The CSG to intersect against this CSG
  57013. * @returns A new CSG
  57014. */
  57015. intersect(csg: CSG): CSG;
  57016. /**
  57017. * Intersects this CSG with another CSG in place
  57018. * @param csg The CSG to intersect against this CSG
  57019. */
  57020. intersectInPlace(csg: CSG): void;
  57021. /**
  57022. * Return a new CSG solid with solid and empty space switched. This solid is
  57023. * not modified.
  57024. * @returns A new CSG solid with solid and empty space switched
  57025. */
  57026. inverse(): CSG;
  57027. /**
  57028. * Inverses the CSG in place
  57029. */
  57030. inverseInPlace(): void;
  57031. /**
  57032. * This is used to keep meshes transformations so they can be restored
  57033. * when we build back a Babylon Mesh
  57034. * NB : All CSG operations are performed in world coordinates
  57035. * @param csg The CSG to copy the transform attributes from
  57036. * @returns This CSG
  57037. */
  57038. copyTransformAttributes(csg: CSG): CSG;
  57039. /**
  57040. * Build Raw mesh from CSG
  57041. * Coordinates here are in world space
  57042. * @param name The name of the mesh geometry
  57043. * @param scene The Scene
  57044. * @param keepSubMeshes Specifies if the submeshes should be kept
  57045. * @returns A new Mesh
  57046. */
  57047. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57048. /**
  57049. * Build Mesh from CSG taking material and transforms into account
  57050. * @param name The name of the Mesh
  57051. * @param material The material of the Mesh
  57052. * @param scene The Scene
  57053. * @param keepSubMeshes Specifies if submeshes should be kept
  57054. * @returns The new Mesh
  57055. */
  57056. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57057. }
  57058. }
  57059. declare module "babylonjs/Meshes/trailMesh" {
  57060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57061. import { Mesh } from "babylonjs/Meshes/mesh";
  57062. import { Scene } from "babylonjs/scene";
  57063. /**
  57064. * Class used to create a trail following a mesh
  57065. */
  57066. export class TrailMesh extends Mesh {
  57067. private _generator;
  57068. private _autoStart;
  57069. private _running;
  57070. private _diameter;
  57071. private _length;
  57072. private _sectionPolygonPointsCount;
  57073. private _sectionVectors;
  57074. private _sectionNormalVectors;
  57075. private _beforeRenderObserver;
  57076. /**
  57077. * @constructor
  57078. * @param name The value used by scene.getMeshByName() to do a lookup.
  57079. * @param generator The mesh to generate a trail.
  57080. * @param scene The scene to add this mesh to.
  57081. * @param diameter Diameter of trailing mesh. Default is 1.
  57082. * @param length Length of trailing mesh. Default is 60.
  57083. * @param autoStart Automatically start trailing mesh. Default true.
  57084. */
  57085. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57086. /**
  57087. * "TrailMesh"
  57088. * @returns "TrailMesh"
  57089. */
  57090. getClassName(): string;
  57091. private _createMesh;
  57092. /**
  57093. * Start trailing mesh.
  57094. */
  57095. start(): void;
  57096. /**
  57097. * Stop trailing mesh.
  57098. */
  57099. stop(): void;
  57100. /**
  57101. * Update trailing mesh geometry.
  57102. */
  57103. update(): void;
  57104. /**
  57105. * Returns a new TrailMesh object.
  57106. * @param name is a string, the name given to the new mesh
  57107. * @param newGenerator use new generator object for cloned trail mesh
  57108. * @returns a new mesh
  57109. */
  57110. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57111. /**
  57112. * Serializes this trail mesh
  57113. * @param serializationObject object to write serialization to
  57114. */
  57115. serialize(serializationObject: any): void;
  57116. /**
  57117. * Parses a serialized trail mesh
  57118. * @param parsedMesh the serialized mesh
  57119. * @param scene the scene to create the trail mesh in
  57120. * @returns the created trail mesh
  57121. */
  57122. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57123. }
  57124. }
  57125. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57126. import { Nullable } from "babylonjs/types";
  57127. import { Scene } from "babylonjs/scene";
  57128. import { Vector4 } from "babylonjs/Maths/math.vector";
  57129. import { Color4 } from "babylonjs/Maths/math.color";
  57130. import { Mesh } from "babylonjs/Meshes/mesh";
  57131. /**
  57132. * Class containing static functions to help procedurally build meshes
  57133. */
  57134. export class TiledBoxBuilder {
  57135. /**
  57136. * Creates a box mesh
  57137. * 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)
  57138. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57142. * @param name defines the name of the mesh
  57143. * @param options defines the options used to create the mesh
  57144. * @param scene defines the hosting scene
  57145. * @returns the box mesh
  57146. */
  57147. static CreateTiledBox(name: string, options: {
  57148. pattern?: number;
  57149. width?: number;
  57150. height?: number;
  57151. depth?: number;
  57152. tileSize?: number;
  57153. tileWidth?: number;
  57154. tileHeight?: number;
  57155. alignHorizontal?: number;
  57156. alignVertical?: number;
  57157. faceUV?: Vector4[];
  57158. faceColors?: Color4[];
  57159. sideOrientation?: number;
  57160. updatable?: boolean;
  57161. }, scene?: Nullable<Scene>): Mesh;
  57162. }
  57163. }
  57164. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57165. import { Vector4 } from "babylonjs/Maths/math.vector";
  57166. import { Mesh } from "babylonjs/Meshes/mesh";
  57167. /**
  57168. * Class containing static functions to help procedurally build meshes
  57169. */
  57170. export class TorusKnotBuilder {
  57171. /**
  57172. * Creates a torus knot mesh
  57173. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57174. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57175. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57176. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57180. * @param name defines the name of the mesh
  57181. * @param options defines the options used to create the mesh
  57182. * @param scene defines the hosting scene
  57183. * @returns the torus knot mesh
  57184. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57185. */
  57186. static CreateTorusKnot(name: string, options: {
  57187. radius?: number;
  57188. tube?: number;
  57189. radialSegments?: number;
  57190. tubularSegments?: number;
  57191. p?: number;
  57192. q?: number;
  57193. updatable?: boolean;
  57194. sideOrientation?: number;
  57195. frontUVs?: Vector4;
  57196. backUVs?: Vector4;
  57197. }, scene: any): Mesh;
  57198. }
  57199. }
  57200. declare module "babylonjs/Meshes/polygonMesh" {
  57201. import { Scene } from "babylonjs/scene";
  57202. import { Vector2 } from "babylonjs/Maths/math.vector";
  57203. import { Mesh } from "babylonjs/Meshes/mesh";
  57204. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57205. import { Path2 } from "babylonjs/Maths/math.path";
  57206. /**
  57207. * Polygon
  57208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57209. */
  57210. export class Polygon {
  57211. /**
  57212. * Creates a rectangle
  57213. * @param xmin bottom X coord
  57214. * @param ymin bottom Y coord
  57215. * @param xmax top X coord
  57216. * @param ymax top Y coord
  57217. * @returns points that make the resulting rectation
  57218. */
  57219. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57220. /**
  57221. * Creates a circle
  57222. * @param radius radius of circle
  57223. * @param cx scale in x
  57224. * @param cy scale in y
  57225. * @param numberOfSides number of sides that make up the circle
  57226. * @returns points that make the resulting circle
  57227. */
  57228. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57229. /**
  57230. * Creates a polygon from input string
  57231. * @param input Input polygon data
  57232. * @returns the parsed points
  57233. */
  57234. static Parse(input: string): Vector2[];
  57235. /**
  57236. * Starts building a polygon from x and y coordinates
  57237. * @param x x coordinate
  57238. * @param y y coordinate
  57239. * @returns the started path2
  57240. */
  57241. static StartingAt(x: number, y: number): Path2;
  57242. }
  57243. /**
  57244. * Builds a polygon
  57245. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57246. */
  57247. export class PolygonMeshBuilder {
  57248. private _points;
  57249. private _outlinepoints;
  57250. private _holes;
  57251. private _name;
  57252. private _scene;
  57253. private _epoints;
  57254. private _eholes;
  57255. private _addToepoint;
  57256. /**
  57257. * Babylon reference to the earcut plugin.
  57258. */
  57259. bjsEarcut: any;
  57260. /**
  57261. * Creates a PolygonMeshBuilder
  57262. * @param name name of the builder
  57263. * @param contours Path of the polygon
  57264. * @param scene scene to add to when creating the mesh
  57265. * @param earcutInjection can be used to inject your own earcut reference
  57266. */
  57267. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57268. /**
  57269. * Adds a whole within the polygon
  57270. * @param hole Array of points defining the hole
  57271. * @returns this
  57272. */
  57273. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57274. /**
  57275. * Creates the polygon
  57276. * @param updatable If the mesh should be updatable
  57277. * @param depth The depth of the mesh created
  57278. * @returns the created mesh
  57279. */
  57280. build(updatable?: boolean, depth?: number): Mesh;
  57281. /**
  57282. * Creates the polygon
  57283. * @param depth The depth of the mesh created
  57284. * @returns the created VertexData
  57285. */
  57286. buildVertexData(depth?: number): VertexData;
  57287. /**
  57288. * Adds a side to the polygon
  57289. * @param positions points that make the polygon
  57290. * @param normals normals of the polygon
  57291. * @param uvs uvs of the polygon
  57292. * @param indices indices of the polygon
  57293. * @param bounds bounds of the polygon
  57294. * @param points points of the polygon
  57295. * @param depth depth of the polygon
  57296. * @param flip flip of the polygon
  57297. */
  57298. private addSide;
  57299. }
  57300. }
  57301. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57302. import { Scene } from "babylonjs/scene";
  57303. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57304. import { Color4 } from "babylonjs/Maths/math.color";
  57305. import { Mesh } from "babylonjs/Meshes/mesh";
  57306. import { Nullable } from "babylonjs/types";
  57307. /**
  57308. * Class containing static functions to help procedurally build meshes
  57309. */
  57310. export class PolygonBuilder {
  57311. /**
  57312. * Creates a polygon mesh
  57313. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57314. * * 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
  57315. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57318. * * Remember you can only change the shape positions, not their number when updating a polygon
  57319. * @param name defines the name of the mesh
  57320. * @param options defines the options used to create the mesh
  57321. * @param scene defines the hosting scene
  57322. * @param earcutInjection can be used to inject your own earcut reference
  57323. * @returns the polygon mesh
  57324. */
  57325. static CreatePolygon(name: string, options: {
  57326. shape: Vector3[];
  57327. holes?: Vector3[][];
  57328. depth?: number;
  57329. faceUV?: Vector4[];
  57330. faceColors?: Color4[];
  57331. updatable?: boolean;
  57332. sideOrientation?: number;
  57333. frontUVs?: Vector4;
  57334. backUVs?: Vector4;
  57335. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57336. /**
  57337. * Creates an extruded polygon mesh, with depth in the Y direction.
  57338. * * 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)
  57339. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57340. * @param name defines the name of the mesh
  57341. * @param options defines the options used to create the mesh
  57342. * @param scene defines the hosting scene
  57343. * @param earcutInjection can be used to inject your own earcut reference
  57344. * @returns the polygon mesh
  57345. */
  57346. static ExtrudePolygon(name: string, options: {
  57347. shape: Vector3[];
  57348. holes?: Vector3[][];
  57349. depth?: number;
  57350. faceUV?: Vector4[];
  57351. faceColors?: Color4[];
  57352. updatable?: boolean;
  57353. sideOrientation?: number;
  57354. frontUVs?: Vector4;
  57355. backUVs?: Vector4;
  57356. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57357. }
  57358. }
  57359. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57360. import { Scene } from "babylonjs/scene";
  57361. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57362. import { Mesh } from "babylonjs/Meshes/mesh";
  57363. import { Nullable } from "babylonjs/types";
  57364. /**
  57365. * Class containing static functions to help procedurally build meshes
  57366. */
  57367. export class LatheBuilder {
  57368. /**
  57369. * Creates lathe mesh.
  57370. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57371. * * 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
  57372. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57373. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57374. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57375. * * 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
  57376. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57377. * * 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
  57378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57380. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57382. * @param name defines the name of the mesh
  57383. * @param options defines the options used to create the mesh
  57384. * @param scene defines the hosting scene
  57385. * @returns the lathe mesh
  57386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57387. */
  57388. static CreateLathe(name: string, options: {
  57389. shape: Vector3[];
  57390. radius?: number;
  57391. tessellation?: number;
  57392. clip?: number;
  57393. arc?: number;
  57394. closed?: boolean;
  57395. updatable?: boolean;
  57396. sideOrientation?: number;
  57397. frontUVs?: Vector4;
  57398. backUVs?: Vector4;
  57399. cap?: number;
  57400. invertUV?: boolean;
  57401. }, scene?: Nullable<Scene>): Mesh;
  57402. }
  57403. }
  57404. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57405. import { Nullable } from "babylonjs/types";
  57406. import { Scene } from "babylonjs/scene";
  57407. import { Vector4 } from "babylonjs/Maths/math.vector";
  57408. import { Mesh } from "babylonjs/Meshes/mesh";
  57409. /**
  57410. * Class containing static functions to help procedurally build meshes
  57411. */
  57412. export class TiledPlaneBuilder {
  57413. /**
  57414. * Creates a tiled plane mesh
  57415. * * The parameter `pattern` will, depending on value, do nothing or
  57416. * * * flip (reflect about central vertical) alternate tiles across and up
  57417. * * * flip every tile on alternate rows
  57418. * * * rotate (180 degs) alternate tiles across and up
  57419. * * * rotate every tile on alternate rows
  57420. * * * flip and rotate alternate tiles across and up
  57421. * * * flip and rotate every tile on alternate rows
  57422. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57423. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57426. * * 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)
  57427. * * 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)
  57428. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57429. * @param name defines the name of the mesh
  57430. * @param options defines the options used to create the mesh
  57431. * @param scene defines the hosting scene
  57432. * @returns the box mesh
  57433. */
  57434. static CreateTiledPlane(name: string, options: {
  57435. pattern?: number;
  57436. tileSize?: number;
  57437. tileWidth?: number;
  57438. tileHeight?: number;
  57439. size?: number;
  57440. width?: number;
  57441. height?: number;
  57442. alignHorizontal?: number;
  57443. alignVertical?: number;
  57444. sideOrientation?: number;
  57445. frontUVs?: Vector4;
  57446. backUVs?: Vector4;
  57447. updatable?: boolean;
  57448. }, scene?: Nullable<Scene>): Mesh;
  57449. }
  57450. }
  57451. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57452. import { Nullable } from "babylonjs/types";
  57453. import { Scene } from "babylonjs/scene";
  57454. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57455. import { Mesh } from "babylonjs/Meshes/mesh";
  57456. /**
  57457. * Class containing static functions to help procedurally build meshes
  57458. */
  57459. export class TubeBuilder {
  57460. /**
  57461. * Creates a tube mesh.
  57462. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57463. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57464. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57465. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57466. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57467. * * 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)
  57468. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57469. * * 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
  57470. * * 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
  57471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57475. * @param name defines the name of the mesh
  57476. * @param options defines the options used to create the mesh
  57477. * @param scene defines the hosting scene
  57478. * @returns the tube mesh
  57479. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57480. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57481. */
  57482. static CreateTube(name: string, options: {
  57483. path: Vector3[];
  57484. radius?: number;
  57485. tessellation?: number;
  57486. radiusFunction?: {
  57487. (i: number, distance: number): number;
  57488. };
  57489. cap?: number;
  57490. arc?: number;
  57491. updatable?: boolean;
  57492. sideOrientation?: number;
  57493. frontUVs?: Vector4;
  57494. backUVs?: Vector4;
  57495. instance?: Mesh;
  57496. invertUV?: boolean;
  57497. }, scene?: Nullable<Scene>): Mesh;
  57498. }
  57499. }
  57500. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57501. import { Scene } from "babylonjs/scene";
  57502. import { Vector4 } from "babylonjs/Maths/math.vector";
  57503. import { Mesh } from "babylonjs/Meshes/mesh";
  57504. import { Nullable } from "babylonjs/types";
  57505. /**
  57506. * Class containing static functions to help procedurally build meshes
  57507. */
  57508. export class IcoSphereBuilder {
  57509. /**
  57510. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57511. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57512. * * 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`)
  57513. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57514. * * 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
  57515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57518. * @param name defines the name of the mesh
  57519. * @param options defines the options used to create the mesh
  57520. * @param scene defines the hosting scene
  57521. * @returns the icosahedron mesh
  57522. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57523. */
  57524. static CreateIcoSphere(name: string, options: {
  57525. radius?: number;
  57526. radiusX?: number;
  57527. radiusY?: number;
  57528. radiusZ?: number;
  57529. flat?: boolean;
  57530. subdivisions?: number;
  57531. sideOrientation?: number;
  57532. frontUVs?: Vector4;
  57533. backUVs?: Vector4;
  57534. updatable?: boolean;
  57535. }, scene?: Nullable<Scene>): Mesh;
  57536. }
  57537. }
  57538. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57539. import { Vector3 } from "babylonjs/Maths/math.vector";
  57540. import { Mesh } from "babylonjs/Meshes/mesh";
  57541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57542. /**
  57543. * Class containing static functions to help procedurally build meshes
  57544. */
  57545. export class DecalBuilder {
  57546. /**
  57547. * Creates a decal mesh.
  57548. * 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
  57549. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57550. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57551. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57552. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57553. * @param name defines the name of the mesh
  57554. * @param sourceMesh defines the mesh where the decal must be applied
  57555. * @param options defines the options used to create the mesh
  57556. * @param scene defines the hosting scene
  57557. * @returns the decal mesh
  57558. * @see https://doc.babylonjs.com/how_to/decals
  57559. */
  57560. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57561. position?: Vector3;
  57562. normal?: Vector3;
  57563. size?: Vector3;
  57564. angle?: number;
  57565. }): Mesh;
  57566. }
  57567. }
  57568. declare module "babylonjs/Meshes/meshBuilder" {
  57569. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57570. import { Nullable } from "babylonjs/types";
  57571. import { Scene } from "babylonjs/scene";
  57572. import { Mesh } from "babylonjs/Meshes/mesh";
  57573. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57574. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57576. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57577. import { Plane } from "babylonjs/Maths/math.plane";
  57578. /**
  57579. * Class containing static functions to help procedurally build meshes
  57580. */
  57581. export class MeshBuilder {
  57582. /**
  57583. * Creates a box mesh
  57584. * * The parameter `size` sets the size (float) of each box side (default 1)
  57585. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57586. * * 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)
  57587. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57591. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57592. * @param name defines the name of the mesh
  57593. * @param options defines the options used to create the mesh
  57594. * @param scene defines the hosting scene
  57595. * @returns the box mesh
  57596. */
  57597. static CreateBox(name: string, options: {
  57598. size?: number;
  57599. width?: number;
  57600. height?: number;
  57601. depth?: number;
  57602. faceUV?: Vector4[];
  57603. faceColors?: Color4[];
  57604. sideOrientation?: number;
  57605. frontUVs?: Vector4;
  57606. backUVs?: Vector4;
  57607. updatable?: boolean;
  57608. }, scene?: Nullable<Scene>): Mesh;
  57609. /**
  57610. * Creates a tiled box mesh
  57611. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57613. * @param name defines the name of the mesh
  57614. * @param options defines the options used to create the mesh
  57615. * @param scene defines the hosting scene
  57616. * @returns the tiled box mesh
  57617. */
  57618. static CreateTiledBox(name: string, options: {
  57619. pattern?: number;
  57620. size?: number;
  57621. width?: number;
  57622. height?: number;
  57623. depth: number;
  57624. tileSize?: number;
  57625. tileWidth?: number;
  57626. tileHeight?: number;
  57627. faceUV?: Vector4[];
  57628. faceColors?: Color4[];
  57629. alignHorizontal?: number;
  57630. alignVertical?: number;
  57631. sideOrientation?: number;
  57632. updatable?: boolean;
  57633. }, scene?: Nullable<Scene>): Mesh;
  57634. /**
  57635. * Creates a sphere mesh
  57636. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57637. * * 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`)
  57638. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57639. * * 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
  57640. * * 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)
  57641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57644. * @param name defines the name of the mesh
  57645. * @param options defines the options used to create the mesh
  57646. * @param scene defines the hosting scene
  57647. * @returns the sphere mesh
  57648. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57649. */
  57650. static CreateSphere(name: string, options: {
  57651. segments?: number;
  57652. diameter?: number;
  57653. diameterX?: number;
  57654. diameterY?: number;
  57655. diameterZ?: number;
  57656. arc?: number;
  57657. slice?: number;
  57658. sideOrientation?: number;
  57659. frontUVs?: Vector4;
  57660. backUVs?: Vector4;
  57661. updatable?: boolean;
  57662. }, scene?: Nullable<Scene>): Mesh;
  57663. /**
  57664. * Creates a plane polygonal mesh. By default, this is a disc
  57665. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57666. * * 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
  57667. * * 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
  57668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57671. * @param name defines the name of the mesh
  57672. * @param options defines the options used to create the mesh
  57673. * @param scene defines the hosting scene
  57674. * @returns the plane polygonal mesh
  57675. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57676. */
  57677. static CreateDisc(name: string, options: {
  57678. radius?: number;
  57679. tessellation?: number;
  57680. arc?: number;
  57681. updatable?: boolean;
  57682. sideOrientation?: number;
  57683. frontUVs?: Vector4;
  57684. backUVs?: Vector4;
  57685. }, scene?: Nullable<Scene>): Mesh;
  57686. /**
  57687. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57688. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57689. * * 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`)
  57690. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57691. * * 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
  57692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57695. * @param name defines the name of the mesh
  57696. * @param options defines the options used to create the mesh
  57697. * @param scene defines the hosting scene
  57698. * @returns the icosahedron mesh
  57699. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57700. */
  57701. static CreateIcoSphere(name: string, options: {
  57702. radius?: number;
  57703. radiusX?: number;
  57704. radiusY?: number;
  57705. radiusZ?: number;
  57706. flat?: boolean;
  57707. subdivisions?: number;
  57708. sideOrientation?: number;
  57709. frontUVs?: Vector4;
  57710. backUVs?: Vector4;
  57711. updatable?: boolean;
  57712. }, scene?: Nullable<Scene>): Mesh;
  57713. /**
  57714. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57715. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57716. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57717. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57718. * * 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
  57719. * * 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
  57720. * * 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
  57721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57724. * * 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
  57725. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57726. * * 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
  57727. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57729. * @param name defines the name of the mesh
  57730. * @param options defines the options used to create the mesh
  57731. * @param scene defines the hosting scene
  57732. * @returns the ribbon mesh
  57733. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57735. */
  57736. static CreateRibbon(name: string, options: {
  57737. pathArray: Vector3[][];
  57738. closeArray?: boolean;
  57739. closePath?: boolean;
  57740. offset?: number;
  57741. updatable?: boolean;
  57742. sideOrientation?: number;
  57743. frontUVs?: Vector4;
  57744. backUVs?: Vector4;
  57745. instance?: Mesh;
  57746. invertUV?: boolean;
  57747. uvs?: Vector2[];
  57748. colors?: Color4[];
  57749. }, scene?: Nullable<Scene>): Mesh;
  57750. /**
  57751. * Creates a cylinder or a cone mesh
  57752. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57753. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57754. * * 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.
  57755. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57756. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57757. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57758. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57759. * * 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).
  57760. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57761. * * 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).
  57762. * * 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
  57763. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57764. * * 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
  57765. * * 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.
  57766. * * If `enclose` is false, a ring surface is one element.
  57767. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57768. * * 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
  57769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57772. * @param name defines the name of the mesh
  57773. * @param options defines the options used to create the mesh
  57774. * @param scene defines the hosting scene
  57775. * @returns the cylinder mesh
  57776. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57777. */
  57778. static CreateCylinder(name: string, options: {
  57779. height?: number;
  57780. diameterTop?: number;
  57781. diameterBottom?: number;
  57782. diameter?: number;
  57783. tessellation?: number;
  57784. subdivisions?: number;
  57785. arc?: number;
  57786. faceColors?: Color4[];
  57787. faceUV?: Vector4[];
  57788. updatable?: boolean;
  57789. hasRings?: boolean;
  57790. enclose?: boolean;
  57791. cap?: number;
  57792. sideOrientation?: number;
  57793. frontUVs?: Vector4;
  57794. backUVs?: Vector4;
  57795. }, scene?: Nullable<Scene>): Mesh;
  57796. /**
  57797. * Creates a torus mesh
  57798. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57799. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57800. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57804. * @param name defines the name of the mesh
  57805. * @param options defines the options used to create the mesh
  57806. * @param scene defines the hosting scene
  57807. * @returns the torus mesh
  57808. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57809. */
  57810. static CreateTorus(name: string, options: {
  57811. diameter?: number;
  57812. thickness?: number;
  57813. tessellation?: number;
  57814. updatable?: boolean;
  57815. sideOrientation?: number;
  57816. frontUVs?: Vector4;
  57817. backUVs?: Vector4;
  57818. }, scene?: Nullable<Scene>): Mesh;
  57819. /**
  57820. * Creates a torus knot mesh
  57821. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57822. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57823. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57824. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57828. * @param name defines the name of the mesh
  57829. * @param options defines the options used to create the mesh
  57830. * @param scene defines the hosting scene
  57831. * @returns the torus knot mesh
  57832. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57833. */
  57834. static CreateTorusKnot(name: string, options: {
  57835. radius?: number;
  57836. tube?: number;
  57837. radialSegments?: number;
  57838. tubularSegments?: number;
  57839. p?: number;
  57840. q?: number;
  57841. updatable?: boolean;
  57842. sideOrientation?: number;
  57843. frontUVs?: Vector4;
  57844. backUVs?: Vector4;
  57845. }, scene?: Nullable<Scene>): Mesh;
  57846. /**
  57847. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57848. * * 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
  57849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57850. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57851. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57852. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57853. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57854. * * 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
  57855. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57858. * @param name defines the name of the new line system
  57859. * @param options defines the options used to create the line system
  57860. * @param scene defines the hosting scene
  57861. * @returns a new line system mesh
  57862. */
  57863. static CreateLineSystem(name: string, options: {
  57864. lines: Vector3[][];
  57865. updatable?: boolean;
  57866. instance?: Nullable<LinesMesh>;
  57867. colors?: Nullable<Color4[][]>;
  57868. useVertexAlpha?: boolean;
  57869. }, scene: Nullable<Scene>): LinesMesh;
  57870. /**
  57871. * Creates a line mesh
  57872. * 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
  57873. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57874. * * The parameter `points` is an array successive Vector3
  57875. * * 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
  57876. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57877. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57878. * * When updating an instance, remember that only point positions can change, not the number of points
  57879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57881. * @param name defines the name of the new line system
  57882. * @param options defines the options used to create the line system
  57883. * @param scene defines the hosting scene
  57884. * @returns a new line mesh
  57885. */
  57886. static CreateLines(name: string, options: {
  57887. points: Vector3[];
  57888. updatable?: boolean;
  57889. instance?: Nullable<LinesMesh>;
  57890. colors?: Color4[];
  57891. useVertexAlpha?: boolean;
  57892. }, scene?: Nullable<Scene>): LinesMesh;
  57893. /**
  57894. * Creates a dashed line mesh
  57895. * * 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
  57896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57897. * * The parameter `points` is an array successive Vector3
  57898. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57899. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57900. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57901. * * 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
  57902. * * When updating an instance, remember that only point positions can change, not the number of points
  57903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57904. * @param name defines the name of the mesh
  57905. * @param options defines the options used to create the mesh
  57906. * @param scene defines the hosting scene
  57907. * @returns the dashed line mesh
  57908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57909. */
  57910. static CreateDashedLines(name: string, options: {
  57911. points: Vector3[];
  57912. dashSize?: number;
  57913. gapSize?: number;
  57914. dashNb?: number;
  57915. updatable?: boolean;
  57916. instance?: LinesMesh;
  57917. }, scene?: Nullable<Scene>): LinesMesh;
  57918. /**
  57919. * 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.
  57920. * * 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.
  57921. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57922. * * 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.
  57923. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57924. * * 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
  57925. * * 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
  57926. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57931. * @param name defines the name of the mesh
  57932. * @param options defines the options used to create the mesh
  57933. * @param scene defines the hosting scene
  57934. * @returns the extruded shape mesh
  57935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57937. */
  57938. static ExtrudeShape(name: string, options: {
  57939. shape: Vector3[];
  57940. path: Vector3[];
  57941. scale?: number;
  57942. rotation?: number;
  57943. cap?: number;
  57944. updatable?: boolean;
  57945. sideOrientation?: number;
  57946. frontUVs?: Vector4;
  57947. backUVs?: Vector4;
  57948. instance?: Mesh;
  57949. invertUV?: boolean;
  57950. }, scene?: Nullable<Scene>): Mesh;
  57951. /**
  57952. * Creates an custom extruded shape mesh.
  57953. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57954. * * 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.
  57955. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57956. * * 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
  57957. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57958. * * 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
  57959. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57960. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57961. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57962. * * 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
  57963. * * 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
  57964. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57969. * @param name defines the name of the mesh
  57970. * @param options defines the options used to create the mesh
  57971. * @param scene defines the hosting scene
  57972. * @returns the custom extruded shape mesh
  57973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57976. */
  57977. static ExtrudeShapeCustom(name: string, options: {
  57978. shape: Vector3[];
  57979. path: Vector3[];
  57980. scaleFunction?: any;
  57981. rotationFunction?: any;
  57982. ribbonCloseArray?: boolean;
  57983. ribbonClosePath?: boolean;
  57984. cap?: number;
  57985. updatable?: boolean;
  57986. sideOrientation?: number;
  57987. frontUVs?: Vector4;
  57988. backUVs?: Vector4;
  57989. instance?: Mesh;
  57990. invertUV?: boolean;
  57991. }, scene?: Nullable<Scene>): Mesh;
  57992. /**
  57993. * Creates lathe mesh.
  57994. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57995. * * 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
  57996. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57997. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57998. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57999. * * 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
  58000. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58001. * * 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
  58002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58006. * @param name defines the name of the mesh
  58007. * @param options defines the options used to create the mesh
  58008. * @param scene defines the hosting scene
  58009. * @returns the lathe mesh
  58010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58011. */
  58012. static CreateLathe(name: string, options: {
  58013. shape: Vector3[];
  58014. radius?: number;
  58015. tessellation?: number;
  58016. clip?: number;
  58017. arc?: number;
  58018. closed?: boolean;
  58019. updatable?: boolean;
  58020. sideOrientation?: number;
  58021. frontUVs?: Vector4;
  58022. backUVs?: Vector4;
  58023. cap?: number;
  58024. invertUV?: boolean;
  58025. }, scene?: Nullable<Scene>): Mesh;
  58026. /**
  58027. * Creates a tiled plane mesh
  58028. * * You can set a limited pattern arrangement with the tiles
  58029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58032. * @param name defines the name of the mesh
  58033. * @param options defines the options used to create the mesh
  58034. * @param scene defines the hosting scene
  58035. * @returns the plane mesh
  58036. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58037. */
  58038. static CreateTiledPlane(name: string, options: {
  58039. pattern?: number;
  58040. tileSize?: number;
  58041. tileWidth?: number;
  58042. tileHeight?: number;
  58043. size?: number;
  58044. width?: number;
  58045. height?: number;
  58046. alignHorizontal?: number;
  58047. alignVertical?: number;
  58048. sideOrientation?: number;
  58049. frontUVs?: Vector4;
  58050. backUVs?: Vector4;
  58051. updatable?: boolean;
  58052. }, scene?: Nullable<Scene>): Mesh;
  58053. /**
  58054. * Creates a plane mesh
  58055. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58056. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58057. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58061. * @param name defines the name of the mesh
  58062. * @param options defines the options used to create the mesh
  58063. * @param scene defines the hosting scene
  58064. * @returns the plane mesh
  58065. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58066. */
  58067. static CreatePlane(name: string, options: {
  58068. size?: number;
  58069. width?: number;
  58070. height?: number;
  58071. sideOrientation?: number;
  58072. frontUVs?: Vector4;
  58073. backUVs?: Vector4;
  58074. updatable?: boolean;
  58075. sourcePlane?: Plane;
  58076. }, scene?: Nullable<Scene>): Mesh;
  58077. /**
  58078. * Creates a ground mesh
  58079. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58080. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58082. * @param name defines the name of the mesh
  58083. * @param options defines the options used to create the mesh
  58084. * @param scene defines the hosting scene
  58085. * @returns the ground mesh
  58086. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58087. */
  58088. static CreateGround(name: string, options: {
  58089. width?: number;
  58090. height?: number;
  58091. subdivisions?: number;
  58092. subdivisionsX?: number;
  58093. subdivisionsY?: number;
  58094. updatable?: boolean;
  58095. }, scene?: Nullable<Scene>): Mesh;
  58096. /**
  58097. * Creates a tiled ground mesh
  58098. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58099. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58100. * * 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
  58101. * * 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
  58102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58103. * @param name defines the name of the mesh
  58104. * @param options defines the options used to create the mesh
  58105. * @param scene defines the hosting scene
  58106. * @returns the tiled ground mesh
  58107. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58108. */
  58109. static CreateTiledGround(name: string, options: {
  58110. xmin: number;
  58111. zmin: number;
  58112. xmax: number;
  58113. zmax: number;
  58114. subdivisions?: {
  58115. w: number;
  58116. h: number;
  58117. };
  58118. precision?: {
  58119. w: number;
  58120. h: number;
  58121. };
  58122. updatable?: boolean;
  58123. }, scene?: Nullable<Scene>): Mesh;
  58124. /**
  58125. * Creates a ground mesh from a height map
  58126. * * The parameter `url` sets the URL of the height map image resource.
  58127. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58128. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58129. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58130. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58131. * * 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.
  58132. * * 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).
  58133. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58135. * @param name defines the name of the mesh
  58136. * @param url defines the url to the height map
  58137. * @param options defines the options used to create the mesh
  58138. * @param scene defines the hosting scene
  58139. * @returns the ground mesh
  58140. * @see https://doc.babylonjs.com/babylon101/height_map
  58141. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58142. */
  58143. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58144. width?: number;
  58145. height?: number;
  58146. subdivisions?: number;
  58147. minHeight?: number;
  58148. maxHeight?: number;
  58149. colorFilter?: Color3;
  58150. alphaFilter?: number;
  58151. updatable?: boolean;
  58152. onReady?: (mesh: GroundMesh) => void;
  58153. }, scene?: Nullable<Scene>): GroundMesh;
  58154. /**
  58155. * Creates a polygon mesh
  58156. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58157. * * 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
  58158. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58161. * * Remember you can only change the shape positions, not their number when updating a polygon
  58162. * @param name defines the name of the mesh
  58163. * @param options defines the options used to create the mesh
  58164. * @param scene defines the hosting scene
  58165. * @param earcutInjection can be used to inject your own earcut reference
  58166. * @returns the polygon mesh
  58167. */
  58168. static CreatePolygon(name: string, options: {
  58169. shape: Vector3[];
  58170. holes?: Vector3[][];
  58171. depth?: number;
  58172. faceUV?: Vector4[];
  58173. faceColors?: Color4[];
  58174. updatable?: boolean;
  58175. sideOrientation?: number;
  58176. frontUVs?: Vector4;
  58177. backUVs?: Vector4;
  58178. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58179. /**
  58180. * Creates an extruded polygon mesh, with depth in the Y direction.
  58181. * * 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)
  58182. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58183. * @param name defines the name of the mesh
  58184. * @param options defines the options used to create the mesh
  58185. * @param scene defines the hosting scene
  58186. * @param earcutInjection can be used to inject your own earcut reference
  58187. * @returns the polygon mesh
  58188. */
  58189. static ExtrudePolygon(name: string, options: {
  58190. shape: Vector3[];
  58191. holes?: Vector3[][];
  58192. depth?: number;
  58193. faceUV?: Vector4[];
  58194. faceColors?: Color4[];
  58195. updatable?: boolean;
  58196. sideOrientation?: number;
  58197. frontUVs?: Vector4;
  58198. backUVs?: Vector4;
  58199. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58200. /**
  58201. * Creates a tube mesh.
  58202. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58203. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58204. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58205. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58206. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58207. * * 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)
  58208. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58209. * * 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
  58210. * * 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
  58211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58213. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58215. * @param name defines the name of the mesh
  58216. * @param options defines the options used to create the mesh
  58217. * @param scene defines the hosting scene
  58218. * @returns the tube mesh
  58219. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58220. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58221. */
  58222. static CreateTube(name: string, options: {
  58223. path: Vector3[];
  58224. radius?: number;
  58225. tessellation?: number;
  58226. radiusFunction?: {
  58227. (i: number, distance: number): number;
  58228. };
  58229. cap?: number;
  58230. arc?: number;
  58231. updatable?: boolean;
  58232. sideOrientation?: number;
  58233. frontUVs?: Vector4;
  58234. backUVs?: Vector4;
  58235. instance?: Mesh;
  58236. invertUV?: boolean;
  58237. }, scene?: Nullable<Scene>): Mesh;
  58238. /**
  58239. * Creates a polyhedron mesh
  58240. * * 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
  58241. * * The parameter `size` (positive float, default 1) sets the polygon size
  58242. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58243. * * 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`
  58244. * * 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
  58245. * * 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)`)
  58246. * * 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
  58247. * * 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
  58248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58251. * @param name defines the name of the mesh
  58252. * @param options defines the options used to create the mesh
  58253. * @param scene defines the hosting scene
  58254. * @returns the polyhedron mesh
  58255. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58256. */
  58257. static CreatePolyhedron(name: string, options: {
  58258. type?: number;
  58259. size?: number;
  58260. sizeX?: number;
  58261. sizeY?: number;
  58262. sizeZ?: number;
  58263. custom?: any;
  58264. faceUV?: Vector4[];
  58265. faceColors?: Color4[];
  58266. flat?: boolean;
  58267. updatable?: boolean;
  58268. sideOrientation?: number;
  58269. frontUVs?: Vector4;
  58270. backUVs?: Vector4;
  58271. }, scene?: Nullable<Scene>): Mesh;
  58272. /**
  58273. * Creates a decal mesh.
  58274. * 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
  58275. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58276. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58277. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58278. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58279. * @param name defines the name of the mesh
  58280. * @param sourceMesh defines the mesh where the decal must be applied
  58281. * @param options defines the options used to create the mesh
  58282. * @param scene defines the hosting scene
  58283. * @returns the decal mesh
  58284. * @see https://doc.babylonjs.com/how_to/decals
  58285. */
  58286. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58287. position?: Vector3;
  58288. normal?: Vector3;
  58289. size?: Vector3;
  58290. angle?: number;
  58291. }): Mesh;
  58292. }
  58293. }
  58294. declare module "babylonjs/Meshes/meshSimplification" {
  58295. import { Mesh } from "babylonjs/Meshes/mesh";
  58296. /**
  58297. * A simplifier interface for future simplification implementations
  58298. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58299. */
  58300. export interface ISimplifier {
  58301. /**
  58302. * Simplification of a given mesh according to the given settings.
  58303. * Since this requires computation, it is assumed that the function runs async.
  58304. * @param settings The settings of the simplification, including quality and distance
  58305. * @param successCallback A callback that will be called after the mesh was simplified.
  58306. * @param errorCallback in case of an error, this callback will be called. optional.
  58307. */
  58308. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58309. }
  58310. /**
  58311. * Expected simplification settings.
  58312. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58314. */
  58315. export interface ISimplificationSettings {
  58316. /**
  58317. * Gets or sets the expected quality
  58318. */
  58319. quality: number;
  58320. /**
  58321. * Gets or sets the distance when this optimized version should be used
  58322. */
  58323. distance: number;
  58324. /**
  58325. * Gets an already optimized mesh
  58326. */
  58327. optimizeMesh?: boolean;
  58328. }
  58329. /**
  58330. * Class used to specify simplification options
  58331. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58332. */
  58333. export class SimplificationSettings implements ISimplificationSettings {
  58334. /** expected quality */
  58335. quality: number;
  58336. /** distance when this optimized version should be used */
  58337. distance: number;
  58338. /** already optimized mesh */
  58339. optimizeMesh?: boolean | undefined;
  58340. /**
  58341. * Creates a SimplificationSettings
  58342. * @param quality expected quality
  58343. * @param distance distance when this optimized version should be used
  58344. * @param optimizeMesh already optimized mesh
  58345. */
  58346. constructor(
  58347. /** expected quality */
  58348. quality: number,
  58349. /** distance when this optimized version should be used */
  58350. distance: number,
  58351. /** already optimized mesh */
  58352. optimizeMesh?: boolean | undefined);
  58353. }
  58354. /**
  58355. * Interface used to define a simplification task
  58356. */
  58357. export interface ISimplificationTask {
  58358. /**
  58359. * Array of settings
  58360. */
  58361. settings: Array<ISimplificationSettings>;
  58362. /**
  58363. * Simplification type
  58364. */
  58365. simplificationType: SimplificationType;
  58366. /**
  58367. * Mesh to simplify
  58368. */
  58369. mesh: Mesh;
  58370. /**
  58371. * Callback called on success
  58372. */
  58373. successCallback?: () => void;
  58374. /**
  58375. * Defines if parallel processing can be used
  58376. */
  58377. parallelProcessing: boolean;
  58378. }
  58379. /**
  58380. * Queue used to order the simplification tasks
  58381. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58382. */
  58383. export class SimplificationQueue {
  58384. private _simplificationArray;
  58385. /**
  58386. * Gets a boolean indicating that the process is still running
  58387. */
  58388. running: boolean;
  58389. /**
  58390. * Creates a new queue
  58391. */
  58392. constructor();
  58393. /**
  58394. * Adds a new simplification task
  58395. * @param task defines a task to add
  58396. */
  58397. addTask(task: ISimplificationTask): void;
  58398. /**
  58399. * Execute next task
  58400. */
  58401. executeNext(): void;
  58402. /**
  58403. * Execute a simplification task
  58404. * @param task defines the task to run
  58405. */
  58406. runSimplification(task: ISimplificationTask): void;
  58407. private getSimplifier;
  58408. }
  58409. /**
  58410. * The implemented types of simplification
  58411. * At the moment only Quadratic Error Decimation is implemented
  58412. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58413. */
  58414. export enum SimplificationType {
  58415. /** Quadratic error decimation */
  58416. QUADRATIC = 0
  58417. }
  58418. }
  58419. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58420. import { Scene } from "babylonjs/scene";
  58421. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58422. import { ISceneComponent } from "babylonjs/sceneComponent";
  58423. module "babylonjs/scene" {
  58424. interface Scene {
  58425. /** @hidden (Backing field) */
  58426. _simplificationQueue: SimplificationQueue;
  58427. /**
  58428. * Gets or sets the simplification queue attached to the scene
  58429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58430. */
  58431. simplificationQueue: SimplificationQueue;
  58432. }
  58433. }
  58434. module "babylonjs/Meshes/mesh" {
  58435. interface Mesh {
  58436. /**
  58437. * Simplify the mesh according to the given array of settings.
  58438. * Function will return immediately and will simplify async
  58439. * @param settings a collection of simplification settings
  58440. * @param parallelProcessing should all levels calculate parallel or one after the other
  58441. * @param simplificationType the type of simplification to run
  58442. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58443. * @returns the current mesh
  58444. */
  58445. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58446. }
  58447. }
  58448. /**
  58449. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58450. * created in a scene
  58451. */
  58452. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58453. /**
  58454. * The component name helpfull to identify the component in the list of scene components.
  58455. */
  58456. readonly name: string;
  58457. /**
  58458. * The scene the component belongs to.
  58459. */
  58460. scene: Scene;
  58461. /**
  58462. * Creates a new instance of the component for the given scene
  58463. * @param scene Defines the scene to register the component in
  58464. */
  58465. constructor(scene: Scene);
  58466. /**
  58467. * Registers the component in a given scene
  58468. */
  58469. register(): void;
  58470. /**
  58471. * Rebuilds the elements related to this component in case of
  58472. * context lost for instance.
  58473. */
  58474. rebuild(): void;
  58475. /**
  58476. * Disposes the component and the associated ressources
  58477. */
  58478. dispose(): void;
  58479. private _beforeCameraUpdate;
  58480. }
  58481. }
  58482. declare module "babylonjs/Meshes/Builders/index" {
  58483. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58484. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58485. export * from "babylonjs/Meshes/Builders/discBuilder";
  58486. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58487. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58488. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58489. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58490. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58491. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58492. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58493. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58494. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58495. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58496. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58497. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58498. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58499. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58500. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58501. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58502. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58503. }
  58504. declare module "babylonjs/Meshes/index" {
  58505. export * from "babylonjs/Meshes/abstractMesh";
  58506. export * from "babylonjs/Meshes/buffer";
  58507. export * from "babylonjs/Meshes/Compression/index";
  58508. export * from "babylonjs/Meshes/csg";
  58509. export * from "babylonjs/Meshes/geometry";
  58510. export * from "babylonjs/Meshes/groundMesh";
  58511. export * from "babylonjs/Meshes/trailMesh";
  58512. export * from "babylonjs/Meshes/instancedMesh";
  58513. export * from "babylonjs/Meshes/linesMesh";
  58514. export * from "babylonjs/Meshes/mesh";
  58515. export * from "babylonjs/Meshes/mesh.vertexData";
  58516. export * from "babylonjs/Meshes/meshBuilder";
  58517. export * from "babylonjs/Meshes/meshSimplification";
  58518. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58519. export * from "babylonjs/Meshes/polygonMesh";
  58520. export * from "babylonjs/Meshes/subMesh";
  58521. export * from "babylonjs/Meshes/meshLODLevel";
  58522. export * from "babylonjs/Meshes/transformNode";
  58523. export * from "babylonjs/Meshes/Builders/index";
  58524. export * from "babylonjs/Meshes/dataBuffer";
  58525. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58526. }
  58527. declare module "babylonjs/Morph/index" {
  58528. export * from "babylonjs/Morph/morphTarget";
  58529. export * from "babylonjs/Morph/morphTargetManager";
  58530. }
  58531. declare module "babylonjs/Navigation/INavigationEngine" {
  58532. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58533. import { Vector3 } from "babylonjs/Maths/math";
  58534. import { Mesh } from "babylonjs/Meshes/mesh";
  58535. import { Scene } from "babylonjs/scene";
  58536. /**
  58537. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58538. */
  58539. export interface INavigationEnginePlugin {
  58540. /**
  58541. * plugin name
  58542. */
  58543. name: string;
  58544. /**
  58545. * Creates a navigation mesh
  58546. * @param meshes array of all the geometry used to compute the navigatio mesh
  58547. * @param parameters bunch of parameters used to filter geometry
  58548. */
  58549. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58550. /**
  58551. * Create a navigation mesh debug mesh
  58552. * @param scene is where the mesh will be added
  58553. * @returns debug display mesh
  58554. */
  58555. createDebugNavMesh(scene: Scene): Mesh;
  58556. /**
  58557. * Get a navigation mesh constrained position, closest to the parameter position
  58558. * @param position world position
  58559. * @returns the closest point to position constrained by the navigation mesh
  58560. */
  58561. getClosestPoint(position: Vector3): Vector3;
  58562. /**
  58563. * Get a navigation mesh constrained position, within a particular radius
  58564. * @param position world position
  58565. * @param maxRadius the maximum distance to the constrained world position
  58566. * @returns the closest point to position constrained by the navigation mesh
  58567. */
  58568. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58569. /**
  58570. * Compute the final position from a segment made of destination-position
  58571. * @param position world position
  58572. * @param destination world position
  58573. * @returns the resulting point along the navmesh
  58574. */
  58575. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58576. /**
  58577. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58578. * @param start world position
  58579. * @param end world position
  58580. * @returns array containing world position composing the path
  58581. */
  58582. computePath(start: Vector3, end: Vector3): Vector3[];
  58583. /**
  58584. * If this plugin is supported
  58585. * @returns true if plugin is supported
  58586. */
  58587. isSupported(): boolean;
  58588. /**
  58589. * Create a new Crowd so you can add agents
  58590. * @param maxAgents the maximum agent count in the crowd
  58591. * @param maxAgentRadius the maximum radius an agent can have
  58592. * @param scene to attach the crowd to
  58593. * @returns the crowd you can add agents to
  58594. */
  58595. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58596. /**
  58597. * Release all resources
  58598. */
  58599. dispose(): void;
  58600. }
  58601. /**
  58602. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58603. */
  58604. export interface ICrowd {
  58605. /**
  58606. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58607. * You can attach anything to that node. The node position is updated in the scene update tick.
  58608. * @param pos world position that will be constrained by the navigation mesh
  58609. * @param parameters agent parameters
  58610. * @param transform hooked to the agent that will be update by the scene
  58611. * @returns agent index
  58612. */
  58613. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58614. /**
  58615. * Returns the agent position in world space
  58616. * @param index agent index returned by addAgent
  58617. * @returns world space position
  58618. */
  58619. getAgentPosition(index: number): Vector3;
  58620. /**
  58621. * Gets the agent velocity in world space
  58622. * @param index agent index returned by addAgent
  58623. * @returns world space velocity
  58624. */
  58625. getAgentVelocity(index: number): Vector3;
  58626. /**
  58627. * remove a particular agent previously created
  58628. * @param index agent index returned by addAgent
  58629. */
  58630. removeAgent(index: number): void;
  58631. /**
  58632. * get the list of all agents attached to this crowd
  58633. * @returns list of agent indices
  58634. */
  58635. getAgents(): number[];
  58636. /**
  58637. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58638. * @param deltaTime in seconds
  58639. */
  58640. update(deltaTime: number): void;
  58641. /**
  58642. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58643. * @param index agent index returned by addAgent
  58644. * @param destination targeted world position
  58645. */
  58646. agentGoto(index: number, destination: Vector3): void;
  58647. /**
  58648. * Release all resources
  58649. */
  58650. dispose(): void;
  58651. }
  58652. /**
  58653. * Configures an agent
  58654. */
  58655. export interface IAgentParameters {
  58656. /**
  58657. * Agent radius. [Limit: >= 0]
  58658. */
  58659. radius: number;
  58660. /**
  58661. * Agent height. [Limit: > 0]
  58662. */
  58663. height: number;
  58664. /**
  58665. * Maximum allowed acceleration. [Limit: >= 0]
  58666. */
  58667. maxAcceleration: number;
  58668. /**
  58669. * Maximum allowed speed. [Limit: >= 0]
  58670. */
  58671. maxSpeed: number;
  58672. /**
  58673. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58674. */
  58675. collisionQueryRange: number;
  58676. /**
  58677. * The path visibility optimization range. [Limit: > 0]
  58678. */
  58679. pathOptimizationRange: number;
  58680. /**
  58681. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58682. */
  58683. separationWeight: number;
  58684. }
  58685. /**
  58686. * Configures the navigation mesh creation
  58687. */
  58688. export interface INavMeshParameters {
  58689. /**
  58690. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58691. */
  58692. cs: number;
  58693. /**
  58694. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58695. */
  58696. ch: number;
  58697. /**
  58698. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58699. */
  58700. walkableSlopeAngle: number;
  58701. /**
  58702. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58703. * be considered walkable. [Limit: >= 3] [Units: vx]
  58704. */
  58705. walkableHeight: number;
  58706. /**
  58707. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58708. */
  58709. walkableClimb: number;
  58710. /**
  58711. * The distance to erode/shrink the walkable area of the heightfield away from
  58712. * obstructions. [Limit: >=0] [Units: vx]
  58713. */
  58714. walkableRadius: number;
  58715. /**
  58716. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58717. */
  58718. maxEdgeLen: number;
  58719. /**
  58720. * The maximum distance a simplfied contour's border edges should deviate
  58721. * the original raw contour. [Limit: >=0] [Units: vx]
  58722. */
  58723. maxSimplificationError: number;
  58724. /**
  58725. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58726. */
  58727. minRegionArea: number;
  58728. /**
  58729. * Any regions with a span count smaller than this value will, if possible,
  58730. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58731. */
  58732. mergeRegionArea: number;
  58733. /**
  58734. * The maximum number of vertices allowed for polygons generated during the
  58735. * contour to polygon conversion process. [Limit: >= 3]
  58736. */
  58737. maxVertsPerPoly: number;
  58738. /**
  58739. * Sets the sampling distance to use when generating the detail mesh.
  58740. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58741. */
  58742. detailSampleDist: number;
  58743. /**
  58744. * The maximum distance the detail mesh surface should deviate from heightfield
  58745. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58746. */
  58747. detailSampleMaxError: number;
  58748. }
  58749. }
  58750. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58751. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58752. import { Mesh } from "babylonjs/Meshes/mesh";
  58753. import { Scene } from "babylonjs/scene";
  58754. import { Vector3 } from "babylonjs/Maths/math";
  58755. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58756. /**
  58757. * RecastJS navigation plugin
  58758. */
  58759. export class RecastJSPlugin implements INavigationEnginePlugin {
  58760. /**
  58761. * Reference to the Recast library
  58762. */
  58763. bjsRECAST: any;
  58764. /**
  58765. * plugin name
  58766. */
  58767. name: string;
  58768. /**
  58769. * the first navmesh created. We might extend this to support multiple navmeshes
  58770. */
  58771. navMesh: any;
  58772. /**
  58773. * Initializes the recastJS plugin
  58774. * @param recastInjection can be used to inject your own recast reference
  58775. */
  58776. constructor(recastInjection?: any);
  58777. /**
  58778. * Creates a navigation mesh
  58779. * @param meshes array of all the geometry used to compute the navigatio mesh
  58780. * @param parameters bunch of parameters used to filter geometry
  58781. */
  58782. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58783. /**
  58784. * Create a navigation mesh debug mesh
  58785. * @param scene is where the mesh will be added
  58786. * @returns debug display mesh
  58787. */
  58788. createDebugNavMesh(scene: Scene): Mesh;
  58789. /**
  58790. * Get a navigation mesh constrained position, closest to the parameter position
  58791. * @param position world position
  58792. * @returns the closest point to position constrained by the navigation mesh
  58793. */
  58794. getClosestPoint(position: Vector3): Vector3;
  58795. /**
  58796. * Get a navigation mesh constrained position, within a particular radius
  58797. * @param position world position
  58798. * @param maxRadius the maximum distance to the constrained world position
  58799. * @returns the closest point to position constrained by the navigation mesh
  58800. */
  58801. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58802. /**
  58803. * Compute the final position from a segment made of destination-position
  58804. * @param position world position
  58805. * @param destination world position
  58806. * @returns the resulting point along the navmesh
  58807. */
  58808. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58809. /**
  58810. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58811. * @param start world position
  58812. * @param end world position
  58813. * @returns array containing world position composing the path
  58814. */
  58815. computePath(start: Vector3, end: Vector3): Vector3[];
  58816. /**
  58817. * Create a new Crowd so you can add agents
  58818. * @param maxAgents the maximum agent count in the crowd
  58819. * @param maxAgentRadius the maximum radius an agent can have
  58820. * @param scene to attach the crowd to
  58821. * @returns the crowd you can add agents to
  58822. */
  58823. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58824. /**
  58825. * Disposes
  58826. */
  58827. dispose(): void;
  58828. /**
  58829. * If this plugin is supported
  58830. * @returns true if plugin is supported
  58831. */
  58832. isSupported(): boolean;
  58833. }
  58834. /**
  58835. * Recast detour crowd implementation
  58836. */
  58837. export class RecastJSCrowd implements ICrowd {
  58838. /**
  58839. * Recast/detour plugin
  58840. */
  58841. bjsRECASTPlugin: RecastJSPlugin;
  58842. /**
  58843. * Link to the detour crowd
  58844. */
  58845. recastCrowd: any;
  58846. /**
  58847. * One transform per agent
  58848. */
  58849. transforms: TransformNode[];
  58850. /**
  58851. * All agents created
  58852. */
  58853. agents: number[];
  58854. /**
  58855. * Link to the scene is kept to unregister the crowd from the scene
  58856. */
  58857. private _scene;
  58858. /**
  58859. * Observer for crowd updates
  58860. */
  58861. private _onBeforeAnimationsObserver;
  58862. /**
  58863. * Constructor
  58864. * @param plugin recastJS plugin
  58865. * @param maxAgents the maximum agent count in the crowd
  58866. * @param maxAgentRadius the maximum radius an agent can have
  58867. * @param scene to attach the crowd to
  58868. * @returns the crowd you can add agents to
  58869. */
  58870. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58871. /**
  58872. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58873. * You can attach anything to that node. The node position is updated in the scene update tick.
  58874. * @param pos world position that will be constrained by the navigation mesh
  58875. * @param parameters agent parameters
  58876. * @param transform hooked to the agent that will be update by the scene
  58877. * @returns agent index
  58878. */
  58879. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58880. /**
  58881. * Returns the agent position in world space
  58882. * @param index agent index returned by addAgent
  58883. * @returns world space position
  58884. */
  58885. getAgentPosition(index: number): Vector3;
  58886. /**
  58887. * Returns the agent velocity in world space
  58888. * @param index agent index returned by addAgent
  58889. * @returns world space velocity
  58890. */
  58891. getAgentVelocity(index: number): Vector3;
  58892. /**
  58893. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58894. * @param index agent index returned by addAgent
  58895. * @param destination targeted world position
  58896. */
  58897. agentGoto(index: number, destination: Vector3): void;
  58898. /**
  58899. * remove a particular agent previously created
  58900. * @param index agent index returned by addAgent
  58901. */
  58902. removeAgent(index: number): void;
  58903. /**
  58904. * get the list of all agents attached to this crowd
  58905. * @returns list of agent indices
  58906. */
  58907. getAgents(): number[];
  58908. /**
  58909. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58910. * @param deltaTime in seconds
  58911. */
  58912. update(deltaTime: number): void;
  58913. /**
  58914. * Release all resources
  58915. */
  58916. dispose(): void;
  58917. }
  58918. }
  58919. declare module "babylonjs/Navigation/Plugins/index" {
  58920. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58921. }
  58922. declare module "babylonjs/Navigation/index" {
  58923. export * from "babylonjs/Navigation/INavigationEngine";
  58924. export * from "babylonjs/Navigation/Plugins/index";
  58925. }
  58926. declare module "babylonjs/Offline/database" {
  58927. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58928. /**
  58929. * Class used to enable access to IndexedDB
  58930. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58931. */
  58932. export class Database implements IOfflineProvider {
  58933. private _callbackManifestChecked;
  58934. private _currentSceneUrl;
  58935. private _db;
  58936. private _enableSceneOffline;
  58937. private _enableTexturesOffline;
  58938. private _manifestVersionFound;
  58939. private _mustUpdateRessources;
  58940. private _hasReachedQuota;
  58941. private _isSupported;
  58942. private _idbFactory;
  58943. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58944. private static IsUASupportingBlobStorage;
  58945. /**
  58946. * Gets a boolean indicating if Database storate is enabled (off by default)
  58947. */
  58948. static IDBStorageEnabled: boolean;
  58949. /**
  58950. * Gets a boolean indicating if scene must be saved in the database
  58951. */
  58952. readonly enableSceneOffline: boolean;
  58953. /**
  58954. * Gets a boolean indicating if textures must be saved in the database
  58955. */
  58956. readonly enableTexturesOffline: boolean;
  58957. /**
  58958. * Creates a new Database
  58959. * @param urlToScene defines the url to load the scene
  58960. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58961. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58962. */
  58963. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58964. private static _ParseURL;
  58965. private static _ReturnFullUrlLocation;
  58966. private _checkManifestFile;
  58967. /**
  58968. * Open the database and make it available
  58969. * @param successCallback defines the callback to call on success
  58970. * @param errorCallback defines the callback to call on error
  58971. */
  58972. open(successCallback: () => void, errorCallback: () => void): void;
  58973. /**
  58974. * Loads an image from the database
  58975. * @param url defines the url to load from
  58976. * @param image defines the target DOM image
  58977. */
  58978. loadImage(url: string, image: HTMLImageElement): void;
  58979. private _loadImageFromDBAsync;
  58980. private _saveImageIntoDBAsync;
  58981. private _checkVersionFromDB;
  58982. private _loadVersionFromDBAsync;
  58983. private _saveVersionIntoDBAsync;
  58984. /**
  58985. * Loads a file from database
  58986. * @param url defines the URL to load from
  58987. * @param sceneLoaded defines a callback to call on success
  58988. * @param progressCallBack defines a callback to call when progress changed
  58989. * @param errorCallback defines a callback to call on error
  58990. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58991. */
  58992. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58993. private _loadFileAsync;
  58994. private _saveFileAsync;
  58995. /**
  58996. * Validates if xhr data is correct
  58997. * @param xhr defines the request to validate
  58998. * @param dataType defines the expected data type
  58999. * @returns true if data is correct
  59000. */
  59001. private static _ValidateXHRData;
  59002. }
  59003. }
  59004. declare module "babylonjs/Offline/index" {
  59005. export * from "babylonjs/Offline/database";
  59006. export * from "babylonjs/Offline/IOfflineProvider";
  59007. }
  59008. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59009. /** @hidden */
  59010. export var gpuUpdateParticlesPixelShader: {
  59011. name: string;
  59012. shader: string;
  59013. };
  59014. }
  59015. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59016. /** @hidden */
  59017. export var gpuUpdateParticlesVertexShader: {
  59018. name: string;
  59019. shader: string;
  59020. };
  59021. }
  59022. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59023. /** @hidden */
  59024. export var clipPlaneFragmentDeclaration2: {
  59025. name: string;
  59026. shader: string;
  59027. };
  59028. }
  59029. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59030. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59031. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59032. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59033. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59034. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59035. /** @hidden */
  59036. export var gpuRenderParticlesPixelShader: {
  59037. name: string;
  59038. shader: string;
  59039. };
  59040. }
  59041. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59042. /** @hidden */
  59043. export var clipPlaneVertexDeclaration2: {
  59044. name: string;
  59045. shader: string;
  59046. };
  59047. }
  59048. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59049. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59051. /** @hidden */
  59052. export var gpuRenderParticlesVertexShader: {
  59053. name: string;
  59054. shader: string;
  59055. };
  59056. }
  59057. declare module "babylonjs/Particles/gpuParticleSystem" {
  59058. import { Nullable } from "babylonjs/types";
  59059. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59060. import { Observable } from "babylonjs/Misc/observable";
  59061. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59062. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59063. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59064. import { Scene, IDisposable } from "babylonjs/scene";
  59065. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59066. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59067. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59068. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59069. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59070. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59071. /**
  59072. * This represents a GPU particle system in Babylon
  59073. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59074. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59075. */
  59076. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59077. /**
  59078. * The layer mask we are rendering the particles through.
  59079. */
  59080. layerMask: number;
  59081. private _capacity;
  59082. private _activeCount;
  59083. private _currentActiveCount;
  59084. private _accumulatedCount;
  59085. private _renderEffect;
  59086. private _updateEffect;
  59087. private _buffer0;
  59088. private _buffer1;
  59089. private _spriteBuffer;
  59090. private _updateVAO;
  59091. private _renderVAO;
  59092. private _targetIndex;
  59093. private _sourceBuffer;
  59094. private _targetBuffer;
  59095. private _engine;
  59096. private _currentRenderId;
  59097. private _started;
  59098. private _stopped;
  59099. private _timeDelta;
  59100. private _randomTexture;
  59101. private _randomTexture2;
  59102. private _attributesStrideSize;
  59103. private _updateEffectOptions;
  59104. private _randomTextureSize;
  59105. private _actualFrame;
  59106. private readonly _rawTextureWidth;
  59107. /**
  59108. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59109. */
  59110. static readonly IsSupported: boolean;
  59111. /**
  59112. * An event triggered when the system is disposed.
  59113. */
  59114. onDisposeObservable: Observable<GPUParticleSystem>;
  59115. /**
  59116. * Gets the maximum number of particles active at the same time.
  59117. * @returns The max number of active particles.
  59118. */
  59119. getCapacity(): number;
  59120. /**
  59121. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59122. * to override the particles.
  59123. */
  59124. forceDepthWrite: boolean;
  59125. /**
  59126. * Gets or set the number of active particles
  59127. */
  59128. activeParticleCount: number;
  59129. private _preWarmDone;
  59130. /**
  59131. * Is this system ready to be used/rendered
  59132. * @return true if the system is ready
  59133. */
  59134. isReady(): boolean;
  59135. /**
  59136. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59137. * @returns True if it has been started, otherwise false.
  59138. */
  59139. isStarted(): boolean;
  59140. /**
  59141. * Starts the particle system and begins to emit
  59142. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59143. */
  59144. start(delay?: number): void;
  59145. /**
  59146. * Stops the particle system.
  59147. */
  59148. stop(): void;
  59149. /**
  59150. * Remove all active particles
  59151. */
  59152. reset(): void;
  59153. /**
  59154. * Returns the string "GPUParticleSystem"
  59155. * @returns a string containing the class name
  59156. */
  59157. getClassName(): string;
  59158. private _colorGradientsTexture;
  59159. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59160. /**
  59161. * Adds a new color gradient
  59162. * @param gradient defines the gradient to use (between 0 and 1)
  59163. * @param color1 defines the color to affect to the specified gradient
  59164. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59165. * @returns the current particle system
  59166. */
  59167. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59168. /**
  59169. * Remove a specific color gradient
  59170. * @param gradient defines the gradient to remove
  59171. * @returns the current particle system
  59172. */
  59173. removeColorGradient(gradient: number): GPUParticleSystem;
  59174. private _angularSpeedGradientsTexture;
  59175. private _sizeGradientsTexture;
  59176. private _velocityGradientsTexture;
  59177. private _limitVelocityGradientsTexture;
  59178. private _dragGradientsTexture;
  59179. private _addFactorGradient;
  59180. /**
  59181. * Adds a new size gradient
  59182. * @param gradient defines the gradient to use (between 0 and 1)
  59183. * @param factor defines the size factor to affect to the specified gradient
  59184. * @returns the current particle system
  59185. */
  59186. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59187. /**
  59188. * Remove a specific size gradient
  59189. * @param gradient defines the gradient to remove
  59190. * @returns the current particle system
  59191. */
  59192. removeSizeGradient(gradient: number): GPUParticleSystem;
  59193. /**
  59194. * Adds a new angular speed gradient
  59195. * @param gradient defines the gradient to use (between 0 and 1)
  59196. * @param factor defines the angular speed to affect to the specified gradient
  59197. * @returns the current particle system
  59198. */
  59199. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59200. /**
  59201. * Remove a specific angular speed gradient
  59202. * @param gradient defines the gradient to remove
  59203. * @returns the current particle system
  59204. */
  59205. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59206. /**
  59207. * Adds a new velocity gradient
  59208. * @param gradient defines the gradient to use (between 0 and 1)
  59209. * @param factor defines the velocity to affect to the specified gradient
  59210. * @returns the current particle system
  59211. */
  59212. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59213. /**
  59214. * Remove a specific velocity gradient
  59215. * @param gradient defines the gradient to remove
  59216. * @returns the current particle system
  59217. */
  59218. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59219. /**
  59220. * Adds a new limit velocity gradient
  59221. * @param gradient defines the gradient to use (between 0 and 1)
  59222. * @param factor defines the limit velocity value to affect to the specified gradient
  59223. * @returns the current particle system
  59224. */
  59225. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59226. /**
  59227. * Remove a specific limit velocity gradient
  59228. * @param gradient defines the gradient to remove
  59229. * @returns the current particle system
  59230. */
  59231. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59232. /**
  59233. * Adds a new drag gradient
  59234. * @param gradient defines the gradient to use (between 0 and 1)
  59235. * @param factor defines the drag value to affect to the specified gradient
  59236. * @returns the current particle system
  59237. */
  59238. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59239. /**
  59240. * Remove a specific drag gradient
  59241. * @param gradient defines the gradient to remove
  59242. * @returns the current particle system
  59243. */
  59244. removeDragGradient(gradient: number): GPUParticleSystem;
  59245. /**
  59246. * Not supported by GPUParticleSystem
  59247. * @param gradient defines the gradient to use (between 0 and 1)
  59248. * @param factor defines the emit rate value to affect to the specified gradient
  59249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59250. * @returns the current particle system
  59251. */
  59252. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59253. /**
  59254. * Not supported by GPUParticleSystem
  59255. * @param gradient defines the gradient to remove
  59256. * @returns the current particle system
  59257. */
  59258. removeEmitRateGradient(gradient: number): IParticleSystem;
  59259. /**
  59260. * Not supported by GPUParticleSystem
  59261. * @param gradient defines the gradient to use (between 0 and 1)
  59262. * @param factor defines the start size value to affect to the specified gradient
  59263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59264. * @returns the current particle system
  59265. */
  59266. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59267. /**
  59268. * Not supported by GPUParticleSystem
  59269. * @param gradient defines the gradient to remove
  59270. * @returns the current particle system
  59271. */
  59272. removeStartSizeGradient(gradient: number): IParticleSystem;
  59273. /**
  59274. * Not supported by GPUParticleSystem
  59275. * @param gradient defines the gradient to use (between 0 and 1)
  59276. * @param min defines the color remap minimal range
  59277. * @param max defines the color remap maximal range
  59278. * @returns the current particle system
  59279. */
  59280. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59281. /**
  59282. * Not supported by GPUParticleSystem
  59283. * @param gradient defines the gradient to remove
  59284. * @returns the current particle system
  59285. */
  59286. removeColorRemapGradient(): IParticleSystem;
  59287. /**
  59288. * Not supported by GPUParticleSystem
  59289. * @param gradient defines the gradient to use (between 0 and 1)
  59290. * @param min defines the alpha remap minimal range
  59291. * @param max defines the alpha remap maximal range
  59292. * @returns the current particle system
  59293. */
  59294. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59295. /**
  59296. * Not supported by GPUParticleSystem
  59297. * @param gradient defines the gradient to remove
  59298. * @returns the current particle system
  59299. */
  59300. removeAlphaRemapGradient(): IParticleSystem;
  59301. /**
  59302. * Not supported by GPUParticleSystem
  59303. * @param gradient defines the gradient to use (between 0 and 1)
  59304. * @param color defines the color to affect to the specified gradient
  59305. * @returns the current particle system
  59306. */
  59307. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59308. /**
  59309. * Not supported by GPUParticleSystem
  59310. * @param gradient defines the gradient to remove
  59311. * @returns the current particle system
  59312. */
  59313. removeRampGradient(): IParticleSystem;
  59314. /**
  59315. * Not supported by GPUParticleSystem
  59316. * @returns the list of ramp gradients
  59317. */
  59318. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59319. /**
  59320. * Not supported by GPUParticleSystem
  59321. * Gets or sets a boolean indicating that ramp gradients must be used
  59322. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59323. */
  59324. useRampGradients: boolean;
  59325. /**
  59326. * Not supported by GPUParticleSystem
  59327. * @param gradient defines the gradient to use (between 0 and 1)
  59328. * @param factor defines the life time factor to affect to the specified gradient
  59329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59330. * @returns the current particle system
  59331. */
  59332. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59333. /**
  59334. * Not supported by GPUParticleSystem
  59335. * @param gradient defines the gradient to remove
  59336. * @returns the current particle system
  59337. */
  59338. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59339. /**
  59340. * Instantiates a GPU particle system.
  59341. * 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.
  59342. * @param name The name of the particle system
  59343. * @param options The options used to create the system
  59344. * @param scene The scene the particle system belongs to
  59345. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59346. */
  59347. constructor(name: string, options: Partial<{
  59348. capacity: number;
  59349. randomTextureSize: number;
  59350. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59351. protected _reset(): void;
  59352. private _createUpdateVAO;
  59353. private _createRenderVAO;
  59354. private _initialize;
  59355. /** @hidden */
  59356. _recreateUpdateEffect(): void;
  59357. /** @hidden */
  59358. _recreateRenderEffect(): void;
  59359. /**
  59360. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59361. * @param preWarm defines if we are in the pre-warmimg phase
  59362. */
  59363. animate(preWarm?: boolean): void;
  59364. private _createFactorGradientTexture;
  59365. private _createSizeGradientTexture;
  59366. private _createAngularSpeedGradientTexture;
  59367. private _createVelocityGradientTexture;
  59368. private _createLimitVelocityGradientTexture;
  59369. private _createDragGradientTexture;
  59370. private _createColorGradientTexture;
  59371. /**
  59372. * Renders the particle system in its current state
  59373. * @param preWarm defines if the system should only update the particles but not render them
  59374. * @returns the current number of particles
  59375. */
  59376. render(preWarm?: boolean): number;
  59377. /**
  59378. * Rebuilds the particle system
  59379. */
  59380. rebuild(): void;
  59381. private _releaseBuffers;
  59382. private _releaseVAOs;
  59383. /**
  59384. * Disposes the particle system and free the associated resources
  59385. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59386. */
  59387. dispose(disposeTexture?: boolean): void;
  59388. /**
  59389. * Clones the particle system.
  59390. * @param name The name of the cloned object
  59391. * @param newEmitter The new emitter to use
  59392. * @returns the cloned particle system
  59393. */
  59394. clone(name: string, newEmitter: any): GPUParticleSystem;
  59395. /**
  59396. * Serializes the particle system to a JSON object.
  59397. * @returns the JSON object
  59398. */
  59399. serialize(): any;
  59400. /**
  59401. * Parses a JSON object to create a GPU particle system.
  59402. * @param parsedParticleSystem The JSON object to parse
  59403. * @param scene The scene to create the particle system in
  59404. * @param rootUrl The root url to use to load external dependencies like texture
  59405. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59406. * @returns the parsed GPU particle system
  59407. */
  59408. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59409. }
  59410. }
  59411. declare module "babylonjs/Particles/particleSystemSet" {
  59412. import { Nullable } from "babylonjs/types";
  59413. import { Color3 } from "babylonjs/Maths/math.color";
  59414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59417. import { Scene, IDisposable } from "babylonjs/scene";
  59418. /**
  59419. * Represents a set of particle systems working together to create a specific effect
  59420. */
  59421. export class ParticleSystemSet implements IDisposable {
  59422. private _emitterCreationOptions;
  59423. private _emitterNode;
  59424. /**
  59425. * Gets the particle system list
  59426. */
  59427. systems: IParticleSystem[];
  59428. /**
  59429. * Gets the emitter node used with this set
  59430. */
  59431. readonly emitterNode: Nullable<TransformNode>;
  59432. /**
  59433. * Creates a new emitter mesh as a sphere
  59434. * @param options defines the options used to create the sphere
  59435. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59436. * @param scene defines the hosting scene
  59437. */
  59438. setEmitterAsSphere(options: {
  59439. diameter: number;
  59440. segments: number;
  59441. color: Color3;
  59442. }, renderingGroupId: number, scene: Scene): void;
  59443. /**
  59444. * Starts all particle systems of the set
  59445. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59446. */
  59447. start(emitter?: AbstractMesh): void;
  59448. /**
  59449. * Release all associated resources
  59450. */
  59451. dispose(): void;
  59452. /**
  59453. * Serialize the set into a JSON compatible object
  59454. * @returns a JSON compatible representation of the set
  59455. */
  59456. serialize(): any;
  59457. /**
  59458. * Parse a new ParticleSystemSet from a serialized source
  59459. * @param data defines a JSON compatible representation of the set
  59460. * @param scene defines the hosting scene
  59461. * @param gpu defines if we want GPU particles or CPU particles
  59462. * @returns a new ParticleSystemSet
  59463. */
  59464. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59465. }
  59466. }
  59467. declare module "babylonjs/Particles/particleHelper" {
  59468. import { Nullable } from "babylonjs/types";
  59469. import { Scene } from "babylonjs/scene";
  59470. import { Vector3 } from "babylonjs/Maths/math.vector";
  59471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59473. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59474. /**
  59475. * This class is made for on one-liner static method to help creating particle system set.
  59476. */
  59477. export class ParticleHelper {
  59478. /**
  59479. * Gets or sets base Assets URL
  59480. */
  59481. static BaseAssetsUrl: string;
  59482. /**
  59483. * Create a default particle system that you can tweak
  59484. * @param emitter defines the emitter to use
  59485. * @param capacity defines the system capacity (default is 500 particles)
  59486. * @param scene defines the hosting scene
  59487. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59488. * @returns the new Particle system
  59489. */
  59490. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59491. /**
  59492. * This is the main static method (one-liner) of this helper to create different particle systems
  59493. * @param type This string represents the type to the particle system to create
  59494. * @param scene The scene where the particle system should live
  59495. * @param gpu If the system will use gpu
  59496. * @returns the ParticleSystemSet created
  59497. */
  59498. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59499. /**
  59500. * Static function used to export a particle system to a ParticleSystemSet variable.
  59501. * Please note that the emitter shape is not exported
  59502. * @param systems defines the particle systems to export
  59503. * @returns the created particle system set
  59504. */
  59505. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59506. }
  59507. }
  59508. declare module "babylonjs/Particles/particleSystemComponent" {
  59509. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59510. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59511. import "babylonjs/Shaders/particles.vertex";
  59512. module "babylonjs/Engines/engine" {
  59513. interface Engine {
  59514. /**
  59515. * Create an effect to use with particle systems.
  59516. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59517. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59518. * @param uniformsNames defines a list of attribute names
  59519. * @param samplers defines an array of string used to represent textures
  59520. * @param defines defines the string containing the defines to use to compile the shaders
  59521. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59522. * @param onCompiled defines a function to call when the effect creation is successful
  59523. * @param onError defines a function to call when the effect creation has failed
  59524. * @returns the new Effect
  59525. */
  59526. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59527. }
  59528. }
  59529. module "babylonjs/Meshes/mesh" {
  59530. interface Mesh {
  59531. /**
  59532. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59533. * @returns an array of IParticleSystem
  59534. */
  59535. getEmittedParticleSystems(): IParticleSystem[];
  59536. /**
  59537. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59538. * @returns an array of IParticleSystem
  59539. */
  59540. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59541. }
  59542. }
  59543. /**
  59544. * @hidden
  59545. */
  59546. export var _IDoNeedToBeInTheBuild: number;
  59547. }
  59548. declare module "babylonjs/Particles/index" {
  59549. export * from "babylonjs/Particles/baseParticleSystem";
  59550. export * from "babylonjs/Particles/EmitterTypes/index";
  59551. export * from "babylonjs/Particles/gpuParticleSystem";
  59552. export * from "babylonjs/Particles/IParticleSystem";
  59553. export * from "babylonjs/Particles/particle";
  59554. export * from "babylonjs/Particles/particleHelper";
  59555. export * from "babylonjs/Particles/particleSystem";
  59556. export * from "babylonjs/Particles/particleSystemComponent";
  59557. export * from "babylonjs/Particles/particleSystemSet";
  59558. export * from "babylonjs/Particles/solidParticle";
  59559. export * from "babylonjs/Particles/solidParticleSystem";
  59560. export * from "babylonjs/Particles/subEmitter";
  59561. }
  59562. declare module "babylonjs/Physics/physicsEngineComponent" {
  59563. import { Nullable } from "babylonjs/types";
  59564. import { Observable, Observer } from "babylonjs/Misc/observable";
  59565. import { Vector3 } from "babylonjs/Maths/math.vector";
  59566. import { Mesh } from "babylonjs/Meshes/mesh";
  59567. import { ISceneComponent } from "babylonjs/sceneComponent";
  59568. import { Scene } from "babylonjs/scene";
  59569. import { Node } from "babylonjs/node";
  59570. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59571. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59572. module "babylonjs/scene" {
  59573. interface Scene {
  59574. /** @hidden (Backing field) */
  59575. _physicsEngine: Nullable<IPhysicsEngine>;
  59576. /**
  59577. * Gets the current physics engine
  59578. * @returns a IPhysicsEngine or null if none attached
  59579. */
  59580. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59581. /**
  59582. * Enables physics to the current scene
  59583. * @param gravity defines the scene's gravity for the physics engine
  59584. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59585. * @return a boolean indicating if the physics engine was initialized
  59586. */
  59587. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59588. /**
  59589. * Disables and disposes the physics engine associated with the scene
  59590. */
  59591. disablePhysicsEngine(): void;
  59592. /**
  59593. * Gets a boolean indicating if there is an active physics engine
  59594. * @returns a boolean indicating if there is an active physics engine
  59595. */
  59596. isPhysicsEnabled(): boolean;
  59597. /**
  59598. * Deletes a physics compound impostor
  59599. * @param compound defines the compound to delete
  59600. */
  59601. deleteCompoundImpostor(compound: any): void;
  59602. /**
  59603. * An event triggered when physic simulation is about to be run
  59604. */
  59605. onBeforePhysicsObservable: Observable<Scene>;
  59606. /**
  59607. * An event triggered when physic simulation has been done
  59608. */
  59609. onAfterPhysicsObservable: Observable<Scene>;
  59610. }
  59611. }
  59612. module "babylonjs/Meshes/abstractMesh" {
  59613. interface AbstractMesh {
  59614. /** @hidden */
  59615. _physicsImpostor: Nullable<PhysicsImpostor>;
  59616. /**
  59617. * Gets or sets impostor used for physic simulation
  59618. * @see http://doc.babylonjs.com/features/physics_engine
  59619. */
  59620. physicsImpostor: Nullable<PhysicsImpostor>;
  59621. /**
  59622. * Gets the current physics impostor
  59623. * @see http://doc.babylonjs.com/features/physics_engine
  59624. * @returns a physics impostor or null
  59625. */
  59626. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59627. /** Apply a physic impulse to the mesh
  59628. * @param force defines the force to apply
  59629. * @param contactPoint defines where to apply the force
  59630. * @returns the current mesh
  59631. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59632. */
  59633. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59634. /**
  59635. * Creates a physic joint between two meshes
  59636. * @param otherMesh defines the other mesh to use
  59637. * @param pivot1 defines the pivot to use on this mesh
  59638. * @param pivot2 defines the pivot to use on the other mesh
  59639. * @param options defines additional options (can be plugin dependent)
  59640. * @returns the current mesh
  59641. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59642. */
  59643. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59644. /** @hidden */
  59645. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59646. }
  59647. }
  59648. /**
  59649. * Defines the physics engine scene component responsible to manage a physics engine
  59650. */
  59651. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59652. /**
  59653. * The component name helpful to identify the component in the list of scene components.
  59654. */
  59655. readonly name: string;
  59656. /**
  59657. * The scene the component belongs to.
  59658. */
  59659. scene: Scene;
  59660. /**
  59661. * Creates a new instance of the component for the given scene
  59662. * @param scene Defines the scene to register the component in
  59663. */
  59664. constructor(scene: Scene);
  59665. /**
  59666. * Registers the component in a given scene
  59667. */
  59668. register(): void;
  59669. /**
  59670. * Rebuilds the elements related to this component in case of
  59671. * context lost for instance.
  59672. */
  59673. rebuild(): void;
  59674. /**
  59675. * Disposes the component and the associated ressources
  59676. */
  59677. dispose(): void;
  59678. }
  59679. }
  59680. declare module "babylonjs/Physics/physicsHelper" {
  59681. import { Nullable } from "babylonjs/types";
  59682. import { Vector3 } from "babylonjs/Maths/math.vector";
  59683. import { Mesh } from "babylonjs/Meshes/mesh";
  59684. import { Scene } from "babylonjs/scene";
  59685. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59686. /**
  59687. * A helper for physics simulations
  59688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59689. */
  59690. export class PhysicsHelper {
  59691. private _scene;
  59692. private _physicsEngine;
  59693. /**
  59694. * Initializes the Physics helper
  59695. * @param scene Babylon.js scene
  59696. */
  59697. constructor(scene: Scene);
  59698. /**
  59699. * Applies a radial explosion impulse
  59700. * @param origin the origin of the explosion
  59701. * @param radiusOrEventOptions the radius or the options of radial explosion
  59702. * @param strength the explosion strength
  59703. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59704. * @returns A physics radial explosion event, or null
  59705. */
  59706. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59707. /**
  59708. * Applies a radial explosion force
  59709. * @param origin the origin of the explosion
  59710. * @param radiusOrEventOptions the radius or the options of radial explosion
  59711. * @param strength the explosion strength
  59712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59713. * @returns A physics radial explosion event, or null
  59714. */
  59715. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59716. /**
  59717. * Creates a gravitational field
  59718. * @param origin the origin of the explosion
  59719. * @param radiusOrEventOptions the radius or the options of radial explosion
  59720. * @param strength the explosion strength
  59721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59722. * @returns A physics gravitational field event, or null
  59723. */
  59724. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59725. /**
  59726. * Creates a physics updraft event
  59727. * @param origin the origin of the updraft
  59728. * @param radiusOrEventOptions the radius or the options of the updraft
  59729. * @param strength the strength of the updraft
  59730. * @param height the height of the updraft
  59731. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59732. * @returns A physics updraft event, or null
  59733. */
  59734. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59735. /**
  59736. * Creates a physics vortex event
  59737. * @param origin the of the vortex
  59738. * @param radiusOrEventOptions the radius or the options of the vortex
  59739. * @param strength the strength of the vortex
  59740. * @param height the height of the vortex
  59741. * @returns a Physics vortex event, or null
  59742. * A physics vortex event or null
  59743. */
  59744. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59745. }
  59746. /**
  59747. * Represents a physics radial explosion event
  59748. */
  59749. class PhysicsRadialExplosionEvent {
  59750. private _scene;
  59751. private _options;
  59752. private _sphere;
  59753. private _dataFetched;
  59754. /**
  59755. * Initializes a radial explosioin event
  59756. * @param _scene BabylonJS scene
  59757. * @param _options The options for the vortex event
  59758. */
  59759. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59760. /**
  59761. * Returns the data related to the radial explosion event (sphere).
  59762. * @returns The radial explosion event data
  59763. */
  59764. getData(): PhysicsRadialExplosionEventData;
  59765. /**
  59766. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59767. * @param impostor A physics imposter
  59768. * @param origin the origin of the explosion
  59769. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59770. */
  59771. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59772. /**
  59773. * Triggers affecterd impostors callbacks
  59774. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59775. */
  59776. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59777. /**
  59778. * Disposes the sphere.
  59779. * @param force Specifies if the sphere should be disposed by force
  59780. */
  59781. dispose(force?: boolean): void;
  59782. /*** Helpers ***/
  59783. private _prepareSphere;
  59784. private _intersectsWithSphere;
  59785. }
  59786. /**
  59787. * Represents a gravitational field event
  59788. */
  59789. class PhysicsGravitationalFieldEvent {
  59790. private _physicsHelper;
  59791. private _scene;
  59792. private _origin;
  59793. private _options;
  59794. private _tickCallback;
  59795. private _sphere;
  59796. private _dataFetched;
  59797. /**
  59798. * Initializes the physics gravitational field event
  59799. * @param _physicsHelper A physics helper
  59800. * @param _scene BabylonJS scene
  59801. * @param _origin The origin position of the gravitational field event
  59802. * @param _options The options for the vortex event
  59803. */
  59804. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59805. /**
  59806. * Returns the data related to the gravitational field event (sphere).
  59807. * @returns A gravitational field event
  59808. */
  59809. getData(): PhysicsGravitationalFieldEventData;
  59810. /**
  59811. * Enables the gravitational field.
  59812. */
  59813. enable(): void;
  59814. /**
  59815. * Disables the gravitational field.
  59816. */
  59817. disable(): void;
  59818. /**
  59819. * Disposes the sphere.
  59820. * @param force The force to dispose from the gravitational field event
  59821. */
  59822. dispose(force?: boolean): void;
  59823. private _tick;
  59824. }
  59825. /**
  59826. * Represents a physics updraft event
  59827. */
  59828. class PhysicsUpdraftEvent {
  59829. private _scene;
  59830. private _origin;
  59831. private _options;
  59832. private _physicsEngine;
  59833. private _originTop;
  59834. private _originDirection;
  59835. private _tickCallback;
  59836. private _cylinder;
  59837. private _cylinderPosition;
  59838. private _dataFetched;
  59839. /**
  59840. * Initializes the physics updraft event
  59841. * @param _scene BabylonJS scene
  59842. * @param _origin The origin position of the updraft
  59843. * @param _options The options for the updraft event
  59844. */
  59845. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59846. /**
  59847. * Returns the data related to the updraft event (cylinder).
  59848. * @returns A physics updraft event
  59849. */
  59850. getData(): PhysicsUpdraftEventData;
  59851. /**
  59852. * Enables the updraft.
  59853. */
  59854. enable(): void;
  59855. /**
  59856. * Disables the updraft.
  59857. */
  59858. disable(): void;
  59859. /**
  59860. * Disposes the cylinder.
  59861. * @param force Specifies if the updraft should be disposed by force
  59862. */
  59863. dispose(force?: boolean): void;
  59864. private getImpostorHitData;
  59865. private _tick;
  59866. /*** Helpers ***/
  59867. private _prepareCylinder;
  59868. private _intersectsWithCylinder;
  59869. }
  59870. /**
  59871. * Represents a physics vortex event
  59872. */
  59873. class PhysicsVortexEvent {
  59874. private _scene;
  59875. private _origin;
  59876. private _options;
  59877. private _physicsEngine;
  59878. private _originTop;
  59879. private _tickCallback;
  59880. private _cylinder;
  59881. private _cylinderPosition;
  59882. private _dataFetched;
  59883. /**
  59884. * Initializes the physics vortex event
  59885. * @param _scene The BabylonJS scene
  59886. * @param _origin The origin position of the vortex
  59887. * @param _options The options for the vortex event
  59888. */
  59889. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59890. /**
  59891. * Returns the data related to the vortex event (cylinder).
  59892. * @returns The physics vortex event data
  59893. */
  59894. getData(): PhysicsVortexEventData;
  59895. /**
  59896. * Enables the vortex.
  59897. */
  59898. enable(): void;
  59899. /**
  59900. * Disables the cortex.
  59901. */
  59902. disable(): void;
  59903. /**
  59904. * Disposes the sphere.
  59905. * @param force
  59906. */
  59907. dispose(force?: boolean): void;
  59908. private getImpostorHitData;
  59909. private _tick;
  59910. /*** Helpers ***/
  59911. private _prepareCylinder;
  59912. private _intersectsWithCylinder;
  59913. }
  59914. /**
  59915. * Options fot the radial explosion event
  59916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59917. */
  59918. export class PhysicsRadialExplosionEventOptions {
  59919. /**
  59920. * The radius of the sphere for the radial explosion.
  59921. */
  59922. radius: number;
  59923. /**
  59924. * The strenth of the explosion.
  59925. */
  59926. strength: number;
  59927. /**
  59928. * The strenght of the force in correspondence to the distance of the affected object
  59929. */
  59930. falloff: PhysicsRadialImpulseFalloff;
  59931. /**
  59932. * Sphere options for the radial explosion.
  59933. */
  59934. sphere: {
  59935. segments: number;
  59936. diameter: number;
  59937. };
  59938. /**
  59939. * Sphere options for the radial explosion.
  59940. */
  59941. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59942. }
  59943. /**
  59944. * Options fot the updraft event
  59945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59946. */
  59947. export class PhysicsUpdraftEventOptions {
  59948. /**
  59949. * The radius of the cylinder for the vortex
  59950. */
  59951. radius: number;
  59952. /**
  59953. * The strenth of the updraft.
  59954. */
  59955. strength: number;
  59956. /**
  59957. * The height of the cylinder for the updraft.
  59958. */
  59959. height: number;
  59960. /**
  59961. * The mode for the the updraft.
  59962. */
  59963. updraftMode: PhysicsUpdraftMode;
  59964. }
  59965. /**
  59966. * Options fot the vortex event
  59967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59968. */
  59969. export class PhysicsVortexEventOptions {
  59970. /**
  59971. * The radius of the cylinder for the vortex
  59972. */
  59973. radius: number;
  59974. /**
  59975. * The strenth of the vortex.
  59976. */
  59977. strength: number;
  59978. /**
  59979. * The height of the cylinder for the vortex.
  59980. */
  59981. height: number;
  59982. /**
  59983. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59984. */
  59985. centripetalForceThreshold: number;
  59986. /**
  59987. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59988. */
  59989. centripetalForceMultiplier: number;
  59990. /**
  59991. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59992. */
  59993. centrifugalForceMultiplier: number;
  59994. /**
  59995. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59996. */
  59997. updraftForceMultiplier: number;
  59998. }
  59999. /**
  60000. * The strenght of the force in correspondence to the distance of the affected object
  60001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60002. */
  60003. export enum PhysicsRadialImpulseFalloff {
  60004. /** Defines that impulse is constant in strength across it's whole radius */
  60005. Constant = 0,
  60006. /** Defines that impulse gets weaker if it's further from the origin */
  60007. Linear = 1
  60008. }
  60009. /**
  60010. * The strength of the force in correspondence to the distance of the affected object
  60011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60012. */
  60013. export enum PhysicsUpdraftMode {
  60014. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60015. Center = 0,
  60016. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60017. Perpendicular = 1
  60018. }
  60019. /**
  60020. * Interface for a physics hit data
  60021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60022. */
  60023. export interface PhysicsHitData {
  60024. /**
  60025. * The force applied at the contact point
  60026. */
  60027. force: Vector3;
  60028. /**
  60029. * The contact point
  60030. */
  60031. contactPoint: Vector3;
  60032. /**
  60033. * The distance from the origin to the contact point
  60034. */
  60035. distanceFromOrigin: number;
  60036. }
  60037. /**
  60038. * Interface for radial explosion event data
  60039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60040. */
  60041. export interface PhysicsRadialExplosionEventData {
  60042. /**
  60043. * A sphere used for the radial explosion event
  60044. */
  60045. sphere: Mesh;
  60046. }
  60047. /**
  60048. * Interface for gravitational field event data
  60049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60050. */
  60051. export interface PhysicsGravitationalFieldEventData {
  60052. /**
  60053. * A sphere mesh used for the gravitational field event
  60054. */
  60055. sphere: Mesh;
  60056. }
  60057. /**
  60058. * Interface for updraft event data
  60059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60060. */
  60061. export interface PhysicsUpdraftEventData {
  60062. /**
  60063. * A cylinder used for the updraft event
  60064. */
  60065. cylinder: Mesh;
  60066. }
  60067. /**
  60068. * Interface for vortex event data
  60069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60070. */
  60071. export interface PhysicsVortexEventData {
  60072. /**
  60073. * A cylinder used for the vortex event
  60074. */
  60075. cylinder: Mesh;
  60076. }
  60077. /**
  60078. * Interface for an affected physics impostor
  60079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60080. */
  60081. export interface PhysicsAffectedImpostorWithData {
  60082. /**
  60083. * The impostor affected by the effect
  60084. */
  60085. impostor: PhysicsImpostor;
  60086. /**
  60087. * The data about the hit/horce from the explosion
  60088. */
  60089. hitData: PhysicsHitData;
  60090. }
  60091. }
  60092. declare module "babylonjs/Physics/Plugins/index" {
  60093. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60094. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60095. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60096. }
  60097. declare module "babylonjs/Physics/index" {
  60098. export * from "babylonjs/Physics/IPhysicsEngine";
  60099. export * from "babylonjs/Physics/physicsEngine";
  60100. export * from "babylonjs/Physics/physicsEngineComponent";
  60101. export * from "babylonjs/Physics/physicsHelper";
  60102. export * from "babylonjs/Physics/physicsImpostor";
  60103. export * from "babylonjs/Physics/physicsJoint";
  60104. export * from "babylonjs/Physics/Plugins/index";
  60105. }
  60106. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60107. /** @hidden */
  60108. export var blackAndWhitePixelShader: {
  60109. name: string;
  60110. shader: string;
  60111. };
  60112. }
  60113. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60114. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60115. import { Camera } from "babylonjs/Cameras/camera";
  60116. import { Engine } from "babylonjs/Engines/engine";
  60117. import "babylonjs/Shaders/blackAndWhite.fragment";
  60118. /**
  60119. * Post process used to render in black and white
  60120. */
  60121. export class BlackAndWhitePostProcess extends PostProcess {
  60122. /**
  60123. * Linear about to convert he result to black and white (default: 1)
  60124. */
  60125. degree: number;
  60126. /**
  60127. * Creates a black and white post process
  60128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60129. * @param name The name of the effect.
  60130. * @param options The required width/height ratio to downsize to before computing the render pass.
  60131. * @param camera The camera to apply the render pass to.
  60132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60133. * @param engine The engine which the post process will be applied. (default: current engine)
  60134. * @param reusable If the post process can be reused on the same frame. (default: false)
  60135. */
  60136. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60137. }
  60138. }
  60139. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60140. import { Nullable } from "babylonjs/types";
  60141. import { Camera } from "babylonjs/Cameras/camera";
  60142. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60143. import { Engine } from "babylonjs/Engines/engine";
  60144. /**
  60145. * This represents a set of one or more post processes in Babylon.
  60146. * A post process can be used to apply a shader to a texture after it is rendered.
  60147. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60148. */
  60149. export class PostProcessRenderEffect {
  60150. private _postProcesses;
  60151. private _getPostProcesses;
  60152. private _singleInstance;
  60153. private _cameras;
  60154. private _indicesForCamera;
  60155. /**
  60156. * Name of the effect
  60157. * @hidden
  60158. */
  60159. _name: string;
  60160. /**
  60161. * Instantiates a post process render effect.
  60162. * A post process can be used to apply a shader to a texture after it is rendered.
  60163. * @param engine The engine the effect is tied to
  60164. * @param name The name of the effect
  60165. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60166. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60167. */
  60168. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60169. /**
  60170. * Checks if all the post processes in the effect are supported.
  60171. */
  60172. readonly isSupported: boolean;
  60173. /**
  60174. * Updates the current state of the effect
  60175. * @hidden
  60176. */
  60177. _update(): void;
  60178. /**
  60179. * Attaches the effect on cameras
  60180. * @param cameras The camera to attach to.
  60181. * @hidden
  60182. */
  60183. _attachCameras(cameras: Camera): void;
  60184. /**
  60185. * Attaches the effect on cameras
  60186. * @param cameras The camera to attach to.
  60187. * @hidden
  60188. */
  60189. _attachCameras(cameras: Camera[]): void;
  60190. /**
  60191. * Detaches the effect on cameras
  60192. * @param cameras The camera to detatch from.
  60193. * @hidden
  60194. */
  60195. _detachCameras(cameras: Camera): void;
  60196. /**
  60197. * Detatches the effect on cameras
  60198. * @param cameras The camera to detatch from.
  60199. * @hidden
  60200. */
  60201. _detachCameras(cameras: Camera[]): void;
  60202. /**
  60203. * Enables the effect on given cameras
  60204. * @param cameras The camera to enable.
  60205. * @hidden
  60206. */
  60207. _enable(cameras: Camera): void;
  60208. /**
  60209. * Enables the effect on given cameras
  60210. * @param cameras The camera to enable.
  60211. * @hidden
  60212. */
  60213. _enable(cameras: Nullable<Camera[]>): void;
  60214. /**
  60215. * Disables the effect on the given cameras
  60216. * @param cameras The camera to disable.
  60217. * @hidden
  60218. */
  60219. _disable(cameras: Camera): void;
  60220. /**
  60221. * Disables the effect on the given cameras
  60222. * @param cameras The camera to disable.
  60223. * @hidden
  60224. */
  60225. _disable(cameras: Nullable<Camera[]>): void;
  60226. /**
  60227. * Gets a list of the post processes contained in the effect.
  60228. * @param camera The camera to get the post processes on.
  60229. * @returns The list of the post processes in the effect.
  60230. */
  60231. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60232. }
  60233. }
  60234. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60235. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60236. /** @hidden */
  60237. export var extractHighlightsPixelShader: {
  60238. name: string;
  60239. shader: string;
  60240. };
  60241. }
  60242. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60243. import { Nullable } from "babylonjs/types";
  60244. import { Camera } from "babylonjs/Cameras/camera";
  60245. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60246. import { Engine } from "babylonjs/Engines/engine";
  60247. import "babylonjs/Shaders/extractHighlights.fragment";
  60248. /**
  60249. * 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.
  60250. */
  60251. export class ExtractHighlightsPostProcess extends PostProcess {
  60252. /**
  60253. * The luminance threshold, pixels below this value will be set to black.
  60254. */
  60255. threshold: number;
  60256. /** @hidden */
  60257. _exposure: number;
  60258. /**
  60259. * Post process which has the input texture to be used when performing highlight extraction
  60260. * @hidden
  60261. */
  60262. _inputPostProcess: Nullable<PostProcess>;
  60263. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60264. }
  60265. }
  60266. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60267. /** @hidden */
  60268. export var bloomMergePixelShader: {
  60269. name: string;
  60270. shader: string;
  60271. };
  60272. }
  60273. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60275. import { Nullable } from "babylonjs/types";
  60276. import { Engine } from "babylonjs/Engines/engine";
  60277. import { Camera } from "babylonjs/Cameras/camera";
  60278. import "babylonjs/Shaders/bloomMerge.fragment";
  60279. /**
  60280. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60281. */
  60282. export class BloomMergePostProcess extends PostProcess {
  60283. /** Weight of the bloom to be added to the original input. */
  60284. weight: number;
  60285. /**
  60286. * Creates a new instance of @see BloomMergePostProcess
  60287. * @param name The name of the effect.
  60288. * @param originalFromInput Post process which's input will be used for the merge.
  60289. * @param blurred Blurred highlights post process which's output will be used.
  60290. * @param weight Weight of the bloom to be added to the original input.
  60291. * @param options The required width/height ratio to downsize to before computing the render pass.
  60292. * @param camera The camera to apply the render pass to.
  60293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60294. * @param engine The engine which the post process will be applied. (default: current engine)
  60295. * @param reusable If the post process can be reused on the same frame. (default: false)
  60296. * @param textureType Type of textures used when performing the post process. (default: 0)
  60297. * @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)
  60298. */
  60299. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60300. /** Weight of the bloom to be added to the original input. */
  60301. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60302. }
  60303. }
  60304. declare module "babylonjs/PostProcesses/bloomEffect" {
  60305. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60306. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60307. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60308. import { Camera } from "babylonjs/Cameras/camera";
  60309. import { Scene } from "babylonjs/scene";
  60310. /**
  60311. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60312. */
  60313. export class BloomEffect extends PostProcessRenderEffect {
  60314. private bloomScale;
  60315. /**
  60316. * @hidden Internal
  60317. */
  60318. _effects: Array<PostProcess>;
  60319. /**
  60320. * @hidden Internal
  60321. */
  60322. _downscale: ExtractHighlightsPostProcess;
  60323. private _blurX;
  60324. private _blurY;
  60325. private _merge;
  60326. /**
  60327. * The luminance threshold to find bright areas of the image to bloom.
  60328. */
  60329. threshold: number;
  60330. /**
  60331. * The strength of the bloom.
  60332. */
  60333. weight: number;
  60334. /**
  60335. * Specifies the size of the bloom blur kernel, relative to the final output size
  60336. */
  60337. kernel: number;
  60338. /**
  60339. * Creates a new instance of @see BloomEffect
  60340. * @param scene The scene the effect belongs to.
  60341. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60342. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60343. * @param bloomWeight The the strength of bloom.
  60344. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60345. * @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)
  60346. */
  60347. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60348. /**
  60349. * Disposes each of the internal effects for a given camera.
  60350. * @param camera The camera to dispose the effect on.
  60351. */
  60352. disposeEffects(camera: Camera): void;
  60353. /**
  60354. * @hidden Internal
  60355. */
  60356. _updateEffects(): void;
  60357. /**
  60358. * Internal
  60359. * @returns if all the contained post processes are ready.
  60360. * @hidden
  60361. */
  60362. _isReady(): boolean;
  60363. }
  60364. }
  60365. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60366. /** @hidden */
  60367. export var chromaticAberrationPixelShader: {
  60368. name: string;
  60369. shader: string;
  60370. };
  60371. }
  60372. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60373. import { Vector2 } from "babylonjs/Maths/math.vector";
  60374. import { Nullable } from "babylonjs/types";
  60375. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60376. import { Camera } from "babylonjs/Cameras/camera";
  60377. import { Engine } from "babylonjs/Engines/engine";
  60378. import "babylonjs/Shaders/chromaticAberration.fragment";
  60379. /**
  60380. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60381. */
  60382. export class ChromaticAberrationPostProcess extends PostProcess {
  60383. /**
  60384. * The amount of seperation of rgb channels (default: 30)
  60385. */
  60386. aberrationAmount: number;
  60387. /**
  60388. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60389. */
  60390. radialIntensity: number;
  60391. /**
  60392. * 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))
  60393. */
  60394. direction: Vector2;
  60395. /**
  60396. * 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))
  60397. */
  60398. centerPosition: Vector2;
  60399. /**
  60400. * Creates a new instance ChromaticAberrationPostProcess
  60401. * @param name The name of the effect.
  60402. * @param screenWidth The width of the screen to apply the effect on.
  60403. * @param screenHeight The height of the screen to apply the effect on.
  60404. * @param options The required width/height ratio to downsize to before computing the render pass.
  60405. * @param camera The camera to apply the render pass to.
  60406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60407. * @param engine The engine which the post process will be applied. (default: current engine)
  60408. * @param reusable If the post process can be reused on the same frame. (default: false)
  60409. * @param textureType Type of textures used when performing the post process. (default: 0)
  60410. * @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)
  60411. */
  60412. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60413. }
  60414. }
  60415. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60416. /** @hidden */
  60417. export var circleOfConfusionPixelShader: {
  60418. name: string;
  60419. shader: string;
  60420. };
  60421. }
  60422. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60423. import { Nullable } from "babylonjs/types";
  60424. import { Engine } from "babylonjs/Engines/engine";
  60425. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60427. import { Camera } from "babylonjs/Cameras/camera";
  60428. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60429. /**
  60430. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60431. */
  60432. export class CircleOfConfusionPostProcess extends PostProcess {
  60433. /**
  60434. * 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.
  60435. */
  60436. lensSize: number;
  60437. /**
  60438. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60439. */
  60440. fStop: number;
  60441. /**
  60442. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60443. */
  60444. focusDistance: number;
  60445. /**
  60446. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60447. */
  60448. focalLength: number;
  60449. private _depthTexture;
  60450. /**
  60451. * Creates a new instance CircleOfConfusionPostProcess
  60452. * @param name The name of the effect.
  60453. * @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.
  60454. * @param options The required width/height ratio to downsize to before computing the render pass.
  60455. * @param camera The camera to apply the render pass to.
  60456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60457. * @param engine The engine which the post process will be applied. (default: current engine)
  60458. * @param reusable If the post process can be reused on the same frame. (default: false)
  60459. * @param textureType Type of textures used when performing the post process. (default: 0)
  60460. * @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)
  60461. */
  60462. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60463. /**
  60464. * 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.
  60465. */
  60466. depthTexture: RenderTargetTexture;
  60467. }
  60468. }
  60469. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60470. /** @hidden */
  60471. export var colorCorrectionPixelShader: {
  60472. name: string;
  60473. shader: string;
  60474. };
  60475. }
  60476. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60478. import { Engine } from "babylonjs/Engines/engine";
  60479. import { Camera } from "babylonjs/Cameras/camera";
  60480. import "babylonjs/Shaders/colorCorrection.fragment";
  60481. /**
  60482. *
  60483. * This post-process allows the modification of rendered colors by using
  60484. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60485. *
  60486. * The object needs to be provided an url to a texture containing the color
  60487. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60488. * Use an image editing software to tweak the LUT to match your needs.
  60489. *
  60490. * For an example of a color LUT, see here:
  60491. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60492. * For explanations on color grading, see here:
  60493. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60494. *
  60495. */
  60496. export class ColorCorrectionPostProcess extends PostProcess {
  60497. private _colorTableTexture;
  60498. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60499. }
  60500. }
  60501. declare module "babylonjs/Shaders/convolution.fragment" {
  60502. /** @hidden */
  60503. export var convolutionPixelShader: {
  60504. name: string;
  60505. shader: string;
  60506. };
  60507. }
  60508. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60509. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60510. import { Nullable } from "babylonjs/types";
  60511. import { Camera } from "babylonjs/Cameras/camera";
  60512. import { Engine } from "babylonjs/Engines/engine";
  60513. import "babylonjs/Shaders/convolution.fragment";
  60514. /**
  60515. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60516. * input texture to perform effects such as edge detection or sharpening
  60517. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60518. */
  60519. export class ConvolutionPostProcess extends PostProcess {
  60520. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60521. kernel: number[];
  60522. /**
  60523. * Creates a new instance ConvolutionPostProcess
  60524. * @param name The name of the effect.
  60525. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60526. * @param options The required width/height ratio to downsize to before computing the render pass.
  60527. * @param camera The camera to apply the render pass to.
  60528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60529. * @param engine The engine which the post process will be applied. (default: current engine)
  60530. * @param reusable If the post process can be reused on the same frame. (default: false)
  60531. * @param textureType Type of textures used when performing the post process. (default: 0)
  60532. */
  60533. constructor(name: string,
  60534. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60535. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60536. /**
  60537. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60538. */
  60539. static EdgeDetect0Kernel: number[];
  60540. /**
  60541. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60542. */
  60543. static EdgeDetect1Kernel: number[];
  60544. /**
  60545. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60546. */
  60547. static EdgeDetect2Kernel: number[];
  60548. /**
  60549. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60550. */
  60551. static SharpenKernel: number[];
  60552. /**
  60553. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60554. */
  60555. static EmbossKernel: number[];
  60556. /**
  60557. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60558. */
  60559. static GaussianKernel: number[];
  60560. }
  60561. }
  60562. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60563. import { Nullable } from "babylonjs/types";
  60564. import { Vector2 } from "babylonjs/Maths/math.vector";
  60565. import { Camera } from "babylonjs/Cameras/camera";
  60566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60567. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60568. import { Engine } from "babylonjs/Engines/engine";
  60569. import { Scene } from "babylonjs/scene";
  60570. /**
  60571. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60572. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60573. * based on samples that have a large difference in distance than the center pixel.
  60574. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60575. */
  60576. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60577. direction: Vector2;
  60578. /**
  60579. * Creates a new instance CircleOfConfusionPostProcess
  60580. * @param name The name of the effect.
  60581. * @param scene The scene the effect belongs to.
  60582. * @param direction The direction the blur should be applied.
  60583. * @param kernel The size of the kernel used to blur.
  60584. * @param options The required width/height ratio to downsize to before computing the render pass.
  60585. * @param camera The camera to apply the render pass to.
  60586. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60587. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60589. * @param engine The engine which the post process will be applied. (default: current engine)
  60590. * @param reusable If the post process can be reused on the same frame. (default: false)
  60591. * @param textureType Type of textures used when performing the post process. (default: 0)
  60592. * @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)
  60593. */
  60594. 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);
  60595. }
  60596. }
  60597. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60598. /** @hidden */
  60599. export var depthOfFieldMergePixelShader: {
  60600. name: string;
  60601. shader: string;
  60602. };
  60603. }
  60604. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60605. import { Nullable } from "babylonjs/types";
  60606. import { Camera } from "babylonjs/Cameras/camera";
  60607. import { Effect } from "babylonjs/Materials/effect";
  60608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60609. import { Engine } from "babylonjs/Engines/engine";
  60610. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60611. /**
  60612. * Options to be set when merging outputs from the default pipeline.
  60613. */
  60614. export class DepthOfFieldMergePostProcessOptions {
  60615. /**
  60616. * The original image to merge on top of
  60617. */
  60618. originalFromInput: PostProcess;
  60619. /**
  60620. * Parameters to perform the merge of the depth of field effect
  60621. */
  60622. depthOfField?: {
  60623. circleOfConfusion: PostProcess;
  60624. blurSteps: Array<PostProcess>;
  60625. };
  60626. /**
  60627. * Parameters to perform the merge of bloom effect
  60628. */
  60629. bloom?: {
  60630. blurred: PostProcess;
  60631. weight: number;
  60632. };
  60633. }
  60634. /**
  60635. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60636. */
  60637. export class DepthOfFieldMergePostProcess extends PostProcess {
  60638. private blurSteps;
  60639. /**
  60640. * Creates a new instance of DepthOfFieldMergePostProcess
  60641. * @param name The name of the effect.
  60642. * @param originalFromInput Post process which's input will be used for the merge.
  60643. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60644. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60645. * @param options The required width/height ratio to downsize to before computing the render pass.
  60646. * @param camera The camera to apply the render pass to.
  60647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60648. * @param engine The engine which the post process will be applied. (default: current engine)
  60649. * @param reusable If the post process can be reused on the same frame. (default: false)
  60650. * @param textureType Type of textures used when performing the post process. (default: 0)
  60651. * @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)
  60652. */
  60653. 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);
  60654. /**
  60655. * Updates the effect with the current post process compile time values and recompiles the shader.
  60656. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60657. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60658. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60659. * @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
  60660. * @param onCompiled Called when the shader has been compiled.
  60661. * @param onError Called if there is an error when compiling a shader.
  60662. */
  60663. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60664. }
  60665. }
  60666. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60667. import { Nullable } from "babylonjs/types";
  60668. import { Camera } from "babylonjs/Cameras/camera";
  60669. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60670. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60671. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60672. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60673. import { Scene } from "babylonjs/scene";
  60674. /**
  60675. * Specifies the level of max blur that should be applied when using the depth of field effect
  60676. */
  60677. export enum DepthOfFieldEffectBlurLevel {
  60678. /**
  60679. * Subtle blur
  60680. */
  60681. Low = 0,
  60682. /**
  60683. * Medium blur
  60684. */
  60685. Medium = 1,
  60686. /**
  60687. * Large blur
  60688. */
  60689. High = 2
  60690. }
  60691. /**
  60692. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60693. */
  60694. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60695. private _circleOfConfusion;
  60696. /**
  60697. * @hidden Internal, blurs from high to low
  60698. */
  60699. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60700. private _depthOfFieldBlurY;
  60701. private _dofMerge;
  60702. /**
  60703. * @hidden Internal post processes in depth of field effect
  60704. */
  60705. _effects: Array<PostProcess>;
  60706. /**
  60707. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60708. */
  60709. focalLength: number;
  60710. /**
  60711. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60712. */
  60713. fStop: number;
  60714. /**
  60715. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60716. */
  60717. focusDistance: number;
  60718. /**
  60719. * 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.
  60720. */
  60721. lensSize: number;
  60722. /**
  60723. * Creates a new instance DepthOfFieldEffect
  60724. * @param scene The scene the effect belongs to.
  60725. * @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.
  60726. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60727. * @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)
  60728. */
  60729. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60730. /**
  60731. * Get the current class name of the current effet
  60732. * @returns "DepthOfFieldEffect"
  60733. */
  60734. getClassName(): string;
  60735. /**
  60736. * 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.
  60737. */
  60738. depthTexture: RenderTargetTexture;
  60739. /**
  60740. * Disposes each of the internal effects for a given camera.
  60741. * @param camera The camera to dispose the effect on.
  60742. */
  60743. disposeEffects(camera: Camera): void;
  60744. /**
  60745. * @hidden Internal
  60746. */
  60747. _updateEffects(): void;
  60748. /**
  60749. * Internal
  60750. * @returns if all the contained post processes are ready.
  60751. * @hidden
  60752. */
  60753. _isReady(): boolean;
  60754. }
  60755. }
  60756. declare module "babylonjs/Shaders/displayPass.fragment" {
  60757. /** @hidden */
  60758. export var displayPassPixelShader: {
  60759. name: string;
  60760. shader: string;
  60761. };
  60762. }
  60763. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60764. import { Nullable } from "babylonjs/types";
  60765. import { Camera } from "babylonjs/Cameras/camera";
  60766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60767. import { Engine } from "babylonjs/Engines/engine";
  60768. import "babylonjs/Shaders/displayPass.fragment";
  60769. /**
  60770. * DisplayPassPostProcess which produces an output the same as it's input
  60771. */
  60772. export class DisplayPassPostProcess extends PostProcess {
  60773. /**
  60774. * Creates the DisplayPassPostProcess
  60775. * @param name The name of the effect.
  60776. * @param options The required width/height ratio to downsize to before computing the render pass.
  60777. * @param camera The camera to apply the render pass to.
  60778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60779. * @param engine The engine which the post process will be applied. (default: current engine)
  60780. * @param reusable If the post process can be reused on the same frame. (default: false)
  60781. */
  60782. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60783. }
  60784. }
  60785. declare module "babylonjs/Shaders/filter.fragment" {
  60786. /** @hidden */
  60787. export var filterPixelShader: {
  60788. name: string;
  60789. shader: string;
  60790. };
  60791. }
  60792. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60793. import { Nullable } from "babylonjs/types";
  60794. import { Matrix } from "babylonjs/Maths/math.vector";
  60795. import { Camera } from "babylonjs/Cameras/camera";
  60796. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60797. import { Engine } from "babylonjs/Engines/engine";
  60798. import "babylonjs/Shaders/filter.fragment";
  60799. /**
  60800. * Applies a kernel filter to the image
  60801. */
  60802. export class FilterPostProcess extends PostProcess {
  60803. /** The matrix to be applied to the image */
  60804. kernelMatrix: Matrix;
  60805. /**
  60806. *
  60807. * @param name The name of the effect.
  60808. * @param kernelMatrix The matrix to be applied to the image
  60809. * @param options The required width/height ratio to downsize to before computing the render pass.
  60810. * @param camera The camera to apply the render pass to.
  60811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60812. * @param engine The engine which the post process will be applied. (default: current engine)
  60813. * @param reusable If the post process can be reused on the same frame. (default: false)
  60814. */
  60815. constructor(name: string,
  60816. /** The matrix to be applied to the image */
  60817. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60818. }
  60819. }
  60820. declare module "babylonjs/Shaders/fxaa.fragment" {
  60821. /** @hidden */
  60822. export var fxaaPixelShader: {
  60823. name: string;
  60824. shader: string;
  60825. };
  60826. }
  60827. declare module "babylonjs/Shaders/fxaa.vertex" {
  60828. /** @hidden */
  60829. export var fxaaVertexShader: {
  60830. name: string;
  60831. shader: string;
  60832. };
  60833. }
  60834. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60835. import { Nullable } from "babylonjs/types";
  60836. import { Camera } from "babylonjs/Cameras/camera";
  60837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60838. import { Engine } from "babylonjs/Engines/engine";
  60839. import "babylonjs/Shaders/fxaa.fragment";
  60840. import "babylonjs/Shaders/fxaa.vertex";
  60841. /**
  60842. * Fxaa post process
  60843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60844. */
  60845. export class FxaaPostProcess extends PostProcess {
  60846. /** @hidden */
  60847. texelWidth: number;
  60848. /** @hidden */
  60849. texelHeight: number;
  60850. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60851. private _getDefines;
  60852. }
  60853. }
  60854. declare module "babylonjs/Shaders/grain.fragment" {
  60855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60856. /** @hidden */
  60857. export var grainPixelShader: {
  60858. name: string;
  60859. shader: string;
  60860. };
  60861. }
  60862. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60863. import { Nullable } from "babylonjs/types";
  60864. import { Camera } from "babylonjs/Cameras/camera";
  60865. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60866. import { Engine } from "babylonjs/Engines/engine";
  60867. import "babylonjs/Shaders/grain.fragment";
  60868. /**
  60869. * The GrainPostProcess adds noise to the image at mid luminance levels
  60870. */
  60871. export class GrainPostProcess extends PostProcess {
  60872. /**
  60873. * The intensity of the grain added (default: 30)
  60874. */
  60875. intensity: number;
  60876. /**
  60877. * If the grain should be randomized on every frame
  60878. */
  60879. animated: boolean;
  60880. /**
  60881. * Creates a new instance of @see GrainPostProcess
  60882. * @param name The name of the effect.
  60883. * @param options The required width/height ratio to downsize to before computing the render pass.
  60884. * @param camera The camera to apply the render pass to.
  60885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60886. * @param engine The engine which the post process will be applied. (default: current engine)
  60887. * @param reusable If the post process can be reused on the same frame. (default: false)
  60888. * @param textureType Type of textures used when performing the post process. (default: 0)
  60889. * @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)
  60890. */
  60891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60892. }
  60893. }
  60894. declare module "babylonjs/Shaders/highlights.fragment" {
  60895. /** @hidden */
  60896. export var highlightsPixelShader: {
  60897. name: string;
  60898. shader: string;
  60899. };
  60900. }
  60901. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60902. import { Nullable } from "babylonjs/types";
  60903. import { Camera } from "babylonjs/Cameras/camera";
  60904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60905. import { Engine } from "babylonjs/Engines/engine";
  60906. import "babylonjs/Shaders/highlights.fragment";
  60907. /**
  60908. * Extracts highlights from the image
  60909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60910. */
  60911. export class HighlightsPostProcess extends PostProcess {
  60912. /**
  60913. * Extracts highlights from the image
  60914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60915. * @param name The name of the effect.
  60916. * @param options The required width/height ratio to downsize to before computing the render pass.
  60917. * @param camera The camera to apply the render pass to.
  60918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60919. * @param engine The engine which the post process will be applied. (default: current engine)
  60920. * @param reusable If the post process can be reused on the same frame. (default: false)
  60921. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60922. */
  60923. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60924. }
  60925. }
  60926. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60927. /** @hidden */
  60928. export var mrtFragmentDeclaration: {
  60929. name: string;
  60930. shader: string;
  60931. };
  60932. }
  60933. declare module "babylonjs/Shaders/geometry.fragment" {
  60934. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60935. /** @hidden */
  60936. export var geometryPixelShader: {
  60937. name: string;
  60938. shader: string;
  60939. };
  60940. }
  60941. declare module "babylonjs/Shaders/geometry.vertex" {
  60942. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60945. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60947. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60948. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60949. /** @hidden */
  60950. export var geometryVertexShader: {
  60951. name: string;
  60952. shader: string;
  60953. };
  60954. }
  60955. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60956. import { Matrix } from "babylonjs/Maths/math.vector";
  60957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60958. import { Mesh } from "babylonjs/Meshes/mesh";
  60959. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60960. import { Effect } from "babylonjs/Materials/effect";
  60961. import { Scene } from "babylonjs/scene";
  60962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60963. import "babylonjs/Shaders/geometry.fragment";
  60964. import "babylonjs/Shaders/geometry.vertex";
  60965. /** @hidden */
  60966. interface ISavedTransformationMatrix {
  60967. world: Matrix;
  60968. viewProjection: Matrix;
  60969. }
  60970. /**
  60971. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60972. */
  60973. export class GeometryBufferRenderer {
  60974. /**
  60975. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60976. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60977. */
  60978. static readonly POSITION_TEXTURE_TYPE: number;
  60979. /**
  60980. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60981. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60982. */
  60983. static readonly VELOCITY_TEXTURE_TYPE: number;
  60984. /**
  60985. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60986. * in order to compute objects velocities when enableVelocity is set to "true"
  60987. * @hidden
  60988. */
  60989. _previousTransformationMatrices: {
  60990. [index: number]: ISavedTransformationMatrix;
  60991. };
  60992. /**
  60993. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60994. * in order to compute objects velocities when enableVelocity is set to "true"
  60995. * @hidden
  60996. */
  60997. _previousBonesTransformationMatrices: {
  60998. [index: number]: Float32Array;
  60999. };
  61000. /**
  61001. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61002. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61003. */
  61004. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61005. private _scene;
  61006. private _multiRenderTarget;
  61007. private _ratio;
  61008. private _enablePosition;
  61009. private _enableVelocity;
  61010. private _positionIndex;
  61011. private _velocityIndex;
  61012. protected _effect: Effect;
  61013. protected _cachedDefines: string;
  61014. /**
  61015. * Set the render list (meshes to be rendered) used in the G buffer.
  61016. */
  61017. renderList: Mesh[];
  61018. /**
  61019. * Gets wether or not G buffer are supported by the running hardware.
  61020. * This requires draw buffer supports
  61021. */
  61022. readonly isSupported: boolean;
  61023. /**
  61024. * Returns the index of the given texture type in the G-Buffer textures array
  61025. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61026. * @returns the index of the given texture type in the G-Buffer textures array
  61027. */
  61028. getTextureIndex(textureType: number): number;
  61029. /**
  61030. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61031. */
  61032. /**
  61033. * Sets whether or not objects positions are enabled for the G buffer.
  61034. */
  61035. enablePosition: boolean;
  61036. /**
  61037. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61038. */
  61039. /**
  61040. * Sets wether or not objects velocities are enabled for the G buffer.
  61041. */
  61042. enableVelocity: boolean;
  61043. /**
  61044. * Gets the scene associated with the buffer.
  61045. */
  61046. readonly scene: Scene;
  61047. /**
  61048. * Gets the ratio used by the buffer during its creation.
  61049. * How big is the buffer related to the main canvas.
  61050. */
  61051. readonly ratio: number;
  61052. /** @hidden */
  61053. static _SceneComponentInitialization: (scene: Scene) => void;
  61054. /**
  61055. * Creates a new G Buffer for the scene
  61056. * @param scene The scene the buffer belongs to
  61057. * @param ratio How big is the buffer related to the main canvas.
  61058. */
  61059. constructor(scene: Scene, ratio?: number);
  61060. /**
  61061. * Checks wether everything is ready to render a submesh to the G buffer.
  61062. * @param subMesh the submesh to check readiness for
  61063. * @param useInstances is the mesh drawn using instance or not
  61064. * @returns true if ready otherwise false
  61065. */
  61066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61067. /**
  61068. * Gets the current underlying G Buffer.
  61069. * @returns the buffer
  61070. */
  61071. getGBuffer(): MultiRenderTarget;
  61072. /**
  61073. * Gets the number of samples used to render the buffer (anti aliasing).
  61074. */
  61075. /**
  61076. * Sets the number of samples used to render the buffer (anti aliasing).
  61077. */
  61078. samples: number;
  61079. /**
  61080. * Disposes the renderer and frees up associated resources.
  61081. */
  61082. dispose(): void;
  61083. protected _createRenderTargets(): void;
  61084. private _copyBonesTransformationMatrices;
  61085. }
  61086. }
  61087. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61088. import { Nullable } from "babylonjs/types";
  61089. import { Scene } from "babylonjs/scene";
  61090. import { ISceneComponent } from "babylonjs/sceneComponent";
  61091. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61092. module "babylonjs/scene" {
  61093. interface Scene {
  61094. /** @hidden (Backing field) */
  61095. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61096. /**
  61097. * Gets or Sets the current geometry buffer associated to the scene.
  61098. */
  61099. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61100. /**
  61101. * Enables a GeometryBufferRender and associates it with the scene
  61102. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61103. * @returns the GeometryBufferRenderer
  61104. */
  61105. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61106. /**
  61107. * Disables the GeometryBufferRender associated with the scene
  61108. */
  61109. disableGeometryBufferRenderer(): void;
  61110. }
  61111. }
  61112. /**
  61113. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61114. * in several rendering techniques.
  61115. */
  61116. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61117. /**
  61118. * The component name helpful to identify the component in the list of scene components.
  61119. */
  61120. readonly name: string;
  61121. /**
  61122. * The scene the component belongs to.
  61123. */
  61124. scene: Scene;
  61125. /**
  61126. * Creates a new instance of the component for the given scene
  61127. * @param scene Defines the scene to register the component in
  61128. */
  61129. constructor(scene: Scene);
  61130. /**
  61131. * Registers the component in a given scene
  61132. */
  61133. register(): void;
  61134. /**
  61135. * Rebuilds the elements related to this component in case of
  61136. * context lost for instance.
  61137. */
  61138. rebuild(): void;
  61139. /**
  61140. * Disposes the component and the associated ressources
  61141. */
  61142. dispose(): void;
  61143. private _gatherRenderTargets;
  61144. }
  61145. }
  61146. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61147. /** @hidden */
  61148. export var motionBlurPixelShader: {
  61149. name: string;
  61150. shader: string;
  61151. };
  61152. }
  61153. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61154. import { Nullable } from "babylonjs/types";
  61155. import { Camera } from "babylonjs/Cameras/camera";
  61156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61157. import { Scene } from "babylonjs/scene";
  61158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61159. import "babylonjs/Animations/animatable";
  61160. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61161. import "babylonjs/Shaders/motionBlur.fragment";
  61162. import { Engine } from "babylonjs/Engines/engine";
  61163. /**
  61164. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61165. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61166. * As an example, all you have to do is to create the post-process:
  61167. * var mb = new BABYLON.MotionBlurPostProcess(
  61168. * 'mb', // The name of the effect.
  61169. * scene, // The scene containing the objects to blur according to their velocity.
  61170. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61171. * camera // The camera to apply the render pass to.
  61172. * );
  61173. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61174. */
  61175. export class MotionBlurPostProcess extends PostProcess {
  61176. /**
  61177. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61178. */
  61179. motionStrength: number;
  61180. /**
  61181. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61182. */
  61183. /**
  61184. * Sets the number of iterations to be used for motion blur quality
  61185. */
  61186. motionBlurSamples: number;
  61187. private _motionBlurSamples;
  61188. private _geometryBufferRenderer;
  61189. /**
  61190. * Creates a new instance MotionBlurPostProcess
  61191. * @param name The name of the effect.
  61192. * @param scene The scene containing the objects to blur according to their velocity.
  61193. * @param options The required width/height ratio to downsize to before computing the render pass.
  61194. * @param camera The camera to apply the render pass to.
  61195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61196. * @param engine The engine which the post process will be applied. (default: current engine)
  61197. * @param reusable If the post process can be reused on the same frame. (default: false)
  61198. * @param textureType Type of textures used when performing the post process. (default: 0)
  61199. * @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)
  61200. */
  61201. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61202. /**
  61203. * Excludes the given skinned mesh from computing bones velocities.
  61204. * 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.
  61205. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61206. */
  61207. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61208. /**
  61209. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61210. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61211. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61212. */
  61213. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61214. /**
  61215. * Disposes the post process.
  61216. * @param camera The camera to dispose the post process on.
  61217. */
  61218. dispose(camera?: Camera): void;
  61219. }
  61220. }
  61221. declare module "babylonjs/Shaders/refraction.fragment" {
  61222. /** @hidden */
  61223. export var refractionPixelShader: {
  61224. name: string;
  61225. shader: string;
  61226. };
  61227. }
  61228. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61229. import { Color3 } from "babylonjs/Maths/math.color";
  61230. import { Camera } from "babylonjs/Cameras/camera";
  61231. import { Texture } from "babylonjs/Materials/Textures/texture";
  61232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61233. import { Engine } from "babylonjs/Engines/engine";
  61234. import "babylonjs/Shaders/refraction.fragment";
  61235. /**
  61236. * Post process which applies a refractin texture
  61237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61238. */
  61239. export class RefractionPostProcess extends PostProcess {
  61240. /** the base color of the refraction (used to taint the rendering) */
  61241. color: Color3;
  61242. /** simulated refraction depth */
  61243. depth: number;
  61244. /** the coefficient of the base color (0 to remove base color tainting) */
  61245. colorLevel: number;
  61246. private _refTexture;
  61247. private _ownRefractionTexture;
  61248. /**
  61249. * Gets or sets the refraction texture
  61250. * Please note that you are responsible for disposing the texture if you set it manually
  61251. */
  61252. refractionTexture: Texture;
  61253. /**
  61254. * Initializes the RefractionPostProcess
  61255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61256. * @param name The name of the effect.
  61257. * @param refractionTextureUrl Url of the refraction texture to use
  61258. * @param color the base color of the refraction (used to taint the rendering)
  61259. * @param depth simulated refraction depth
  61260. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61261. * @param camera The camera to apply the render pass to.
  61262. * @param options The required width/height ratio to downsize to before computing the render pass.
  61263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61264. * @param engine The engine which the post process will be applied. (default: current engine)
  61265. * @param reusable If the post process can be reused on the same frame. (default: false)
  61266. */
  61267. constructor(name: string, refractionTextureUrl: string,
  61268. /** the base color of the refraction (used to taint the rendering) */
  61269. color: Color3,
  61270. /** simulated refraction depth */
  61271. depth: number,
  61272. /** the coefficient of the base color (0 to remove base color tainting) */
  61273. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61274. /**
  61275. * Disposes of the post process
  61276. * @param camera Camera to dispose post process on
  61277. */
  61278. dispose(camera: Camera): void;
  61279. }
  61280. }
  61281. declare module "babylonjs/Shaders/sharpen.fragment" {
  61282. /** @hidden */
  61283. export var sharpenPixelShader: {
  61284. name: string;
  61285. shader: string;
  61286. };
  61287. }
  61288. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61289. import { Nullable } from "babylonjs/types";
  61290. import { Camera } from "babylonjs/Cameras/camera";
  61291. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61292. import "babylonjs/Shaders/sharpen.fragment";
  61293. import { Engine } from "babylonjs/Engines/engine";
  61294. /**
  61295. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61296. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61297. */
  61298. export class SharpenPostProcess extends PostProcess {
  61299. /**
  61300. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61301. */
  61302. colorAmount: number;
  61303. /**
  61304. * How much sharpness should be applied (default: 0.3)
  61305. */
  61306. edgeAmount: number;
  61307. /**
  61308. * Creates a new instance ConvolutionPostProcess
  61309. * @param name The name of the effect.
  61310. * @param options The required width/height ratio to downsize to before computing the render pass.
  61311. * @param camera The camera to apply the render pass to.
  61312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61313. * @param engine The engine which the post process will be applied. (default: current engine)
  61314. * @param reusable If the post process can be reused on the same frame. (default: false)
  61315. * @param textureType Type of textures used when performing the post process. (default: 0)
  61316. * @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)
  61317. */
  61318. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61319. }
  61320. }
  61321. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61322. import { Nullable } from "babylonjs/types";
  61323. import { Camera } from "babylonjs/Cameras/camera";
  61324. import { Engine } from "babylonjs/Engines/engine";
  61325. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61326. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61327. /**
  61328. * PostProcessRenderPipeline
  61329. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61330. */
  61331. export class PostProcessRenderPipeline {
  61332. private engine;
  61333. private _renderEffects;
  61334. private _renderEffectsForIsolatedPass;
  61335. /**
  61336. * List of inspectable custom properties (used by the Inspector)
  61337. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61338. */
  61339. inspectableCustomProperties: IInspectable[];
  61340. /**
  61341. * @hidden
  61342. */
  61343. protected _cameras: Camera[];
  61344. /** @hidden */
  61345. _name: string;
  61346. /**
  61347. * Gets pipeline name
  61348. */
  61349. readonly name: string;
  61350. /**
  61351. * Initializes a PostProcessRenderPipeline
  61352. * @param engine engine to add the pipeline to
  61353. * @param name name of the pipeline
  61354. */
  61355. constructor(engine: Engine, name: string);
  61356. /**
  61357. * Gets the class name
  61358. * @returns "PostProcessRenderPipeline"
  61359. */
  61360. getClassName(): string;
  61361. /**
  61362. * If all the render effects in the pipeline are supported
  61363. */
  61364. readonly isSupported: boolean;
  61365. /**
  61366. * Adds an effect to the pipeline
  61367. * @param renderEffect the effect to add
  61368. */
  61369. addEffect(renderEffect: PostProcessRenderEffect): void;
  61370. /** @hidden */
  61371. _rebuild(): void;
  61372. /** @hidden */
  61373. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61374. /** @hidden */
  61375. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61376. /** @hidden */
  61377. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61378. /** @hidden */
  61379. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61380. /** @hidden */
  61381. _attachCameras(cameras: Camera, unique: boolean): void;
  61382. /** @hidden */
  61383. _attachCameras(cameras: Camera[], unique: boolean): void;
  61384. /** @hidden */
  61385. _detachCameras(cameras: Camera): void;
  61386. /** @hidden */
  61387. _detachCameras(cameras: Nullable<Camera[]>): void;
  61388. /** @hidden */
  61389. _update(): void;
  61390. /** @hidden */
  61391. _reset(): void;
  61392. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61393. /**
  61394. * Disposes of the pipeline
  61395. */
  61396. dispose(): void;
  61397. }
  61398. }
  61399. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61400. import { Camera } from "babylonjs/Cameras/camera";
  61401. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61402. /**
  61403. * PostProcessRenderPipelineManager class
  61404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61405. */
  61406. export class PostProcessRenderPipelineManager {
  61407. private _renderPipelines;
  61408. /**
  61409. * Initializes a PostProcessRenderPipelineManager
  61410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61411. */
  61412. constructor();
  61413. /**
  61414. * Gets the list of supported render pipelines
  61415. */
  61416. readonly supportedPipelines: PostProcessRenderPipeline[];
  61417. /**
  61418. * Adds a pipeline to the manager
  61419. * @param renderPipeline The pipeline to add
  61420. */
  61421. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61422. /**
  61423. * Attaches a camera to the pipeline
  61424. * @param renderPipelineName The name of the pipeline to attach to
  61425. * @param cameras the camera to attach
  61426. * @param unique if the camera can be attached multiple times to the pipeline
  61427. */
  61428. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61429. /**
  61430. * Detaches a camera from the pipeline
  61431. * @param renderPipelineName The name of the pipeline to detach from
  61432. * @param cameras the camera to detach
  61433. */
  61434. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61435. /**
  61436. * Enables an effect by name on a pipeline
  61437. * @param renderPipelineName the name of the pipeline to enable the effect in
  61438. * @param renderEffectName the name of the effect to enable
  61439. * @param cameras the cameras that the effect should be enabled on
  61440. */
  61441. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61442. /**
  61443. * Disables an effect by name on a pipeline
  61444. * @param renderPipelineName the name of the pipeline to disable the effect in
  61445. * @param renderEffectName the name of the effect to disable
  61446. * @param cameras the cameras that the effect should be disabled on
  61447. */
  61448. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61449. /**
  61450. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61451. */
  61452. update(): void;
  61453. /** @hidden */
  61454. _rebuild(): void;
  61455. /**
  61456. * Disposes of the manager and pipelines
  61457. */
  61458. dispose(): void;
  61459. }
  61460. }
  61461. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61462. import { ISceneComponent } from "babylonjs/sceneComponent";
  61463. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61464. import { Scene } from "babylonjs/scene";
  61465. module "babylonjs/scene" {
  61466. interface Scene {
  61467. /** @hidden (Backing field) */
  61468. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61469. /**
  61470. * Gets the postprocess render pipeline manager
  61471. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61472. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61473. */
  61474. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61475. }
  61476. }
  61477. /**
  61478. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61479. */
  61480. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61481. /**
  61482. * The component name helpfull to identify the component in the list of scene components.
  61483. */
  61484. readonly name: string;
  61485. /**
  61486. * The scene the component belongs to.
  61487. */
  61488. scene: Scene;
  61489. /**
  61490. * Creates a new instance of the component for the given scene
  61491. * @param scene Defines the scene to register the component in
  61492. */
  61493. constructor(scene: Scene);
  61494. /**
  61495. * Registers the component in a given scene
  61496. */
  61497. register(): void;
  61498. /**
  61499. * Rebuilds the elements related to this component in case of
  61500. * context lost for instance.
  61501. */
  61502. rebuild(): void;
  61503. /**
  61504. * Disposes the component and the associated ressources
  61505. */
  61506. dispose(): void;
  61507. private _gatherRenderTargets;
  61508. }
  61509. }
  61510. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61511. import { Nullable } from "babylonjs/types";
  61512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61513. import { Camera } from "babylonjs/Cameras/camera";
  61514. import { IDisposable } from "babylonjs/scene";
  61515. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61516. import { Scene } from "babylonjs/scene";
  61517. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61518. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61519. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61520. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61521. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61522. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61523. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61524. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61525. import { Animation } from "babylonjs/Animations/animation";
  61526. /**
  61527. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61528. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61529. */
  61530. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61531. private _scene;
  61532. private _camerasToBeAttached;
  61533. /**
  61534. * ID of the sharpen post process,
  61535. */
  61536. private readonly SharpenPostProcessId;
  61537. /**
  61538. * @ignore
  61539. * ID of the image processing post process;
  61540. */
  61541. readonly ImageProcessingPostProcessId: string;
  61542. /**
  61543. * @ignore
  61544. * ID of the Fast Approximate Anti-Aliasing post process;
  61545. */
  61546. readonly FxaaPostProcessId: string;
  61547. /**
  61548. * ID of the chromatic aberration post process,
  61549. */
  61550. private readonly ChromaticAberrationPostProcessId;
  61551. /**
  61552. * ID of the grain post process
  61553. */
  61554. private readonly GrainPostProcessId;
  61555. /**
  61556. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61557. */
  61558. sharpen: SharpenPostProcess;
  61559. private _sharpenEffect;
  61560. private bloom;
  61561. /**
  61562. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61563. */
  61564. depthOfField: DepthOfFieldEffect;
  61565. /**
  61566. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61567. */
  61568. fxaa: FxaaPostProcess;
  61569. /**
  61570. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61571. */
  61572. imageProcessing: ImageProcessingPostProcess;
  61573. /**
  61574. * Chromatic aberration post process which will shift rgb colors in the image
  61575. */
  61576. chromaticAberration: ChromaticAberrationPostProcess;
  61577. private _chromaticAberrationEffect;
  61578. /**
  61579. * Grain post process which add noise to the image
  61580. */
  61581. grain: GrainPostProcess;
  61582. private _grainEffect;
  61583. /**
  61584. * Glow post process which adds a glow to emissive areas of the image
  61585. */
  61586. private _glowLayer;
  61587. /**
  61588. * Animations which can be used to tweak settings over a period of time
  61589. */
  61590. animations: Animation[];
  61591. private _imageProcessingConfigurationObserver;
  61592. private _sharpenEnabled;
  61593. private _bloomEnabled;
  61594. private _depthOfFieldEnabled;
  61595. private _depthOfFieldBlurLevel;
  61596. private _fxaaEnabled;
  61597. private _imageProcessingEnabled;
  61598. private _defaultPipelineTextureType;
  61599. private _bloomScale;
  61600. private _chromaticAberrationEnabled;
  61601. private _grainEnabled;
  61602. private _buildAllowed;
  61603. /**
  61604. * Gets active scene
  61605. */
  61606. readonly scene: Scene;
  61607. /**
  61608. * Enable or disable the sharpen process from the pipeline
  61609. */
  61610. sharpenEnabled: boolean;
  61611. private _resizeObserver;
  61612. private _hardwareScaleLevel;
  61613. private _bloomKernel;
  61614. /**
  61615. * Specifies the size of the bloom blur kernel, relative to the final output size
  61616. */
  61617. bloomKernel: number;
  61618. /**
  61619. * Specifies the weight of the bloom in the final rendering
  61620. */
  61621. private _bloomWeight;
  61622. /**
  61623. * Specifies the luma threshold for the area that will be blurred by the bloom
  61624. */
  61625. private _bloomThreshold;
  61626. private _hdr;
  61627. /**
  61628. * The strength of the bloom.
  61629. */
  61630. bloomWeight: number;
  61631. /**
  61632. * The strength of the bloom.
  61633. */
  61634. bloomThreshold: number;
  61635. /**
  61636. * The scale of the bloom, lower value will provide better performance.
  61637. */
  61638. bloomScale: number;
  61639. /**
  61640. * Enable or disable the bloom from the pipeline
  61641. */
  61642. bloomEnabled: boolean;
  61643. private _rebuildBloom;
  61644. /**
  61645. * If the depth of field is enabled.
  61646. */
  61647. depthOfFieldEnabled: boolean;
  61648. /**
  61649. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61650. */
  61651. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61652. /**
  61653. * If the anti aliasing is enabled.
  61654. */
  61655. fxaaEnabled: boolean;
  61656. private _samples;
  61657. /**
  61658. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61659. */
  61660. samples: number;
  61661. /**
  61662. * If image processing is enabled.
  61663. */
  61664. imageProcessingEnabled: boolean;
  61665. /**
  61666. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61667. */
  61668. glowLayerEnabled: boolean;
  61669. /**
  61670. * Gets the glow layer (or null if not defined)
  61671. */
  61672. readonly glowLayer: Nullable<GlowLayer>;
  61673. /**
  61674. * Enable or disable the chromaticAberration process from the pipeline
  61675. */
  61676. chromaticAberrationEnabled: boolean;
  61677. /**
  61678. * Enable or disable the grain process from the pipeline
  61679. */
  61680. grainEnabled: boolean;
  61681. /**
  61682. * @constructor
  61683. * @param name - The rendering pipeline name (default: "")
  61684. * @param hdr - If high dynamic range textures should be used (default: true)
  61685. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61686. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61687. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61688. */
  61689. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61690. /**
  61691. * Get the class name
  61692. * @returns "DefaultRenderingPipeline"
  61693. */
  61694. getClassName(): string;
  61695. /**
  61696. * Force the compilation of the entire pipeline.
  61697. */
  61698. prepare(): void;
  61699. private _hasCleared;
  61700. private _prevPostProcess;
  61701. private _prevPrevPostProcess;
  61702. private _setAutoClearAndTextureSharing;
  61703. private _depthOfFieldSceneObserver;
  61704. private _buildPipeline;
  61705. private _disposePostProcesses;
  61706. /**
  61707. * Adds a camera to the pipeline
  61708. * @param camera the camera to be added
  61709. */
  61710. addCamera(camera: Camera): void;
  61711. /**
  61712. * Removes a camera from the pipeline
  61713. * @param camera the camera to remove
  61714. */
  61715. removeCamera(camera: Camera): void;
  61716. /**
  61717. * Dispose of the pipeline and stop all post processes
  61718. */
  61719. dispose(): void;
  61720. /**
  61721. * Serialize the rendering pipeline (Used when exporting)
  61722. * @returns the serialized object
  61723. */
  61724. serialize(): any;
  61725. /**
  61726. * Parse the serialized pipeline
  61727. * @param source Source pipeline.
  61728. * @param scene The scene to load the pipeline to.
  61729. * @param rootUrl The URL of the serialized pipeline.
  61730. * @returns An instantiated pipeline from the serialized object.
  61731. */
  61732. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61733. }
  61734. }
  61735. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61736. /** @hidden */
  61737. export var lensHighlightsPixelShader: {
  61738. name: string;
  61739. shader: string;
  61740. };
  61741. }
  61742. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61743. /** @hidden */
  61744. export var depthOfFieldPixelShader: {
  61745. name: string;
  61746. shader: string;
  61747. };
  61748. }
  61749. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61750. import { Camera } from "babylonjs/Cameras/camera";
  61751. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61752. import { Scene } from "babylonjs/scene";
  61753. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61754. import "babylonjs/Shaders/chromaticAberration.fragment";
  61755. import "babylonjs/Shaders/lensHighlights.fragment";
  61756. import "babylonjs/Shaders/depthOfField.fragment";
  61757. /**
  61758. * BABYLON.JS Chromatic Aberration GLSL Shader
  61759. * Author: Olivier Guyot
  61760. * Separates very slightly R, G and B colors on the edges of the screen
  61761. * Inspired by Francois Tarlier & Martins Upitis
  61762. */
  61763. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61764. /**
  61765. * @ignore
  61766. * The chromatic aberration PostProcess id in the pipeline
  61767. */
  61768. LensChromaticAberrationEffect: string;
  61769. /**
  61770. * @ignore
  61771. * The highlights enhancing PostProcess id in the pipeline
  61772. */
  61773. HighlightsEnhancingEffect: string;
  61774. /**
  61775. * @ignore
  61776. * The depth-of-field PostProcess id in the pipeline
  61777. */
  61778. LensDepthOfFieldEffect: string;
  61779. private _scene;
  61780. private _depthTexture;
  61781. private _grainTexture;
  61782. private _chromaticAberrationPostProcess;
  61783. private _highlightsPostProcess;
  61784. private _depthOfFieldPostProcess;
  61785. private _edgeBlur;
  61786. private _grainAmount;
  61787. private _chromaticAberration;
  61788. private _distortion;
  61789. private _highlightsGain;
  61790. private _highlightsThreshold;
  61791. private _dofDistance;
  61792. private _dofAperture;
  61793. private _dofDarken;
  61794. private _dofPentagon;
  61795. private _blurNoise;
  61796. /**
  61797. * @constructor
  61798. *
  61799. * Effect parameters are as follow:
  61800. * {
  61801. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61802. * edge_blur: number; // from 0 to x (1 for realism)
  61803. * distortion: number; // from 0 to x (1 for realism)
  61804. * grain_amount: number; // from 0 to 1
  61805. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61806. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61807. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61808. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61809. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61810. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61811. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61812. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61813. * }
  61814. * Note: if an effect parameter is unset, effect is disabled
  61815. *
  61816. * @param name The rendering pipeline name
  61817. * @param parameters - An object containing all parameters (see above)
  61818. * @param scene The scene linked to this pipeline
  61819. * @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)
  61820. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61821. */
  61822. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61823. /**
  61824. * Get the class name
  61825. * @returns "LensRenderingPipeline"
  61826. */
  61827. getClassName(): string;
  61828. /**
  61829. * Gets associated scene
  61830. */
  61831. readonly scene: Scene;
  61832. /**
  61833. * Gets or sets the edge blur
  61834. */
  61835. edgeBlur: number;
  61836. /**
  61837. * Gets or sets the grain amount
  61838. */
  61839. grainAmount: number;
  61840. /**
  61841. * Gets or sets the chromatic aberration amount
  61842. */
  61843. chromaticAberration: number;
  61844. /**
  61845. * Gets or sets the depth of field aperture
  61846. */
  61847. dofAperture: number;
  61848. /**
  61849. * Gets or sets the edge distortion
  61850. */
  61851. edgeDistortion: number;
  61852. /**
  61853. * Gets or sets the depth of field distortion
  61854. */
  61855. dofDistortion: number;
  61856. /**
  61857. * Gets or sets the darken out of focus amount
  61858. */
  61859. darkenOutOfFocus: number;
  61860. /**
  61861. * Gets or sets a boolean indicating if blur noise is enabled
  61862. */
  61863. blurNoise: boolean;
  61864. /**
  61865. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61866. */
  61867. pentagonBokeh: boolean;
  61868. /**
  61869. * Gets or sets the highlight grain amount
  61870. */
  61871. highlightsGain: number;
  61872. /**
  61873. * Gets or sets the highlight threshold
  61874. */
  61875. highlightsThreshold: number;
  61876. /**
  61877. * Sets the amount of blur at the edges
  61878. * @param amount blur amount
  61879. */
  61880. setEdgeBlur(amount: number): void;
  61881. /**
  61882. * Sets edge blur to 0
  61883. */
  61884. disableEdgeBlur(): void;
  61885. /**
  61886. * Sets the amout of grain
  61887. * @param amount Amount of grain
  61888. */
  61889. setGrainAmount(amount: number): void;
  61890. /**
  61891. * Set grain amount to 0
  61892. */
  61893. disableGrain(): void;
  61894. /**
  61895. * Sets the chromatic aberration amount
  61896. * @param amount amount of chromatic aberration
  61897. */
  61898. setChromaticAberration(amount: number): void;
  61899. /**
  61900. * Sets chromatic aberration amount to 0
  61901. */
  61902. disableChromaticAberration(): void;
  61903. /**
  61904. * Sets the EdgeDistortion amount
  61905. * @param amount amount of EdgeDistortion
  61906. */
  61907. setEdgeDistortion(amount: number): void;
  61908. /**
  61909. * Sets edge distortion to 0
  61910. */
  61911. disableEdgeDistortion(): void;
  61912. /**
  61913. * Sets the FocusDistance amount
  61914. * @param amount amount of FocusDistance
  61915. */
  61916. setFocusDistance(amount: number): void;
  61917. /**
  61918. * Disables depth of field
  61919. */
  61920. disableDepthOfField(): void;
  61921. /**
  61922. * Sets the Aperture amount
  61923. * @param amount amount of Aperture
  61924. */
  61925. setAperture(amount: number): void;
  61926. /**
  61927. * Sets the DarkenOutOfFocus amount
  61928. * @param amount amount of DarkenOutOfFocus
  61929. */
  61930. setDarkenOutOfFocus(amount: number): void;
  61931. private _pentagonBokehIsEnabled;
  61932. /**
  61933. * Creates a pentagon bokeh effect
  61934. */
  61935. enablePentagonBokeh(): void;
  61936. /**
  61937. * Disables the pentagon bokeh effect
  61938. */
  61939. disablePentagonBokeh(): void;
  61940. /**
  61941. * Enables noise blur
  61942. */
  61943. enableNoiseBlur(): void;
  61944. /**
  61945. * Disables noise blur
  61946. */
  61947. disableNoiseBlur(): void;
  61948. /**
  61949. * Sets the HighlightsGain amount
  61950. * @param amount amount of HighlightsGain
  61951. */
  61952. setHighlightsGain(amount: number): void;
  61953. /**
  61954. * Sets the HighlightsThreshold amount
  61955. * @param amount amount of HighlightsThreshold
  61956. */
  61957. setHighlightsThreshold(amount: number): void;
  61958. /**
  61959. * Disables highlights
  61960. */
  61961. disableHighlights(): void;
  61962. /**
  61963. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61964. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61965. */
  61966. dispose(disableDepthRender?: boolean): void;
  61967. private _createChromaticAberrationPostProcess;
  61968. private _createHighlightsPostProcess;
  61969. private _createDepthOfFieldPostProcess;
  61970. private _createGrainTexture;
  61971. }
  61972. }
  61973. declare module "babylonjs/Shaders/ssao2.fragment" {
  61974. /** @hidden */
  61975. export var ssao2PixelShader: {
  61976. name: string;
  61977. shader: string;
  61978. };
  61979. }
  61980. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61981. /** @hidden */
  61982. export var ssaoCombinePixelShader: {
  61983. name: string;
  61984. shader: string;
  61985. };
  61986. }
  61987. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61988. import { Camera } from "babylonjs/Cameras/camera";
  61989. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61990. import { Scene } from "babylonjs/scene";
  61991. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61992. import "babylonjs/Shaders/ssao2.fragment";
  61993. import "babylonjs/Shaders/ssaoCombine.fragment";
  61994. /**
  61995. * Render pipeline to produce ssao effect
  61996. */
  61997. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61998. /**
  61999. * @ignore
  62000. * The PassPostProcess id in the pipeline that contains the original scene color
  62001. */
  62002. SSAOOriginalSceneColorEffect: string;
  62003. /**
  62004. * @ignore
  62005. * The SSAO PostProcess id in the pipeline
  62006. */
  62007. SSAORenderEffect: string;
  62008. /**
  62009. * @ignore
  62010. * The horizontal blur PostProcess id in the pipeline
  62011. */
  62012. SSAOBlurHRenderEffect: string;
  62013. /**
  62014. * @ignore
  62015. * The vertical blur PostProcess id in the pipeline
  62016. */
  62017. SSAOBlurVRenderEffect: string;
  62018. /**
  62019. * @ignore
  62020. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62021. */
  62022. SSAOCombineRenderEffect: string;
  62023. /**
  62024. * The output strength of the SSAO post-process. Default value is 1.0.
  62025. */
  62026. totalStrength: number;
  62027. /**
  62028. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62029. */
  62030. maxZ: number;
  62031. /**
  62032. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62033. */
  62034. minZAspect: number;
  62035. private _samples;
  62036. /**
  62037. * Number of samples used for the SSAO calculations. Default value is 8
  62038. */
  62039. samples: number;
  62040. private _textureSamples;
  62041. /**
  62042. * Number of samples to use for antialiasing
  62043. */
  62044. textureSamples: number;
  62045. /**
  62046. * Ratio object used for SSAO ratio and blur ratio
  62047. */
  62048. private _ratio;
  62049. /**
  62050. * Dynamically generated sphere sampler.
  62051. */
  62052. private _sampleSphere;
  62053. /**
  62054. * Blur filter offsets
  62055. */
  62056. private _samplerOffsets;
  62057. private _expensiveBlur;
  62058. /**
  62059. * If bilateral blur should be used
  62060. */
  62061. expensiveBlur: boolean;
  62062. /**
  62063. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62064. */
  62065. radius: number;
  62066. /**
  62067. * The base color of the SSAO post-process
  62068. * The final result is "base + ssao" between [0, 1]
  62069. */
  62070. base: number;
  62071. /**
  62072. * Support test.
  62073. */
  62074. static readonly IsSupported: boolean;
  62075. private _scene;
  62076. private _depthTexture;
  62077. private _normalTexture;
  62078. private _randomTexture;
  62079. private _originalColorPostProcess;
  62080. private _ssaoPostProcess;
  62081. private _blurHPostProcess;
  62082. private _blurVPostProcess;
  62083. private _ssaoCombinePostProcess;
  62084. private _firstUpdate;
  62085. /**
  62086. * Gets active scene
  62087. */
  62088. readonly scene: Scene;
  62089. /**
  62090. * @constructor
  62091. * @param name The rendering pipeline name
  62092. * @param scene The scene linked to this pipeline
  62093. * @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 }
  62094. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62095. */
  62096. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62097. /**
  62098. * Get the class name
  62099. * @returns "SSAO2RenderingPipeline"
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62104. */
  62105. dispose(disableGeometryBufferRenderer?: boolean): void;
  62106. private _createBlurPostProcess;
  62107. /** @hidden */
  62108. _rebuild(): void;
  62109. private _bits;
  62110. private _radicalInverse_VdC;
  62111. private _hammersley;
  62112. private _hemisphereSample_uniform;
  62113. private _generateHemisphere;
  62114. private _createSSAOPostProcess;
  62115. private _createSSAOCombinePostProcess;
  62116. private _createRandomTexture;
  62117. /**
  62118. * Serialize the rendering pipeline (Used when exporting)
  62119. * @returns the serialized object
  62120. */
  62121. serialize(): any;
  62122. /**
  62123. * Parse the serialized pipeline
  62124. * @param source Source pipeline.
  62125. * @param scene The scene to load the pipeline to.
  62126. * @param rootUrl The URL of the serialized pipeline.
  62127. * @returns An instantiated pipeline from the serialized object.
  62128. */
  62129. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62130. }
  62131. }
  62132. declare module "babylonjs/Shaders/ssao.fragment" {
  62133. /** @hidden */
  62134. export var ssaoPixelShader: {
  62135. name: string;
  62136. shader: string;
  62137. };
  62138. }
  62139. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62140. import { Camera } from "babylonjs/Cameras/camera";
  62141. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62142. import { Scene } from "babylonjs/scene";
  62143. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62144. import "babylonjs/Shaders/ssao.fragment";
  62145. import "babylonjs/Shaders/ssaoCombine.fragment";
  62146. /**
  62147. * Render pipeline to produce ssao effect
  62148. */
  62149. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62150. /**
  62151. * @ignore
  62152. * The PassPostProcess id in the pipeline that contains the original scene color
  62153. */
  62154. SSAOOriginalSceneColorEffect: string;
  62155. /**
  62156. * @ignore
  62157. * The SSAO PostProcess id in the pipeline
  62158. */
  62159. SSAORenderEffect: string;
  62160. /**
  62161. * @ignore
  62162. * The horizontal blur PostProcess id in the pipeline
  62163. */
  62164. SSAOBlurHRenderEffect: string;
  62165. /**
  62166. * @ignore
  62167. * The vertical blur PostProcess id in the pipeline
  62168. */
  62169. SSAOBlurVRenderEffect: string;
  62170. /**
  62171. * @ignore
  62172. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62173. */
  62174. SSAOCombineRenderEffect: string;
  62175. /**
  62176. * The output strength of the SSAO post-process. Default value is 1.0.
  62177. */
  62178. totalStrength: number;
  62179. /**
  62180. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62181. */
  62182. radius: number;
  62183. /**
  62184. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62185. * Must not be equal to fallOff and superior to fallOff.
  62186. * Default value is 0.0075
  62187. */
  62188. area: number;
  62189. /**
  62190. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62191. * Must not be equal to area and inferior to area.
  62192. * Default value is 0.000001
  62193. */
  62194. fallOff: number;
  62195. /**
  62196. * The base color of the SSAO post-process
  62197. * The final result is "base + ssao" between [0, 1]
  62198. */
  62199. base: number;
  62200. private _scene;
  62201. private _depthTexture;
  62202. private _randomTexture;
  62203. private _originalColorPostProcess;
  62204. private _ssaoPostProcess;
  62205. private _blurHPostProcess;
  62206. private _blurVPostProcess;
  62207. private _ssaoCombinePostProcess;
  62208. private _firstUpdate;
  62209. /**
  62210. * Gets active scene
  62211. */
  62212. readonly scene: Scene;
  62213. /**
  62214. * @constructor
  62215. * @param name - The rendering pipeline name
  62216. * @param scene - The scene linked to this pipeline
  62217. * @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 }
  62218. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62219. */
  62220. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62221. /**
  62222. * Get the class name
  62223. * @returns "SSAORenderingPipeline"
  62224. */
  62225. getClassName(): string;
  62226. /**
  62227. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62228. */
  62229. dispose(disableDepthRender?: boolean): void;
  62230. private _createBlurPostProcess;
  62231. /** @hidden */
  62232. _rebuild(): void;
  62233. private _createSSAOPostProcess;
  62234. private _createSSAOCombinePostProcess;
  62235. private _createRandomTexture;
  62236. }
  62237. }
  62238. declare module "babylonjs/Shaders/standard.fragment" {
  62239. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62240. /** @hidden */
  62241. export var standardPixelShader: {
  62242. name: string;
  62243. shader: string;
  62244. };
  62245. }
  62246. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62247. import { Nullable } from "babylonjs/types";
  62248. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62249. import { Camera } from "babylonjs/Cameras/camera";
  62250. import { Texture } from "babylonjs/Materials/Textures/texture";
  62251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62252. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62253. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62254. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62255. import { IDisposable } from "babylonjs/scene";
  62256. import { SpotLight } from "babylonjs/Lights/spotLight";
  62257. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62258. import { Scene } from "babylonjs/scene";
  62259. import { Animation } from "babylonjs/Animations/animation";
  62260. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62261. import "babylonjs/Shaders/standard.fragment";
  62262. /**
  62263. * Standard rendering pipeline
  62264. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62265. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62266. */
  62267. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62268. /**
  62269. * Public members
  62270. */
  62271. /**
  62272. * Post-process which contains the original scene color before the pipeline applies all the effects
  62273. */
  62274. originalPostProcess: Nullable<PostProcess>;
  62275. /**
  62276. * Post-process used to down scale an image x4
  62277. */
  62278. downSampleX4PostProcess: Nullable<PostProcess>;
  62279. /**
  62280. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62281. */
  62282. brightPassPostProcess: Nullable<PostProcess>;
  62283. /**
  62284. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62285. */
  62286. blurHPostProcesses: PostProcess[];
  62287. /**
  62288. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62289. */
  62290. blurVPostProcesses: PostProcess[];
  62291. /**
  62292. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62293. */
  62294. textureAdderPostProcess: Nullable<PostProcess>;
  62295. /**
  62296. * Post-process used to create volumetric lighting effect
  62297. */
  62298. volumetricLightPostProcess: Nullable<PostProcess>;
  62299. /**
  62300. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62301. */
  62302. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62303. /**
  62304. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62305. */
  62306. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62307. /**
  62308. * Post-process used to merge the volumetric light effect and the real scene color
  62309. */
  62310. volumetricLightMergePostProces: Nullable<PostProcess>;
  62311. /**
  62312. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62313. */
  62314. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62315. /**
  62316. * Base post-process used to calculate the average luminance of the final image for HDR
  62317. */
  62318. luminancePostProcess: Nullable<PostProcess>;
  62319. /**
  62320. * Post-processes used to create down sample post-processes in order to get
  62321. * the average luminance of the final image for HDR
  62322. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62323. */
  62324. luminanceDownSamplePostProcesses: PostProcess[];
  62325. /**
  62326. * Post-process used to create a HDR effect (light adaptation)
  62327. */
  62328. hdrPostProcess: Nullable<PostProcess>;
  62329. /**
  62330. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62331. */
  62332. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62333. /**
  62334. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62335. */
  62336. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62337. /**
  62338. * Post-process used to merge the final HDR post-process and the real scene color
  62339. */
  62340. hdrFinalPostProcess: Nullable<PostProcess>;
  62341. /**
  62342. * Post-process used to create a lens flare effect
  62343. */
  62344. lensFlarePostProcess: Nullable<PostProcess>;
  62345. /**
  62346. * Post-process that merges the result of the lens flare post-process and the real scene color
  62347. */
  62348. lensFlareComposePostProcess: Nullable<PostProcess>;
  62349. /**
  62350. * Post-process used to create a motion blur effect
  62351. */
  62352. motionBlurPostProcess: Nullable<PostProcess>;
  62353. /**
  62354. * Post-process used to create a depth of field effect
  62355. */
  62356. depthOfFieldPostProcess: Nullable<PostProcess>;
  62357. /**
  62358. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62359. */
  62360. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62361. /**
  62362. * Represents the brightness threshold in order to configure the illuminated surfaces
  62363. */
  62364. brightThreshold: number;
  62365. /**
  62366. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62367. */
  62368. blurWidth: number;
  62369. /**
  62370. * Sets if the blur for highlighted surfaces must be only horizontal
  62371. */
  62372. horizontalBlur: boolean;
  62373. /**
  62374. * Gets the overall exposure used by the pipeline
  62375. */
  62376. /**
  62377. * Sets the overall exposure used by the pipeline
  62378. */
  62379. exposure: number;
  62380. /**
  62381. * Texture used typically to simulate "dirty" on camera lens
  62382. */
  62383. lensTexture: Nullable<Texture>;
  62384. /**
  62385. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62386. */
  62387. volumetricLightCoefficient: number;
  62388. /**
  62389. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62390. */
  62391. volumetricLightPower: number;
  62392. /**
  62393. * Used the set the blur intensity to smooth the volumetric lights
  62394. */
  62395. volumetricLightBlurScale: number;
  62396. /**
  62397. * Light (spot or directional) used to generate the volumetric lights rays
  62398. * The source light must have a shadow generate so the pipeline can get its
  62399. * depth map
  62400. */
  62401. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62402. /**
  62403. * For eye adaptation, represents the minimum luminance the eye can see
  62404. */
  62405. hdrMinimumLuminance: number;
  62406. /**
  62407. * For eye adaptation, represents the decrease luminance speed
  62408. */
  62409. hdrDecreaseRate: number;
  62410. /**
  62411. * For eye adaptation, represents the increase luminance speed
  62412. */
  62413. hdrIncreaseRate: number;
  62414. /**
  62415. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62416. */
  62417. /**
  62418. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62419. */
  62420. hdrAutoExposure: boolean;
  62421. /**
  62422. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62423. */
  62424. lensColorTexture: Nullable<Texture>;
  62425. /**
  62426. * The overall strengh for the lens flare effect
  62427. */
  62428. lensFlareStrength: number;
  62429. /**
  62430. * Dispersion coefficient for lens flare ghosts
  62431. */
  62432. lensFlareGhostDispersal: number;
  62433. /**
  62434. * Main lens flare halo width
  62435. */
  62436. lensFlareHaloWidth: number;
  62437. /**
  62438. * Based on the lens distortion effect, defines how much the lens flare result
  62439. * is distorted
  62440. */
  62441. lensFlareDistortionStrength: number;
  62442. /**
  62443. * Configures the blur intensity used for for lens flare (halo)
  62444. */
  62445. lensFlareBlurWidth: number;
  62446. /**
  62447. * Lens star texture must be used to simulate rays on the flares and is available
  62448. * in the documentation
  62449. */
  62450. lensStarTexture: Nullable<Texture>;
  62451. /**
  62452. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62453. * flare effect by taking account of the dirt texture
  62454. */
  62455. lensFlareDirtTexture: Nullable<Texture>;
  62456. /**
  62457. * Represents the focal length for the depth of field effect
  62458. */
  62459. depthOfFieldDistance: number;
  62460. /**
  62461. * Represents the blur intensity for the blurred part of the depth of field effect
  62462. */
  62463. depthOfFieldBlurWidth: number;
  62464. /**
  62465. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62466. */
  62467. /**
  62468. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62469. */
  62470. motionStrength: number;
  62471. /**
  62472. * Gets wether or not the motion blur post-process is object based or screen based.
  62473. */
  62474. /**
  62475. * Sets wether or not the motion blur post-process should be object based or screen based
  62476. */
  62477. objectBasedMotionBlur: boolean;
  62478. /**
  62479. * List of animations for the pipeline (IAnimatable implementation)
  62480. */
  62481. animations: Animation[];
  62482. /**
  62483. * Private members
  62484. */
  62485. private _scene;
  62486. private _currentDepthOfFieldSource;
  62487. private _basePostProcess;
  62488. private _fixedExposure;
  62489. private _currentExposure;
  62490. private _hdrAutoExposure;
  62491. private _hdrCurrentLuminance;
  62492. private _motionStrength;
  62493. private _isObjectBasedMotionBlur;
  62494. private _floatTextureType;
  62495. private _camerasToBeAttached;
  62496. private _ratio;
  62497. private _bloomEnabled;
  62498. private _depthOfFieldEnabled;
  62499. private _vlsEnabled;
  62500. private _lensFlareEnabled;
  62501. private _hdrEnabled;
  62502. private _motionBlurEnabled;
  62503. private _fxaaEnabled;
  62504. private _motionBlurSamples;
  62505. private _volumetricLightStepsCount;
  62506. private _samples;
  62507. /**
  62508. * @ignore
  62509. * Specifies if the bloom pipeline is enabled
  62510. */
  62511. BloomEnabled: boolean;
  62512. /**
  62513. * @ignore
  62514. * Specifies if the depth of field pipeline is enabed
  62515. */
  62516. DepthOfFieldEnabled: boolean;
  62517. /**
  62518. * @ignore
  62519. * Specifies if the lens flare pipeline is enabed
  62520. */
  62521. LensFlareEnabled: boolean;
  62522. /**
  62523. * @ignore
  62524. * Specifies if the HDR pipeline is enabled
  62525. */
  62526. HDREnabled: boolean;
  62527. /**
  62528. * @ignore
  62529. * Specifies if the volumetric lights scattering effect is enabled
  62530. */
  62531. VLSEnabled: boolean;
  62532. /**
  62533. * @ignore
  62534. * Specifies if the motion blur effect is enabled
  62535. */
  62536. MotionBlurEnabled: boolean;
  62537. /**
  62538. * Specifies if anti-aliasing is enabled
  62539. */
  62540. fxaaEnabled: boolean;
  62541. /**
  62542. * Specifies the number of steps used to calculate the volumetric lights
  62543. * Typically in interval [50, 200]
  62544. */
  62545. volumetricLightStepsCount: number;
  62546. /**
  62547. * Specifies the number of samples used for the motion blur effect
  62548. * Typically in interval [16, 64]
  62549. */
  62550. motionBlurSamples: number;
  62551. /**
  62552. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62553. */
  62554. samples: number;
  62555. /**
  62556. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62557. * @constructor
  62558. * @param name The rendering pipeline name
  62559. * @param scene The scene linked to this pipeline
  62560. * @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)
  62561. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62562. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62563. */
  62564. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62565. private _buildPipeline;
  62566. private _createDownSampleX4PostProcess;
  62567. private _createBrightPassPostProcess;
  62568. private _createBlurPostProcesses;
  62569. private _createTextureAdderPostProcess;
  62570. private _createVolumetricLightPostProcess;
  62571. private _createLuminancePostProcesses;
  62572. private _createHdrPostProcess;
  62573. private _createLensFlarePostProcess;
  62574. private _createDepthOfFieldPostProcess;
  62575. private _createMotionBlurPostProcess;
  62576. private _getDepthTexture;
  62577. private _disposePostProcesses;
  62578. /**
  62579. * Dispose of the pipeline and stop all post processes
  62580. */
  62581. dispose(): void;
  62582. /**
  62583. * Serialize the rendering pipeline (Used when exporting)
  62584. * @returns the serialized object
  62585. */
  62586. serialize(): any;
  62587. /**
  62588. * Parse the serialized pipeline
  62589. * @param source Source pipeline.
  62590. * @param scene The scene to load the pipeline to.
  62591. * @param rootUrl The URL of the serialized pipeline.
  62592. * @returns An instantiated pipeline from the serialized object.
  62593. */
  62594. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62595. /**
  62596. * Luminance steps
  62597. */
  62598. static LuminanceSteps: number;
  62599. }
  62600. }
  62601. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62602. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62603. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62604. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62605. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62606. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62607. }
  62608. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62609. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62610. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62611. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62612. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62613. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62614. }
  62615. declare module "babylonjs/Shaders/tonemap.fragment" {
  62616. /** @hidden */
  62617. export var tonemapPixelShader: {
  62618. name: string;
  62619. shader: string;
  62620. };
  62621. }
  62622. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62623. import { Camera } from "babylonjs/Cameras/camera";
  62624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62625. import "babylonjs/Shaders/tonemap.fragment";
  62626. import { Engine } from "babylonjs/Engines/engine";
  62627. /** Defines operator used for tonemapping */
  62628. export enum TonemappingOperator {
  62629. /** Hable */
  62630. Hable = 0,
  62631. /** Reinhard */
  62632. Reinhard = 1,
  62633. /** HejiDawson */
  62634. HejiDawson = 2,
  62635. /** Photographic */
  62636. Photographic = 3
  62637. }
  62638. /**
  62639. * Defines a post process to apply tone mapping
  62640. */
  62641. export class TonemapPostProcess extends PostProcess {
  62642. private _operator;
  62643. /** Defines the required exposure adjustement */
  62644. exposureAdjustment: number;
  62645. /**
  62646. * Creates a new TonemapPostProcess
  62647. * @param name defines the name of the postprocess
  62648. * @param _operator defines the operator to use
  62649. * @param exposureAdjustment defines the required exposure adjustement
  62650. * @param camera defines the camera to use (can be null)
  62651. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62652. * @param engine defines the hosting engine (can be ignore if camera is set)
  62653. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62654. */
  62655. constructor(name: string, _operator: TonemappingOperator,
  62656. /** Defines the required exposure adjustement */
  62657. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62658. }
  62659. }
  62660. declare module "babylonjs/Shaders/depth.vertex" {
  62661. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62662. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62663. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62664. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62665. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62666. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62667. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62668. /** @hidden */
  62669. export var depthVertexShader: {
  62670. name: string;
  62671. shader: string;
  62672. };
  62673. }
  62674. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62675. /** @hidden */
  62676. export var volumetricLightScatteringPixelShader: {
  62677. name: string;
  62678. shader: string;
  62679. };
  62680. }
  62681. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62682. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62683. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62684. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62685. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62686. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62687. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62688. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62689. /** @hidden */
  62690. export var volumetricLightScatteringPassVertexShader: {
  62691. name: string;
  62692. shader: string;
  62693. };
  62694. }
  62695. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62696. /** @hidden */
  62697. export var volumetricLightScatteringPassPixelShader: {
  62698. name: string;
  62699. shader: string;
  62700. };
  62701. }
  62702. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62703. import { Vector3 } from "babylonjs/Maths/math.vector";
  62704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62705. import { Mesh } from "babylonjs/Meshes/mesh";
  62706. import { Camera } from "babylonjs/Cameras/camera";
  62707. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62708. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62709. import { Scene } from "babylonjs/scene";
  62710. import "babylonjs/Meshes/Builders/planeBuilder";
  62711. import "babylonjs/Shaders/depth.vertex";
  62712. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62713. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62714. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62715. import { Engine } from "babylonjs/Engines/engine";
  62716. /**
  62717. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62718. */
  62719. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62720. private _volumetricLightScatteringPass;
  62721. private _volumetricLightScatteringRTT;
  62722. private _viewPort;
  62723. private _screenCoordinates;
  62724. private _cachedDefines;
  62725. /**
  62726. * If not undefined, the mesh position is computed from the attached node position
  62727. */
  62728. attachedNode: {
  62729. position: Vector3;
  62730. };
  62731. /**
  62732. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62733. */
  62734. customMeshPosition: Vector3;
  62735. /**
  62736. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62737. */
  62738. useCustomMeshPosition: boolean;
  62739. /**
  62740. * If the post-process should inverse the light scattering direction
  62741. */
  62742. invert: boolean;
  62743. /**
  62744. * The internal mesh used by the post-process
  62745. */
  62746. mesh: Mesh;
  62747. /**
  62748. * @hidden
  62749. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62750. */
  62751. useDiffuseColor: boolean;
  62752. /**
  62753. * Array containing the excluded meshes not rendered in the internal pass
  62754. */
  62755. excludedMeshes: AbstractMesh[];
  62756. /**
  62757. * Controls the overall intensity of the post-process
  62758. */
  62759. exposure: number;
  62760. /**
  62761. * Dissipates each sample's contribution in range [0, 1]
  62762. */
  62763. decay: number;
  62764. /**
  62765. * Controls the overall intensity of each sample
  62766. */
  62767. weight: number;
  62768. /**
  62769. * Controls the density of each sample
  62770. */
  62771. density: number;
  62772. /**
  62773. * @constructor
  62774. * @param name The post-process name
  62775. * @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)
  62776. * @param camera The camera that the post-process will be attached to
  62777. * @param mesh The mesh used to create the light scattering
  62778. * @param samples The post-process quality, default 100
  62779. * @param samplingModeThe post-process filtering mode
  62780. * @param engine The babylon engine
  62781. * @param reusable If the post-process is reusable
  62782. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62783. */
  62784. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62785. /**
  62786. * Returns the string "VolumetricLightScatteringPostProcess"
  62787. * @returns "VolumetricLightScatteringPostProcess"
  62788. */
  62789. getClassName(): string;
  62790. private _isReady;
  62791. /**
  62792. * Sets the new light position for light scattering effect
  62793. * @param position The new custom light position
  62794. */
  62795. setCustomMeshPosition(position: Vector3): void;
  62796. /**
  62797. * Returns the light position for light scattering effect
  62798. * @return Vector3 The custom light position
  62799. */
  62800. getCustomMeshPosition(): Vector3;
  62801. /**
  62802. * Disposes the internal assets and detaches the post-process from the camera
  62803. */
  62804. dispose(camera: Camera): void;
  62805. /**
  62806. * Returns the render target texture used by the post-process
  62807. * @return the render target texture used by the post-process
  62808. */
  62809. getPass(): RenderTargetTexture;
  62810. private _meshExcluded;
  62811. private _createPass;
  62812. private _updateMeshScreenCoordinates;
  62813. /**
  62814. * Creates a default mesh for the Volumeric Light Scattering post-process
  62815. * @param name The mesh name
  62816. * @param scene The scene where to create the mesh
  62817. * @return the default mesh
  62818. */
  62819. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62820. }
  62821. }
  62822. declare module "babylonjs/PostProcesses/index" {
  62823. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62824. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62825. export * from "babylonjs/PostProcesses/bloomEffect";
  62826. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62827. export * from "babylonjs/PostProcesses/blurPostProcess";
  62828. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62829. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62830. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62831. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62832. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62833. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62834. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62835. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62836. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62837. export * from "babylonjs/PostProcesses/filterPostProcess";
  62838. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62839. export * from "babylonjs/PostProcesses/grainPostProcess";
  62840. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62841. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62842. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62843. export * from "babylonjs/PostProcesses/passPostProcess";
  62844. export * from "babylonjs/PostProcesses/postProcess";
  62845. export * from "babylonjs/PostProcesses/postProcessManager";
  62846. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62847. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62848. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62849. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62850. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62851. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62852. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62853. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62854. }
  62855. declare module "babylonjs/Probes/index" {
  62856. export * from "babylonjs/Probes/reflectionProbe";
  62857. }
  62858. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62859. import { Scene } from "babylonjs/scene";
  62860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62861. import { SmartArray } from "babylonjs/Misc/smartArray";
  62862. import { ISceneComponent } from "babylonjs/sceneComponent";
  62863. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62864. import "babylonjs/Meshes/Builders/boxBuilder";
  62865. import "babylonjs/Shaders/color.fragment";
  62866. import "babylonjs/Shaders/color.vertex";
  62867. import { Color3 } from "babylonjs/Maths/math.color";
  62868. module "babylonjs/scene" {
  62869. interface Scene {
  62870. /** @hidden (Backing field) */
  62871. _boundingBoxRenderer: BoundingBoxRenderer;
  62872. /** @hidden (Backing field) */
  62873. _forceShowBoundingBoxes: boolean;
  62874. /**
  62875. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62876. */
  62877. forceShowBoundingBoxes: boolean;
  62878. /**
  62879. * Gets the bounding box renderer associated with the scene
  62880. * @returns a BoundingBoxRenderer
  62881. */
  62882. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62883. }
  62884. }
  62885. module "babylonjs/Meshes/abstractMesh" {
  62886. interface AbstractMesh {
  62887. /** @hidden (Backing field) */
  62888. _showBoundingBox: boolean;
  62889. /**
  62890. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62891. */
  62892. showBoundingBox: boolean;
  62893. }
  62894. }
  62895. /**
  62896. * Component responsible of rendering the bounding box of the meshes in a scene.
  62897. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62898. */
  62899. export class BoundingBoxRenderer implements ISceneComponent {
  62900. /**
  62901. * The component name helpfull to identify the component in the list of scene components.
  62902. */
  62903. readonly name: string;
  62904. /**
  62905. * The scene the component belongs to.
  62906. */
  62907. scene: Scene;
  62908. /**
  62909. * Color of the bounding box lines placed in front of an object
  62910. */
  62911. frontColor: Color3;
  62912. /**
  62913. * Color of the bounding box lines placed behind an object
  62914. */
  62915. backColor: Color3;
  62916. /**
  62917. * Defines if the renderer should show the back lines or not
  62918. */
  62919. showBackLines: boolean;
  62920. /**
  62921. * @hidden
  62922. */
  62923. renderList: SmartArray<BoundingBox>;
  62924. private _colorShader;
  62925. private _vertexBuffers;
  62926. private _indexBuffer;
  62927. private _fillIndexBuffer;
  62928. private _fillIndexData;
  62929. /**
  62930. * Instantiates a new bounding box renderer in a scene.
  62931. * @param scene the scene the renderer renders in
  62932. */
  62933. constructor(scene: Scene);
  62934. /**
  62935. * Registers the component in a given scene
  62936. */
  62937. register(): void;
  62938. private _evaluateSubMesh;
  62939. private _activeMesh;
  62940. private _prepareRessources;
  62941. private _createIndexBuffer;
  62942. /**
  62943. * Rebuilds the elements related to this component in case of
  62944. * context lost for instance.
  62945. */
  62946. rebuild(): void;
  62947. /**
  62948. * @hidden
  62949. */
  62950. reset(): void;
  62951. /**
  62952. * Render the bounding boxes of a specific rendering group
  62953. * @param renderingGroupId defines the rendering group to render
  62954. */
  62955. render(renderingGroupId: number): void;
  62956. /**
  62957. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62958. * @param mesh Define the mesh to render the occlusion bounding box for
  62959. */
  62960. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62961. /**
  62962. * Dispose and release the resources attached to this renderer.
  62963. */
  62964. dispose(): void;
  62965. }
  62966. }
  62967. declare module "babylonjs/Shaders/depth.fragment" {
  62968. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62969. /** @hidden */
  62970. export var depthPixelShader: {
  62971. name: string;
  62972. shader: string;
  62973. };
  62974. }
  62975. declare module "babylonjs/Rendering/depthRenderer" {
  62976. import { Nullable } from "babylonjs/types";
  62977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62978. import { Scene } from "babylonjs/scene";
  62979. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62980. import { Camera } from "babylonjs/Cameras/camera";
  62981. import "babylonjs/Shaders/depth.fragment";
  62982. import "babylonjs/Shaders/depth.vertex";
  62983. /**
  62984. * This represents a depth renderer in Babylon.
  62985. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62986. */
  62987. export class DepthRenderer {
  62988. private _scene;
  62989. private _depthMap;
  62990. private _effect;
  62991. private readonly _storeNonLinearDepth;
  62992. private readonly _clearColor;
  62993. /** Get if the depth renderer is using packed depth or not */
  62994. readonly isPacked: boolean;
  62995. private _cachedDefines;
  62996. private _camera;
  62997. /**
  62998. * Specifiess that the depth renderer will only be used within
  62999. * the camera it is created for.
  63000. * This can help forcing its rendering during the camera processing.
  63001. */
  63002. useOnlyInActiveCamera: boolean;
  63003. /** @hidden */
  63004. static _SceneComponentInitialization: (scene: Scene) => void;
  63005. /**
  63006. * Instantiates a depth renderer
  63007. * @param scene The scene the renderer belongs to
  63008. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63009. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63010. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63011. */
  63012. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63013. /**
  63014. * Creates the depth rendering effect and checks if the effect is ready.
  63015. * @param subMesh The submesh to be used to render the depth map of
  63016. * @param useInstances If multiple world instances should be used
  63017. * @returns if the depth renderer is ready to render the depth map
  63018. */
  63019. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63020. /**
  63021. * Gets the texture which the depth map will be written to.
  63022. * @returns The depth map texture
  63023. */
  63024. getDepthMap(): RenderTargetTexture;
  63025. /**
  63026. * Disposes of the depth renderer.
  63027. */
  63028. dispose(): void;
  63029. }
  63030. }
  63031. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63032. import { Nullable } from "babylonjs/types";
  63033. import { Scene } from "babylonjs/scene";
  63034. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63035. import { Camera } from "babylonjs/Cameras/camera";
  63036. import { ISceneComponent } from "babylonjs/sceneComponent";
  63037. module "babylonjs/scene" {
  63038. interface Scene {
  63039. /** @hidden (Backing field) */
  63040. _depthRenderer: {
  63041. [id: string]: DepthRenderer;
  63042. };
  63043. /**
  63044. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63045. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63046. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63047. * @returns the created depth renderer
  63048. */
  63049. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63050. /**
  63051. * Disables a depth renderer for a given camera
  63052. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63053. */
  63054. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63055. }
  63056. }
  63057. /**
  63058. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63059. * in several rendering techniques.
  63060. */
  63061. export class DepthRendererSceneComponent implements ISceneComponent {
  63062. /**
  63063. * The component name helpfull to identify the component in the list of scene components.
  63064. */
  63065. readonly name: string;
  63066. /**
  63067. * The scene the component belongs to.
  63068. */
  63069. scene: Scene;
  63070. /**
  63071. * Creates a new instance of the component for the given scene
  63072. * @param scene Defines the scene to register the component in
  63073. */
  63074. constructor(scene: Scene);
  63075. /**
  63076. * Registers the component in a given scene
  63077. */
  63078. register(): void;
  63079. /**
  63080. * Rebuilds the elements related to this component in case of
  63081. * context lost for instance.
  63082. */
  63083. rebuild(): void;
  63084. /**
  63085. * Disposes the component and the associated ressources
  63086. */
  63087. dispose(): void;
  63088. private _gatherRenderTargets;
  63089. private _gatherActiveCameraRenderTargets;
  63090. }
  63091. }
  63092. declare module "babylonjs/Shaders/outline.fragment" {
  63093. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63094. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63095. /** @hidden */
  63096. export var outlinePixelShader: {
  63097. name: string;
  63098. shader: string;
  63099. };
  63100. }
  63101. declare module "babylonjs/Shaders/outline.vertex" {
  63102. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63103. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63104. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63105. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63106. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63107. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63108. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63109. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63110. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63111. /** @hidden */
  63112. export var outlineVertexShader: {
  63113. name: string;
  63114. shader: string;
  63115. };
  63116. }
  63117. declare module "babylonjs/Rendering/outlineRenderer" {
  63118. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63119. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63120. import { Scene } from "babylonjs/scene";
  63121. import { ISceneComponent } from "babylonjs/sceneComponent";
  63122. import "babylonjs/Shaders/outline.fragment";
  63123. import "babylonjs/Shaders/outline.vertex";
  63124. module "babylonjs/scene" {
  63125. interface Scene {
  63126. /** @hidden */
  63127. _outlineRenderer: OutlineRenderer;
  63128. /**
  63129. * Gets the outline renderer associated with the scene
  63130. * @returns a OutlineRenderer
  63131. */
  63132. getOutlineRenderer(): OutlineRenderer;
  63133. }
  63134. }
  63135. module "babylonjs/Meshes/abstractMesh" {
  63136. interface AbstractMesh {
  63137. /** @hidden (Backing field) */
  63138. _renderOutline: boolean;
  63139. /**
  63140. * Gets or sets a boolean indicating if the outline must be rendered as well
  63141. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63142. */
  63143. renderOutline: boolean;
  63144. /** @hidden (Backing field) */
  63145. _renderOverlay: boolean;
  63146. /**
  63147. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63148. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63149. */
  63150. renderOverlay: boolean;
  63151. }
  63152. }
  63153. /**
  63154. * This class is responsible to draw bothe outline/overlay of meshes.
  63155. * It should not be used directly but through the available method on mesh.
  63156. */
  63157. export class OutlineRenderer implements ISceneComponent {
  63158. /**
  63159. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63160. */
  63161. private static _StencilReference;
  63162. /**
  63163. * The name of the component. Each component must have a unique name.
  63164. */
  63165. name: string;
  63166. /**
  63167. * The scene the component belongs to.
  63168. */
  63169. scene: Scene;
  63170. /**
  63171. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63172. */
  63173. zOffset: number;
  63174. private _engine;
  63175. private _effect;
  63176. private _cachedDefines;
  63177. private _savedDepthWrite;
  63178. /**
  63179. * Instantiates a new outline renderer. (There could be only one per scene).
  63180. * @param scene Defines the scene it belongs to
  63181. */
  63182. constructor(scene: Scene);
  63183. /**
  63184. * Register the component to one instance of a scene.
  63185. */
  63186. register(): void;
  63187. /**
  63188. * Rebuilds the elements related to this component in case of
  63189. * context lost for instance.
  63190. */
  63191. rebuild(): void;
  63192. /**
  63193. * Disposes the component and the associated ressources.
  63194. */
  63195. dispose(): void;
  63196. /**
  63197. * Renders the outline in the canvas.
  63198. * @param subMesh Defines the sumesh to render
  63199. * @param batch Defines the batch of meshes in case of instances
  63200. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63201. */
  63202. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63203. /**
  63204. * Returns whether or not the outline renderer is ready for a given submesh.
  63205. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63206. * @param subMesh Defines the submesh to check readyness for
  63207. * @param useInstances Defines wheter wee are trying to render instances or not
  63208. * @returns true if ready otherwise false
  63209. */
  63210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63211. private _beforeRenderingMesh;
  63212. private _afterRenderingMesh;
  63213. }
  63214. }
  63215. declare module "babylonjs/Rendering/index" {
  63216. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63217. export * from "babylonjs/Rendering/depthRenderer";
  63218. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63219. export * from "babylonjs/Rendering/edgesRenderer";
  63220. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63221. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63222. export * from "babylonjs/Rendering/outlineRenderer";
  63223. export * from "babylonjs/Rendering/renderingGroup";
  63224. export * from "babylonjs/Rendering/renderingManager";
  63225. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63226. }
  63227. declare module "babylonjs/Sprites/spritePackedManager" {
  63228. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63229. import { Scene } from "babylonjs/scene";
  63230. /**
  63231. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63232. * @see http://doc.babylonjs.com/babylon101/sprites
  63233. */
  63234. export class SpritePackedManager extends SpriteManager {
  63235. /** defines the packed manager's name */
  63236. name: string;
  63237. /**
  63238. * Creates a new sprite manager from a packed sprite sheet
  63239. * @param name defines the manager's name
  63240. * @param imgUrl defines the sprite sheet url
  63241. * @param capacity defines the maximum allowed number of sprites
  63242. * @param scene defines the hosting scene
  63243. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63244. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63245. * @param samplingMode defines the smapling mode to use with spritesheet
  63246. * @param fromPacked set to true; do not alter
  63247. */
  63248. constructor(
  63249. /** defines the packed manager's name */
  63250. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63251. }
  63252. }
  63253. declare module "babylonjs/Sprites/index" {
  63254. export * from "babylonjs/Sprites/sprite";
  63255. export * from "babylonjs/Sprites/spriteManager";
  63256. export * from "babylonjs/Sprites/spritePackedManager";
  63257. export * from "babylonjs/Sprites/spriteSceneComponent";
  63258. }
  63259. declare module "babylonjs/Misc/assetsManager" {
  63260. import { Scene } from "babylonjs/scene";
  63261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63262. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63263. import { Skeleton } from "babylonjs/Bones/skeleton";
  63264. import { Observable } from "babylonjs/Misc/observable";
  63265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63266. import { Texture } from "babylonjs/Materials/Textures/texture";
  63267. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63268. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63269. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63270. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63271. /**
  63272. * Defines the list of states available for a task inside a AssetsManager
  63273. */
  63274. export enum AssetTaskState {
  63275. /**
  63276. * Initialization
  63277. */
  63278. INIT = 0,
  63279. /**
  63280. * Running
  63281. */
  63282. RUNNING = 1,
  63283. /**
  63284. * Done
  63285. */
  63286. DONE = 2,
  63287. /**
  63288. * Error
  63289. */
  63290. ERROR = 3
  63291. }
  63292. /**
  63293. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63294. */
  63295. export abstract class AbstractAssetTask {
  63296. /**
  63297. * Task name
  63298. */ name: string;
  63299. /**
  63300. * Callback called when the task is successful
  63301. */
  63302. onSuccess: (task: any) => void;
  63303. /**
  63304. * Callback called when the task is not successful
  63305. */
  63306. onError: (task: any, message?: string, exception?: any) => void;
  63307. /**
  63308. * Creates a new AssetsManager
  63309. * @param name defines the name of the task
  63310. */
  63311. constructor(
  63312. /**
  63313. * Task name
  63314. */ name: string);
  63315. private _isCompleted;
  63316. private _taskState;
  63317. private _errorObject;
  63318. /**
  63319. * Get if the task is completed
  63320. */
  63321. readonly isCompleted: boolean;
  63322. /**
  63323. * Gets the current state of the task
  63324. */
  63325. readonly taskState: AssetTaskState;
  63326. /**
  63327. * Gets the current error object (if task is in error)
  63328. */
  63329. readonly errorObject: {
  63330. message?: string;
  63331. exception?: any;
  63332. };
  63333. /**
  63334. * Internal only
  63335. * @hidden
  63336. */
  63337. _setErrorObject(message?: string, exception?: any): void;
  63338. /**
  63339. * Execute the current task
  63340. * @param scene defines the scene where you want your assets to be loaded
  63341. * @param onSuccess is a callback called when the task is successfully executed
  63342. * @param onError is a callback called if an error occurs
  63343. */
  63344. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63345. /**
  63346. * Execute the current task
  63347. * @param scene defines the scene where you want your assets to be loaded
  63348. * @param onSuccess is a callback called when the task is successfully executed
  63349. * @param onError is a callback called if an error occurs
  63350. */
  63351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63352. /**
  63353. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63354. * This can be used with failed tasks that have the reason for failure fixed.
  63355. */
  63356. reset(): void;
  63357. private onErrorCallback;
  63358. private onDoneCallback;
  63359. }
  63360. /**
  63361. * Define the interface used by progress events raised during assets loading
  63362. */
  63363. export interface IAssetsProgressEvent {
  63364. /**
  63365. * Defines the number of remaining tasks to process
  63366. */
  63367. remainingCount: number;
  63368. /**
  63369. * Defines the total number of tasks
  63370. */
  63371. totalCount: number;
  63372. /**
  63373. * Defines the task that was just processed
  63374. */
  63375. task: AbstractAssetTask;
  63376. }
  63377. /**
  63378. * Class used to share progress information about assets loading
  63379. */
  63380. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63381. /**
  63382. * Defines the number of remaining tasks to process
  63383. */
  63384. remainingCount: number;
  63385. /**
  63386. * Defines the total number of tasks
  63387. */
  63388. totalCount: number;
  63389. /**
  63390. * Defines the task that was just processed
  63391. */
  63392. task: AbstractAssetTask;
  63393. /**
  63394. * Creates a AssetsProgressEvent
  63395. * @param remainingCount defines the number of remaining tasks to process
  63396. * @param totalCount defines the total number of tasks
  63397. * @param task defines the task that was just processed
  63398. */
  63399. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63400. }
  63401. /**
  63402. * Define a task used by AssetsManager to load meshes
  63403. */
  63404. export class MeshAssetTask extends AbstractAssetTask {
  63405. /**
  63406. * Defines the name of the task
  63407. */
  63408. name: string;
  63409. /**
  63410. * Defines the list of mesh's names you want to load
  63411. */
  63412. meshesNames: any;
  63413. /**
  63414. * Defines the root url to use as a base to load your meshes and associated resources
  63415. */
  63416. rootUrl: string;
  63417. /**
  63418. * Defines the filename of the scene to load from
  63419. */
  63420. sceneFilename: string;
  63421. /**
  63422. * Gets the list of loaded meshes
  63423. */
  63424. loadedMeshes: Array<AbstractMesh>;
  63425. /**
  63426. * Gets the list of loaded particle systems
  63427. */
  63428. loadedParticleSystems: Array<IParticleSystem>;
  63429. /**
  63430. * Gets the list of loaded skeletons
  63431. */
  63432. loadedSkeletons: Array<Skeleton>;
  63433. /**
  63434. * Gets the list of loaded animation groups
  63435. */
  63436. loadedAnimationGroups: Array<AnimationGroup>;
  63437. /**
  63438. * Callback called when the task is successful
  63439. */
  63440. onSuccess: (task: MeshAssetTask) => void;
  63441. /**
  63442. * Callback called when the task is successful
  63443. */
  63444. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63445. /**
  63446. * Creates a new MeshAssetTask
  63447. * @param name defines the name of the task
  63448. * @param meshesNames defines the list of mesh's names you want to load
  63449. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63450. * @param sceneFilename defines the filename of the scene to load from
  63451. */
  63452. constructor(
  63453. /**
  63454. * Defines the name of the task
  63455. */
  63456. name: string,
  63457. /**
  63458. * Defines the list of mesh's names you want to load
  63459. */
  63460. meshesNames: any,
  63461. /**
  63462. * Defines the root url to use as a base to load your meshes and associated resources
  63463. */
  63464. rootUrl: string,
  63465. /**
  63466. * Defines the filename of the scene to load from
  63467. */
  63468. sceneFilename: string);
  63469. /**
  63470. * Execute the current task
  63471. * @param scene defines the scene where you want your assets to be loaded
  63472. * @param onSuccess is a callback called when the task is successfully executed
  63473. * @param onError is a callback called if an error occurs
  63474. */
  63475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63476. }
  63477. /**
  63478. * Define a task used by AssetsManager to load text content
  63479. */
  63480. export class TextFileAssetTask extends AbstractAssetTask {
  63481. /**
  63482. * Defines the name of the task
  63483. */
  63484. name: string;
  63485. /**
  63486. * Defines the location of the file to load
  63487. */
  63488. url: string;
  63489. /**
  63490. * Gets the loaded text string
  63491. */
  63492. text: string;
  63493. /**
  63494. * Callback called when the task is successful
  63495. */
  63496. onSuccess: (task: TextFileAssetTask) => void;
  63497. /**
  63498. * Callback called when the task is successful
  63499. */
  63500. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63501. /**
  63502. * Creates a new TextFileAssetTask object
  63503. * @param name defines the name of the task
  63504. * @param url defines the location of the file to load
  63505. */
  63506. constructor(
  63507. /**
  63508. * Defines the name of the task
  63509. */
  63510. name: string,
  63511. /**
  63512. * Defines the location of the file to load
  63513. */
  63514. url: string);
  63515. /**
  63516. * Execute the current task
  63517. * @param scene defines the scene where you want your assets to be loaded
  63518. * @param onSuccess is a callback called when the task is successfully executed
  63519. * @param onError is a callback called if an error occurs
  63520. */
  63521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63522. }
  63523. /**
  63524. * Define a task used by AssetsManager to load binary data
  63525. */
  63526. export class BinaryFileAssetTask extends AbstractAssetTask {
  63527. /**
  63528. * Defines the name of the task
  63529. */
  63530. name: string;
  63531. /**
  63532. * Defines the location of the file to load
  63533. */
  63534. url: string;
  63535. /**
  63536. * Gets the lodaded data (as an array buffer)
  63537. */
  63538. data: ArrayBuffer;
  63539. /**
  63540. * Callback called when the task is successful
  63541. */
  63542. onSuccess: (task: BinaryFileAssetTask) => void;
  63543. /**
  63544. * Callback called when the task is successful
  63545. */
  63546. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63547. /**
  63548. * Creates a new BinaryFileAssetTask object
  63549. * @param name defines the name of the new task
  63550. * @param url defines the location of the file to load
  63551. */
  63552. constructor(
  63553. /**
  63554. * Defines the name of the task
  63555. */
  63556. name: string,
  63557. /**
  63558. * Defines the location of the file to load
  63559. */
  63560. url: string);
  63561. /**
  63562. * Execute the current task
  63563. * @param scene defines the scene where you want your assets to be loaded
  63564. * @param onSuccess is a callback called when the task is successfully executed
  63565. * @param onError is a callback called if an error occurs
  63566. */
  63567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63568. }
  63569. /**
  63570. * Define a task used by AssetsManager to load images
  63571. */
  63572. export class ImageAssetTask extends AbstractAssetTask {
  63573. /**
  63574. * Defines the name of the task
  63575. */
  63576. name: string;
  63577. /**
  63578. * Defines the location of the image to load
  63579. */
  63580. url: string;
  63581. /**
  63582. * Gets the loaded images
  63583. */
  63584. image: HTMLImageElement;
  63585. /**
  63586. * Callback called when the task is successful
  63587. */
  63588. onSuccess: (task: ImageAssetTask) => void;
  63589. /**
  63590. * Callback called when the task is successful
  63591. */
  63592. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63593. /**
  63594. * Creates a new ImageAssetTask
  63595. * @param name defines the name of the task
  63596. * @param url defines the location of the image to load
  63597. */
  63598. constructor(
  63599. /**
  63600. * Defines the name of the task
  63601. */
  63602. name: string,
  63603. /**
  63604. * Defines the location of the image to load
  63605. */
  63606. url: string);
  63607. /**
  63608. * Execute the current task
  63609. * @param scene defines the scene where you want your assets to be loaded
  63610. * @param onSuccess is a callback called when the task is successfully executed
  63611. * @param onError is a callback called if an error occurs
  63612. */
  63613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63614. }
  63615. /**
  63616. * Defines the interface used by texture loading tasks
  63617. */
  63618. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63619. /**
  63620. * Gets the loaded texture
  63621. */
  63622. texture: TEX;
  63623. }
  63624. /**
  63625. * Define a task used by AssetsManager to load 2D textures
  63626. */
  63627. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63628. /**
  63629. * Defines the name of the task
  63630. */
  63631. name: string;
  63632. /**
  63633. * Defines the location of the file to load
  63634. */
  63635. url: string;
  63636. /**
  63637. * Defines if mipmap should not be generated (default is false)
  63638. */
  63639. noMipmap?: boolean | undefined;
  63640. /**
  63641. * Defines if texture must be inverted on Y axis (default is false)
  63642. */
  63643. invertY?: boolean | undefined;
  63644. /**
  63645. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63646. */
  63647. samplingMode: number;
  63648. /**
  63649. * Gets the loaded texture
  63650. */
  63651. texture: Texture;
  63652. /**
  63653. * Callback called when the task is successful
  63654. */
  63655. onSuccess: (task: TextureAssetTask) => void;
  63656. /**
  63657. * Callback called when the task is successful
  63658. */
  63659. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63660. /**
  63661. * Creates a new TextureAssetTask object
  63662. * @param name defines the name of the task
  63663. * @param url defines the location of the file to load
  63664. * @param noMipmap defines if mipmap should not be generated (default is false)
  63665. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63666. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63667. */
  63668. constructor(
  63669. /**
  63670. * Defines the name of the task
  63671. */
  63672. name: string,
  63673. /**
  63674. * Defines the location of the file to load
  63675. */
  63676. url: string,
  63677. /**
  63678. * Defines if mipmap should not be generated (default is false)
  63679. */
  63680. noMipmap?: boolean | undefined,
  63681. /**
  63682. * Defines if texture must be inverted on Y axis (default is false)
  63683. */
  63684. invertY?: boolean | undefined,
  63685. /**
  63686. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63687. */
  63688. samplingMode?: number);
  63689. /**
  63690. * Execute the current task
  63691. * @param scene defines the scene where you want your assets to be loaded
  63692. * @param onSuccess is a callback called when the task is successfully executed
  63693. * @param onError is a callback called if an error occurs
  63694. */
  63695. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63696. }
  63697. /**
  63698. * Define a task used by AssetsManager to load cube textures
  63699. */
  63700. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63701. /**
  63702. * Defines the name of the task
  63703. */
  63704. name: string;
  63705. /**
  63706. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63707. */
  63708. url: string;
  63709. /**
  63710. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63711. */
  63712. extensions?: string[] | undefined;
  63713. /**
  63714. * Defines if mipmaps should not be generated (default is false)
  63715. */
  63716. noMipmap?: boolean | undefined;
  63717. /**
  63718. * Defines the explicit list of files (undefined by default)
  63719. */
  63720. files?: string[] | undefined;
  63721. /**
  63722. * Gets the loaded texture
  63723. */
  63724. texture: CubeTexture;
  63725. /**
  63726. * Callback called when the task is successful
  63727. */
  63728. onSuccess: (task: CubeTextureAssetTask) => void;
  63729. /**
  63730. * Callback called when the task is successful
  63731. */
  63732. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63733. /**
  63734. * Creates a new CubeTextureAssetTask
  63735. * @param name defines the name of the task
  63736. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63737. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63738. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63739. * @param files defines the explicit list of files (undefined by default)
  63740. */
  63741. constructor(
  63742. /**
  63743. * Defines the name of the task
  63744. */
  63745. name: string,
  63746. /**
  63747. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63748. */
  63749. url: string,
  63750. /**
  63751. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63752. */
  63753. extensions?: string[] | undefined,
  63754. /**
  63755. * Defines if mipmaps should not be generated (default is false)
  63756. */
  63757. noMipmap?: boolean | undefined,
  63758. /**
  63759. * Defines the explicit list of files (undefined by default)
  63760. */
  63761. files?: string[] | undefined);
  63762. /**
  63763. * Execute the current task
  63764. * @param scene defines the scene where you want your assets to be loaded
  63765. * @param onSuccess is a callback called when the task is successfully executed
  63766. * @param onError is a callback called if an error occurs
  63767. */
  63768. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63769. }
  63770. /**
  63771. * Define a task used by AssetsManager to load HDR cube textures
  63772. */
  63773. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63774. /**
  63775. * Defines the name of the task
  63776. */
  63777. name: string;
  63778. /**
  63779. * Defines the location of the file to load
  63780. */
  63781. url: string;
  63782. /**
  63783. * Defines the desired size (the more it increases the longer the generation will be)
  63784. */
  63785. size: number;
  63786. /**
  63787. * Defines if mipmaps should not be generated (default is false)
  63788. */
  63789. noMipmap: boolean;
  63790. /**
  63791. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63792. */
  63793. generateHarmonics: boolean;
  63794. /**
  63795. * 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)
  63796. */
  63797. gammaSpace: boolean;
  63798. /**
  63799. * Internal Use Only
  63800. */
  63801. reserved: boolean;
  63802. /**
  63803. * Gets the loaded texture
  63804. */
  63805. texture: HDRCubeTexture;
  63806. /**
  63807. * Callback called when the task is successful
  63808. */
  63809. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63810. /**
  63811. * Callback called when the task is successful
  63812. */
  63813. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63814. /**
  63815. * Creates a new HDRCubeTextureAssetTask object
  63816. * @param name defines the name of the task
  63817. * @param url defines the location of the file to load
  63818. * @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.
  63819. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63820. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63821. * @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)
  63822. * @param reserved Internal use only
  63823. */
  63824. constructor(
  63825. /**
  63826. * Defines the name of the task
  63827. */
  63828. name: string,
  63829. /**
  63830. * Defines the location of the file to load
  63831. */
  63832. url: string,
  63833. /**
  63834. * Defines the desired size (the more it increases the longer the generation will be)
  63835. */
  63836. size: number,
  63837. /**
  63838. * Defines if mipmaps should not be generated (default is false)
  63839. */
  63840. noMipmap?: boolean,
  63841. /**
  63842. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63843. */
  63844. generateHarmonics?: boolean,
  63845. /**
  63846. * 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)
  63847. */
  63848. gammaSpace?: boolean,
  63849. /**
  63850. * Internal Use Only
  63851. */
  63852. reserved?: boolean);
  63853. /**
  63854. * Execute the current task
  63855. * @param scene defines the scene where you want your assets to be loaded
  63856. * @param onSuccess is a callback called when the task is successfully executed
  63857. * @param onError is a callback called if an error occurs
  63858. */
  63859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63860. }
  63861. /**
  63862. * Define a task used by AssetsManager to load Equirectangular cube textures
  63863. */
  63864. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63865. /**
  63866. * Defines the name of the task
  63867. */
  63868. name: string;
  63869. /**
  63870. * Defines the location of the file to load
  63871. */
  63872. url: string;
  63873. /**
  63874. * Defines the desired size (the more it increases the longer the generation will be)
  63875. */
  63876. size: number;
  63877. /**
  63878. * Defines if mipmaps should not be generated (default is false)
  63879. */
  63880. noMipmap: boolean;
  63881. /**
  63882. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63883. * but the standard material would require them in Gamma space) (default is true)
  63884. */
  63885. gammaSpace: boolean;
  63886. /**
  63887. * Gets the loaded texture
  63888. */
  63889. texture: EquiRectangularCubeTexture;
  63890. /**
  63891. * Callback called when the task is successful
  63892. */
  63893. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63894. /**
  63895. * Callback called when the task is successful
  63896. */
  63897. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63898. /**
  63899. * Creates a new EquiRectangularCubeTextureAssetTask object
  63900. * @param name defines the name of the task
  63901. * @param url defines the location of the file to load
  63902. * @param size defines the desired size (the more it increases the longer the generation will be)
  63903. * If the size is omitted this implies you are using a preprocessed cubemap.
  63904. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63905. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63906. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63907. * (default is true)
  63908. */
  63909. constructor(
  63910. /**
  63911. * Defines the name of the task
  63912. */
  63913. name: string,
  63914. /**
  63915. * Defines the location of the file to load
  63916. */
  63917. url: string,
  63918. /**
  63919. * Defines the desired size (the more it increases the longer the generation will be)
  63920. */
  63921. size: number,
  63922. /**
  63923. * Defines if mipmaps should not be generated (default is false)
  63924. */
  63925. noMipmap?: boolean,
  63926. /**
  63927. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63928. * but the standard material would require them in Gamma space) (default is true)
  63929. */
  63930. gammaSpace?: boolean);
  63931. /**
  63932. * Execute the current task
  63933. * @param scene defines the scene where you want your assets to be loaded
  63934. * @param onSuccess is a callback called when the task is successfully executed
  63935. * @param onError is a callback called if an error occurs
  63936. */
  63937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63938. }
  63939. /**
  63940. * This class can be used to easily import assets into a scene
  63941. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63942. */
  63943. export class AssetsManager {
  63944. private _scene;
  63945. private _isLoading;
  63946. protected _tasks: AbstractAssetTask[];
  63947. protected _waitingTasksCount: number;
  63948. protected _totalTasksCount: number;
  63949. /**
  63950. * Callback called when all tasks are processed
  63951. */
  63952. onFinish: (tasks: AbstractAssetTask[]) => void;
  63953. /**
  63954. * Callback called when a task is successful
  63955. */
  63956. onTaskSuccess: (task: AbstractAssetTask) => void;
  63957. /**
  63958. * Callback called when a task had an error
  63959. */
  63960. onTaskError: (task: AbstractAssetTask) => void;
  63961. /**
  63962. * Callback called when a task is done (whatever the result is)
  63963. */
  63964. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63965. /**
  63966. * Observable called when all tasks are processed
  63967. */
  63968. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63969. /**
  63970. * Observable called when a task had an error
  63971. */
  63972. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63973. /**
  63974. * Observable called when all tasks were executed
  63975. */
  63976. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63977. /**
  63978. * Observable called when a task is done (whatever the result is)
  63979. */
  63980. onProgressObservable: Observable<IAssetsProgressEvent>;
  63981. /**
  63982. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63984. */
  63985. useDefaultLoadingScreen: boolean;
  63986. /**
  63987. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63988. * when all assets have been downloaded.
  63989. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63990. */
  63991. autoHideLoadingUI: boolean;
  63992. /**
  63993. * Creates a new AssetsManager
  63994. * @param scene defines the scene to work on
  63995. */
  63996. constructor(scene: Scene);
  63997. /**
  63998. * Add a MeshAssetTask to the list of active tasks
  63999. * @param taskName defines the name of the new task
  64000. * @param meshesNames defines the name of meshes to load
  64001. * @param rootUrl defines the root url to use to locate files
  64002. * @param sceneFilename defines the filename of the scene file
  64003. * @returns a new MeshAssetTask object
  64004. */
  64005. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64006. /**
  64007. * Add a TextFileAssetTask to the list of active tasks
  64008. * @param taskName defines the name of the new task
  64009. * @param url defines the url of the file to load
  64010. * @returns a new TextFileAssetTask object
  64011. */
  64012. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64013. /**
  64014. * Add a BinaryFileAssetTask to the list of active tasks
  64015. * @param taskName defines the name of the new task
  64016. * @param url defines the url of the file to load
  64017. * @returns a new BinaryFileAssetTask object
  64018. */
  64019. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64020. /**
  64021. * Add a ImageAssetTask to the list of active tasks
  64022. * @param taskName defines the name of the new task
  64023. * @param url defines the url of the file to load
  64024. * @returns a new ImageAssetTask object
  64025. */
  64026. addImageTask(taskName: string, url: string): ImageAssetTask;
  64027. /**
  64028. * Add a TextureAssetTask to the list of active tasks
  64029. * @param taskName defines the name of the new task
  64030. * @param url defines the url of the file to load
  64031. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64032. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64033. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64034. * @returns a new TextureAssetTask object
  64035. */
  64036. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64037. /**
  64038. * Add a CubeTextureAssetTask to the list of active tasks
  64039. * @param taskName defines the name of the new task
  64040. * @param url defines the url of the file to load
  64041. * @param extensions defines the extension to use to load the cube map (can be null)
  64042. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64043. * @param files defines the list of files to load (can be null)
  64044. * @returns a new CubeTextureAssetTask object
  64045. */
  64046. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64047. /**
  64048. *
  64049. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64050. * @param taskName defines the name of the new task
  64051. * @param url defines the url of the file to load
  64052. * @param size defines the size you want for the cubemap (can be null)
  64053. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64054. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64055. * @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)
  64056. * @param reserved Internal use only
  64057. * @returns a new HDRCubeTextureAssetTask object
  64058. */
  64059. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64060. /**
  64061. *
  64062. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64063. * @param taskName defines the name of the new task
  64064. * @param url defines the url of the file to load
  64065. * @param size defines the size you want for the cubemap (can be null)
  64066. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64067. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64068. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64069. * @returns a new EquiRectangularCubeTextureAssetTask object
  64070. */
  64071. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64072. /**
  64073. * Remove a task from the assets manager.
  64074. * @param task the task to remove
  64075. */
  64076. removeTask(task: AbstractAssetTask): void;
  64077. private _decreaseWaitingTasksCount;
  64078. private _runTask;
  64079. /**
  64080. * Reset the AssetsManager and remove all tasks
  64081. * @return the current instance of the AssetsManager
  64082. */
  64083. reset(): AssetsManager;
  64084. /**
  64085. * Start the loading process
  64086. * @return the current instance of the AssetsManager
  64087. */
  64088. load(): AssetsManager;
  64089. /**
  64090. * Start the loading process as an async operation
  64091. * @return a promise returning the list of failed tasks
  64092. */
  64093. loadAsync(): Promise<void>;
  64094. }
  64095. }
  64096. declare module "babylonjs/Misc/deferred" {
  64097. /**
  64098. * Wrapper class for promise with external resolve and reject.
  64099. */
  64100. export class Deferred<T> {
  64101. /**
  64102. * The promise associated with this deferred object.
  64103. */
  64104. readonly promise: Promise<T>;
  64105. private _resolve;
  64106. private _reject;
  64107. /**
  64108. * The resolve method of the promise associated with this deferred object.
  64109. */
  64110. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64111. /**
  64112. * The reject method of the promise associated with this deferred object.
  64113. */
  64114. readonly reject: (reason?: any) => void;
  64115. /**
  64116. * Constructor for this deferred object.
  64117. */
  64118. constructor();
  64119. }
  64120. }
  64121. declare module "babylonjs/Misc/meshExploder" {
  64122. import { Mesh } from "babylonjs/Meshes/mesh";
  64123. /**
  64124. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64125. */
  64126. export class MeshExploder {
  64127. private _centerMesh;
  64128. private _meshes;
  64129. private _meshesOrigins;
  64130. private _toCenterVectors;
  64131. private _scaledDirection;
  64132. private _newPosition;
  64133. private _centerPosition;
  64134. /**
  64135. * Explodes meshes from a center mesh.
  64136. * @param meshes The meshes to explode.
  64137. * @param centerMesh The mesh to be center of explosion.
  64138. */
  64139. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64140. private _setCenterMesh;
  64141. /**
  64142. * Get class name
  64143. * @returns "MeshExploder"
  64144. */
  64145. getClassName(): string;
  64146. /**
  64147. * "Exploded meshes"
  64148. * @returns Array of meshes with the centerMesh at index 0.
  64149. */
  64150. getMeshes(): Array<Mesh>;
  64151. /**
  64152. * Explodes meshes giving a specific direction
  64153. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64154. */
  64155. explode(direction?: number): void;
  64156. }
  64157. }
  64158. declare module "babylonjs/Misc/filesInput" {
  64159. import { Engine } from "babylonjs/Engines/engine";
  64160. import { Scene } from "babylonjs/scene";
  64161. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64162. /**
  64163. * Class used to help managing file picking and drag'n'drop
  64164. */
  64165. export class FilesInput {
  64166. /**
  64167. * List of files ready to be loaded
  64168. */
  64169. static readonly FilesToLoad: {
  64170. [key: string]: File;
  64171. };
  64172. /**
  64173. * Callback called when a file is processed
  64174. */
  64175. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64176. private _engine;
  64177. private _currentScene;
  64178. private _sceneLoadedCallback;
  64179. private _progressCallback;
  64180. private _additionalRenderLoopLogicCallback;
  64181. private _textureLoadingCallback;
  64182. private _startingProcessingFilesCallback;
  64183. private _onReloadCallback;
  64184. private _errorCallback;
  64185. private _elementToMonitor;
  64186. private _sceneFileToLoad;
  64187. private _filesToLoad;
  64188. /**
  64189. * Creates a new FilesInput
  64190. * @param engine defines the rendering engine
  64191. * @param scene defines the hosting scene
  64192. * @param sceneLoadedCallback callback called when scene is loaded
  64193. * @param progressCallback callback called to track progress
  64194. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64195. * @param textureLoadingCallback callback called when a texture is loading
  64196. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64197. * @param onReloadCallback callback called when a reload is requested
  64198. * @param errorCallback callback call if an error occurs
  64199. */
  64200. 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);
  64201. private _dragEnterHandler;
  64202. private _dragOverHandler;
  64203. private _dropHandler;
  64204. /**
  64205. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64206. * @param elementToMonitor defines the DOM element to track
  64207. */
  64208. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64209. /**
  64210. * Release all associated resources
  64211. */
  64212. dispose(): void;
  64213. private renderFunction;
  64214. private drag;
  64215. private drop;
  64216. private _traverseFolder;
  64217. private _processFiles;
  64218. /**
  64219. * Load files from a drop event
  64220. * @param event defines the drop event to use as source
  64221. */
  64222. loadFiles(event: any): void;
  64223. private _processReload;
  64224. /**
  64225. * Reload the current scene from the loaded files
  64226. */
  64227. reload(): void;
  64228. }
  64229. }
  64230. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64231. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64232. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64233. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64234. }
  64235. declare module "babylonjs/Misc/sceneOptimizer" {
  64236. import { Scene, IDisposable } from "babylonjs/scene";
  64237. import { Observable } from "babylonjs/Misc/observable";
  64238. /**
  64239. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64241. */
  64242. export class SceneOptimization {
  64243. /**
  64244. * Defines the priority of this optimization (0 by default which means first in the list)
  64245. */
  64246. priority: number;
  64247. /**
  64248. * Gets a string describing the action executed by the current optimization
  64249. * @returns description string
  64250. */
  64251. getDescription(): string;
  64252. /**
  64253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64254. * @param scene defines the current scene where to apply this optimization
  64255. * @param optimizer defines the current optimizer
  64256. * @returns true if everything that can be done was applied
  64257. */
  64258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64259. /**
  64260. * Creates the SceneOptimization object
  64261. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64262. * @param desc defines the description associated with the optimization
  64263. */
  64264. constructor(
  64265. /**
  64266. * Defines the priority of this optimization (0 by default which means first in the list)
  64267. */
  64268. priority?: number);
  64269. }
  64270. /**
  64271. * Defines an optimization used to reduce the size of render target textures
  64272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64273. */
  64274. export class TextureOptimization extends SceneOptimization {
  64275. /**
  64276. * Defines the priority of this optimization (0 by default which means first in the list)
  64277. */
  64278. priority: number;
  64279. /**
  64280. * 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
  64281. */
  64282. maximumSize: number;
  64283. /**
  64284. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64285. */
  64286. step: number;
  64287. /**
  64288. * Gets a string describing the action executed by the current optimization
  64289. * @returns description string
  64290. */
  64291. getDescription(): string;
  64292. /**
  64293. * Creates the TextureOptimization object
  64294. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64295. * @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
  64296. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64297. */
  64298. constructor(
  64299. /**
  64300. * Defines the priority of this optimization (0 by default which means first in the list)
  64301. */
  64302. priority?: number,
  64303. /**
  64304. * 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
  64305. */
  64306. maximumSize?: number,
  64307. /**
  64308. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64309. */
  64310. step?: number);
  64311. /**
  64312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64313. * @param scene defines the current scene where to apply this optimization
  64314. * @param optimizer defines the current optimizer
  64315. * @returns true if everything that can be done was applied
  64316. */
  64317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64318. }
  64319. /**
  64320. * Defines an optimization used to increase or decrease the rendering resolution
  64321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64322. */
  64323. export class HardwareScalingOptimization extends SceneOptimization {
  64324. /**
  64325. * Defines the priority of this optimization (0 by default which means first in the list)
  64326. */
  64327. priority: number;
  64328. /**
  64329. * Defines the maximum scale to use (2 by default)
  64330. */
  64331. maximumScale: number;
  64332. /**
  64333. * Defines the step to use between two passes (0.5 by default)
  64334. */
  64335. step: number;
  64336. private _currentScale;
  64337. private _directionOffset;
  64338. /**
  64339. * Gets a string describing the action executed by the current optimization
  64340. * @return description string
  64341. */
  64342. getDescription(): string;
  64343. /**
  64344. * Creates the HardwareScalingOptimization object
  64345. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64346. * @param maximumScale defines the maximum scale to use (2 by default)
  64347. * @param step defines the step to use between two passes (0.5 by default)
  64348. */
  64349. constructor(
  64350. /**
  64351. * Defines the priority of this optimization (0 by default which means first in the list)
  64352. */
  64353. priority?: number,
  64354. /**
  64355. * Defines the maximum scale to use (2 by default)
  64356. */
  64357. maximumScale?: number,
  64358. /**
  64359. * Defines the step to use between two passes (0.5 by default)
  64360. */
  64361. step?: number);
  64362. /**
  64363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64364. * @param scene defines the current scene where to apply this optimization
  64365. * @param optimizer defines the current optimizer
  64366. * @returns true if everything that can be done was applied
  64367. */
  64368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64369. }
  64370. /**
  64371. * Defines an optimization used to remove shadows
  64372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64373. */
  64374. export class ShadowsOptimization extends SceneOptimization {
  64375. /**
  64376. * Gets a string describing the action executed by the current optimization
  64377. * @return description string
  64378. */
  64379. getDescription(): string;
  64380. /**
  64381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64382. * @param scene defines the current scene where to apply this optimization
  64383. * @param optimizer defines the current optimizer
  64384. * @returns true if everything that can be done was applied
  64385. */
  64386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64387. }
  64388. /**
  64389. * Defines an optimization used to turn post-processes off
  64390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64391. */
  64392. export class PostProcessesOptimization extends SceneOptimization {
  64393. /**
  64394. * Gets a string describing the action executed by the current optimization
  64395. * @return description string
  64396. */
  64397. getDescription(): string;
  64398. /**
  64399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64400. * @param scene defines the current scene where to apply this optimization
  64401. * @param optimizer defines the current optimizer
  64402. * @returns true if everything that can be done was applied
  64403. */
  64404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64405. }
  64406. /**
  64407. * Defines an optimization used to turn lens flares off
  64408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64409. */
  64410. export class LensFlaresOptimization extends SceneOptimization {
  64411. /**
  64412. * Gets a string describing the action executed by the current optimization
  64413. * @return description string
  64414. */
  64415. getDescription(): string;
  64416. /**
  64417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64418. * @param scene defines the current scene where to apply this optimization
  64419. * @param optimizer defines the current optimizer
  64420. * @returns true if everything that can be done was applied
  64421. */
  64422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64423. }
  64424. /**
  64425. * Defines an optimization based on user defined callback.
  64426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64427. */
  64428. export class CustomOptimization extends SceneOptimization {
  64429. /**
  64430. * Callback called to apply the custom optimization.
  64431. */
  64432. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64433. /**
  64434. * Callback called to get custom description
  64435. */
  64436. onGetDescription: () => string;
  64437. /**
  64438. * Gets a string describing the action executed by the current optimization
  64439. * @returns description string
  64440. */
  64441. getDescription(): string;
  64442. /**
  64443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64444. * @param scene defines the current scene where to apply this optimization
  64445. * @param optimizer defines the current optimizer
  64446. * @returns true if everything that can be done was applied
  64447. */
  64448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64449. }
  64450. /**
  64451. * Defines an optimization used to turn particles off
  64452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64453. */
  64454. export class ParticlesOptimization extends SceneOptimization {
  64455. /**
  64456. * Gets a string describing the action executed by the current optimization
  64457. * @return description string
  64458. */
  64459. getDescription(): string;
  64460. /**
  64461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64462. * @param scene defines the current scene where to apply this optimization
  64463. * @param optimizer defines the current optimizer
  64464. * @returns true if everything that can be done was applied
  64465. */
  64466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64467. }
  64468. /**
  64469. * Defines an optimization used to turn render targets off
  64470. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64471. */
  64472. export class RenderTargetsOptimization extends SceneOptimization {
  64473. /**
  64474. * Gets a string describing the action executed by the current optimization
  64475. * @return description string
  64476. */
  64477. getDescription(): string;
  64478. /**
  64479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64480. * @param scene defines the current scene where to apply this optimization
  64481. * @param optimizer defines the current optimizer
  64482. * @returns true if everything that can be done was applied
  64483. */
  64484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64485. }
  64486. /**
  64487. * Defines an optimization used to merge meshes with compatible materials
  64488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64489. */
  64490. export class MergeMeshesOptimization extends SceneOptimization {
  64491. private static _UpdateSelectionTree;
  64492. /**
  64493. * Gets or sets a boolean which defines if optimization octree has to be updated
  64494. */
  64495. /**
  64496. * Gets or sets a boolean which defines if optimization octree has to be updated
  64497. */
  64498. static UpdateSelectionTree: boolean;
  64499. /**
  64500. * Gets a string describing the action executed by the current optimization
  64501. * @return description string
  64502. */
  64503. getDescription(): string;
  64504. private _canBeMerged;
  64505. /**
  64506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64507. * @param scene defines the current scene where to apply this optimization
  64508. * @param optimizer defines the current optimizer
  64509. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64510. * @returns true if everything that can be done was applied
  64511. */
  64512. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64513. }
  64514. /**
  64515. * Defines a list of options used by SceneOptimizer
  64516. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64517. */
  64518. export class SceneOptimizerOptions {
  64519. /**
  64520. * Defines the target frame rate to reach (60 by default)
  64521. */
  64522. targetFrameRate: number;
  64523. /**
  64524. * Defines the interval between two checkes (2000ms by default)
  64525. */
  64526. trackerDuration: number;
  64527. /**
  64528. * Gets the list of optimizations to apply
  64529. */
  64530. optimizations: SceneOptimization[];
  64531. /**
  64532. * Creates a new list of options used by SceneOptimizer
  64533. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64534. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64535. */
  64536. constructor(
  64537. /**
  64538. * Defines the target frame rate to reach (60 by default)
  64539. */
  64540. targetFrameRate?: number,
  64541. /**
  64542. * Defines the interval between two checkes (2000ms by default)
  64543. */
  64544. trackerDuration?: number);
  64545. /**
  64546. * Add a new optimization
  64547. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64548. * @returns the current SceneOptimizerOptions
  64549. */
  64550. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64551. /**
  64552. * Add a new custom optimization
  64553. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64554. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64555. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64556. * @returns the current SceneOptimizerOptions
  64557. */
  64558. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64559. /**
  64560. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64561. * @param targetFrameRate defines the target frame rate (60 by default)
  64562. * @returns a SceneOptimizerOptions object
  64563. */
  64564. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64565. /**
  64566. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64567. * @param targetFrameRate defines the target frame rate (60 by default)
  64568. * @returns a SceneOptimizerOptions object
  64569. */
  64570. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64571. /**
  64572. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64573. * @param targetFrameRate defines the target frame rate (60 by default)
  64574. * @returns a SceneOptimizerOptions object
  64575. */
  64576. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64577. }
  64578. /**
  64579. * Class used to run optimizations in order to reach a target frame rate
  64580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64581. */
  64582. export class SceneOptimizer implements IDisposable {
  64583. private _isRunning;
  64584. private _options;
  64585. private _scene;
  64586. private _currentPriorityLevel;
  64587. private _targetFrameRate;
  64588. private _trackerDuration;
  64589. private _currentFrameRate;
  64590. private _sceneDisposeObserver;
  64591. private _improvementMode;
  64592. /**
  64593. * Defines an observable called when the optimizer reaches the target frame rate
  64594. */
  64595. onSuccessObservable: Observable<SceneOptimizer>;
  64596. /**
  64597. * Defines an observable called when the optimizer enables an optimization
  64598. */
  64599. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64600. /**
  64601. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64602. */
  64603. onFailureObservable: Observable<SceneOptimizer>;
  64604. /**
  64605. * Gets a boolean indicating if the optimizer is in improvement mode
  64606. */
  64607. readonly isInImprovementMode: boolean;
  64608. /**
  64609. * Gets the current priority level (0 at start)
  64610. */
  64611. readonly currentPriorityLevel: number;
  64612. /**
  64613. * Gets the current frame rate checked by the SceneOptimizer
  64614. */
  64615. readonly currentFrameRate: number;
  64616. /**
  64617. * Gets or sets the current target frame rate (60 by default)
  64618. */
  64619. /**
  64620. * Gets or sets the current target frame rate (60 by default)
  64621. */
  64622. targetFrameRate: number;
  64623. /**
  64624. * Gets or sets the current interval between two checks (every 2000ms by default)
  64625. */
  64626. /**
  64627. * Gets or sets the current interval between two checks (every 2000ms by default)
  64628. */
  64629. trackerDuration: number;
  64630. /**
  64631. * Gets the list of active optimizations
  64632. */
  64633. readonly optimizations: SceneOptimization[];
  64634. /**
  64635. * Creates a new SceneOptimizer
  64636. * @param scene defines the scene to work on
  64637. * @param options defines the options to use with the SceneOptimizer
  64638. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64639. * @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)
  64640. */
  64641. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64642. /**
  64643. * Stops the current optimizer
  64644. */
  64645. stop(): void;
  64646. /**
  64647. * Reset the optimizer to initial step (current priority level = 0)
  64648. */
  64649. reset(): void;
  64650. /**
  64651. * Start the optimizer. By default it will try to reach a specific framerate
  64652. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64653. */
  64654. start(): void;
  64655. private _checkCurrentState;
  64656. /**
  64657. * Release all resources
  64658. */
  64659. dispose(): void;
  64660. /**
  64661. * Helper function to create a SceneOptimizer with one single line of code
  64662. * @param scene defines the scene to work on
  64663. * @param options defines the options to use with the SceneOptimizer
  64664. * @param onSuccess defines a callback to call on success
  64665. * @param onFailure defines a callback to call on failure
  64666. * @returns the new SceneOptimizer object
  64667. */
  64668. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64669. }
  64670. }
  64671. declare module "babylonjs/Misc/sceneSerializer" {
  64672. import { Scene } from "babylonjs/scene";
  64673. /**
  64674. * Class used to serialize a scene into a string
  64675. */
  64676. export class SceneSerializer {
  64677. /**
  64678. * Clear cache used by a previous serialization
  64679. */
  64680. static ClearCache(): void;
  64681. /**
  64682. * Serialize a scene into a JSON compatible object
  64683. * @param scene defines the scene to serialize
  64684. * @returns a JSON compatible object
  64685. */
  64686. static Serialize(scene: Scene): any;
  64687. /**
  64688. * Serialize a mesh into a JSON compatible object
  64689. * @param toSerialize defines the mesh to serialize
  64690. * @param withParents defines if parents must be serialized as well
  64691. * @param withChildren defines if children must be serialized as well
  64692. * @returns a JSON compatible object
  64693. */
  64694. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64695. }
  64696. }
  64697. declare module "babylonjs/Misc/textureTools" {
  64698. import { Texture } from "babylonjs/Materials/Textures/texture";
  64699. /**
  64700. * Class used to host texture specific utilities
  64701. */
  64702. export class TextureTools {
  64703. /**
  64704. * Uses the GPU to create a copy texture rescaled at a given size
  64705. * @param texture Texture to copy from
  64706. * @param width defines the desired width
  64707. * @param height defines the desired height
  64708. * @param useBilinearMode defines if bilinear mode has to be used
  64709. * @return the generated texture
  64710. */
  64711. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64712. }
  64713. }
  64714. declare module "babylonjs/Misc/videoRecorder" {
  64715. import { Nullable } from "babylonjs/types";
  64716. import { Engine } from "babylonjs/Engines/engine";
  64717. /**
  64718. * This represents the different options available for the video capture.
  64719. */
  64720. export interface VideoRecorderOptions {
  64721. /** Defines the mime type of the video. */
  64722. mimeType: string;
  64723. /** Defines the FPS the video should be recorded at. */
  64724. fps: number;
  64725. /** Defines the chunk size for the recording data. */
  64726. recordChunckSize: number;
  64727. /** The audio tracks to attach to the recording. */
  64728. audioTracks?: MediaStreamTrack[];
  64729. }
  64730. /**
  64731. * This can help with recording videos from BabylonJS.
  64732. * This is based on the available WebRTC functionalities of the browser.
  64733. *
  64734. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64735. */
  64736. export class VideoRecorder {
  64737. private static readonly _defaultOptions;
  64738. /**
  64739. * Returns whether or not the VideoRecorder is available in your browser.
  64740. * @param engine Defines the Babylon Engine.
  64741. * @returns true if supported otherwise false.
  64742. */
  64743. static IsSupported(engine: Engine): boolean;
  64744. private readonly _options;
  64745. private _canvas;
  64746. private _mediaRecorder;
  64747. private _recordedChunks;
  64748. private _fileName;
  64749. private _resolve;
  64750. private _reject;
  64751. /**
  64752. * True when a recording is already in progress.
  64753. */
  64754. readonly isRecording: boolean;
  64755. /**
  64756. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64757. * @param engine Defines the BabylonJS Engine you wish to record.
  64758. * @param options Defines options that can be used to customize the capture.
  64759. */
  64760. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64761. /**
  64762. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64763. */
  64764. stopRecording(): void;
  64765. /**
  64766. * Starts recording the canvas for a max duration specified in parameters.
  64767. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64768. * If null no automatic download will start and you can rely on the promise to get the data back.
  64769. * @param maxDuration Defines the maximum recording time in seconds.
  64770. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64771. * @return A promise callback at the end of the recording with the video data in Blob.
  64772. */
  64773. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64774. /**
  64775. * Releases internal resources used during the recording.
  64776. */
  64777. dispose(): void;
  64778. private _handleDataAvailable;
  64779. private _handleError;
  64780. private _handleStop;
  64781. }
  64782. }
  64783. declare module "babylonjs/Misc/screenshotTools" {
  64784. import { Camera } from "babylonjs/Cameras/camera";
  64785. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64786. import { Engine } from "babylonjs/Engines/engine";
  64787. /**
  64788. * Class containing a set of static utilities functions for screenshots
  64789. */
  64790. export class ScreenshotTools {
  64791. /**
  64792. * Captures a screenshot of the current rendering
  64793. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64794. * @param engine defines the rendering engine
  64795. * @param camera defines the source camera
  64796. * @param size This parameter can be set to a single number or to an object with the
  64797. * following (optional) properties: precision, width, height. If a single number is passed,
  64798. * it will be used for both width and height. If an object is passed, the screenshot size
  64799. * will be derived from the parameters. The precision property is a multiplier allowing
  64800. * rendering at a higher or lower resolution
  64801. * @param successCallback defines the callback receives a single parameter which contains the
  64802. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64803. * src parameter of an <img> to display it
  64804. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64805. * Check your browser for supported MIME types
  64806. */
  64807. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64808. /**
  64809. * Captures a screenshot of the current rendering
  64810. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64811. * @param engine defines the rendering engine
  64812. * @param camera defines the source camera
  64813. * @param size This parameter can be set to a single number or to an object with the
  64814. * following (optional) properties: precision, width, height. If a single number is passed,
  64815. * it will be used for both width and height. If an object is passed, the screenshot size
  64816. * will be derived from the parameters. The precision property is a multiplier allowing
  64817. * rendering at a higher or lower resolution
  64818. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64819. * Check your browser for supported MIME types
  64820. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64821. * to the src parameter of an <img> to display it
  64822. */
  64823. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64824. /**
  64825. * Generates an image screenshot from the specified camera.
  64826. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64827. * @param engine The engine to use for rendering
  64828. * @param camera The camera to use for rendering
  64829. * @param size This parameter can be set to a single number or to an object with the
  64830. * following (optional) properties: precision, width, height. If a single number is passed,
  64831. * it will be used for both width and height. If an object is passed, the screenshot size
  64832. * will be derived from the parameters. The precision property is a multiplier allowing
  64833. * rendering at a higher or lower resolution
  64834. * @param successCallback The callback receives a single parameter which contains the
  64835. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64836. * src parameter of an <img> to display it
  64837. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64838. * Check your browser for supported MIME types
  64839. * @param samples Texture samples (default: 1)
  64840. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64841. * @param fileName A name for for the downloaded file.
  64842. */
  64843. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64844. /**
  64845. * Generates an image screenshot from the specified camera.
  64846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64847. * @param engine The engine to use for rendering
  64848. * @param camera The camera to use for rendering
  64849. * @param size This parameter can be set to a single number or to an object with the
  64850. * following (optional) properties: precision, width, height. If a single number is passed,
  64851. * it will be used for both width and height. If an object is passed, the screenshot size
  64852. * will be derived from the parameters. The precision property is a multiplier allowing
  64853. * rendering at a higher or lower resolution
  64854. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64855. * Check your browser for supported MIME types
  64856. * @param samples Texture samples (default: 1)
  64857. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64858. * @param fileName A name for for the downloaded file.
  64859. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64860. * to the src parameter of an <img> to display it
  64861. */
  64862. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64863. /**
  64864. * Gets height and width for screenshot size
  64865. * @private
  64866. */
  64867. private static _getScreenshotSize;
  64868. }
  64869. }
  64870. declare module "babylonjs/Misc/index" {
  64871. export * from "babylonjs/Misc/andOrNotEvaluator";
  64872. export * from "babylonjs/Misc/assetsManager";
  64873. export * from "babylonjs/Misc/dds";
  64874. export * from "babylonjs/Misc/decorators";
  64875. export * from "babylonjs/Misc/deferred";
  64876. export * from "babylonjs/Misc/environmentTextureTools";
  64877. export * from "babylonjs/Misc/meshExploder";
  64878. export * from "babylonjs/Misc/filesInput";
  64879. export * from "babylonjs/Misc/HighDynamicRange/index";
  64880. export * from "babylonjs/Misc/khronosTextureContainer";
  64881. export * from "babylonjs/Misc/observable";
  64882. export * from "babylonjs/Misc/performanceMonitor";
  64883. export * from "babylonjs/Misc/promise";
  64884. export * from "babylonjs/Misc/sceneOptimizer";
  64885. export * from "babylonjs/Misc/sceneSerializer";
  64886. export * from "babylonjs/Misc/smartArray";
  64887. export * from "babylonjs/Misc/stringDictionary";
  64888. export * from "babylonjs/Misc/tags";
  64889. export * from "babylonjs/Misc/textureTools";
  64890. export * from "babylonjs/Misc/tga";
  64891. export * from "babylonjs/Misc/tools";
  64892. export * from "babylonjs/Misc/videoRecorder";
  64893. export * from "babylonjs/Misc/virtualJoystick";
  64894. export * from "babylonjs/Misc/workerPool";
  64895. export * from "babylonjs/Misc/logger";
  64896. export * from "babylonjs/Misc/typeStore";
  64897. export * from "babylonjs/Misc/filesInputStore";
  64898. export * from "babylonjs/Misc/deepCopier";
  64899. export * from "babylonjs/Misc/pivotTools";
  64900. export * from "babylonjs/Misc/precisionDate";
  64901. export * from "babylonjs/Misc/screenshotTools";
  64902. export * from "babylonjs/Misc/typeStore";
  64903. export * from "babylonjs/Misc/webRequest";
  64904. export * from "babylonjs/Misc/iInspectable";
  64905. export * from "babylonjs/Misc/brdfTextureTools";
  64906. export * from "babylonjs/Misc/gradients";
  64907. export * from "babylonjs/Misc/perfCounter";
  64908. export * from "babylonjs/Misc/fileRequest";
  64909. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64910. export * from "babylonjs/Misc/retryStrategy";
  64911. export * from "babylonjs/Misc/loadFileError";
  64912. }
  64913. declare module "babylonjs/index" {
  64914. export * from "babylonjs/abstractScene";
  64915. export * from "babylonjs/Actions/index";
  64916. export * from "babylonjs/Animations/index";
  64917. export * from "babylonjs/assetContainer";
  64918. export * from "babylonjs/Audio/index";
  64919. export * from "babylonjs/Behaviors/index";
  64920. export * from "babylonjs/Bones/index";
  64921. export * from "babylonjs/Cameras/index";
  64922. export * from "babylonjs/Collisions/index";
  64923. export * from "babylonjs/Culling/index";
  64924. export * from "babylonjs/Debug/index";
  64925. export * from "babylonjs/Engines/index";
  64926. export * from "babylonjs/Events/index";
  64927. export * from "babylonjs/Gamepads/index";
  64928. export * from "babylonjs/Gizmos/index";
  64929. export * from "babylonjs/Helpers/index";
  64930. export * from "babylonjs/Instrumentation/index";
  64931. export * from "babylonjs/Layers/index";
  64932. export * from "babylonjs/LensFlares/index";
  64933. export * from "babylonjs/Lights/index";
  64934. export * from "babylonjs/Loading/index";
  64935. export * from "babylonjs/Materials/index";
  64936. export * from "babylonjs/Maths/index";
  64937. export * from "babylonjs/Meshes/index";
  64938. export * from "babylonjs/Morph/index";
  64939. export * from "babylonjs/Navigation/index";
  64940. export * from "babylonjs/node";
  64941. export * from "babylonjs/Offline/index";
  64942. export * from "babylonjs/Particles/index";
  64943. export * from "babylonjs/Physics/index";
  64944. export * from "babylonjs/PostProcesses/index";
  64945. export * from "babylonjs/Probes/index";
  64946. export * from "babylonjs/Rendering/index";
  64947. export * from "babylonjs/scene";
  64948. export * from "babylonjs/sceneComponent";
  64949. export * from "babylonjs/Sprites/index";
  64950. export * from "babylonjs/States/index";
  64951. export * from "babylonjs/Misc/index";
  64952. export * from "babylonjs/types";
  64953. }
  64954. declare module "babylonjs/Animations/pathCursor" {
  64955. import { Vector3 } from "babylonjs/Maths/math.vector";
  64956. import { Path2 } from "babylonjs/Maths/math.path";
  64957. /**
  64958. * A cursor which tracks a point on a path
  64959. */
  64960. export class PathCursor {
  64961. private path;
  64962. /**
  64963. * Stores path cursor callbacks for when an onchange event is triggered
  64964. */
  64965. private _onchange;
  64966. /**
  64967. * The value of the path cursor
  64968. */
  64969. value: number;
  64970. /**
  64971. * The animation array of the path cursor
  64972. */
  64973. animations: Animation[];
  64974. /**
  64975. * Initializes the path cursor
  64976. * @param path The path to track
  64977. */
  64978. constructor(path: Path2);
  64979. /**
  64980. * Gets the cursor point on the path
  64981. * @returns A point on the path cursor at the cursor location
  64982. */
  64983. getPoint(): Vector3;
  64984. /**
  64985. * Moves the cursor ahead by the step amount
  64986. * @param step The amount to move the cursor forward
  64987. * @returns This path cursor
  64988. */
  64989. moveAhead(step?: number): PathCursor;
  64990. /**
  64991. * Moves the cursor behind by the step amount
  64992. * @param step The amount to move the cursor back
  64993. * @returns This path cursor
  64994. */
  64995. moveBack(step?: number): PathCursor;
  64996. /**
  64997. * Moves the cursor by the step amount
  64998. * If the step amount is greater than one, an exception is thrown
  64999. * @param step The amount to move the cursor
  65000. * @returns This path cursor
  65001. */
  65002. move(step: number): PathCursor;
  65003. /**
  65004. * Ensures that the value is limited between zero and one
  65005. * @returns This path cursor
  65006. */
  65007. private ensureLimits;
  65008. /**
  65009. * Runs onchange callbacks on change (used by the animation engine)
  65010. * @returns This path cursor
  65011. */
  65012. private raiseOnChange;
  65013. /**
  65014. * Executes a function on change
  65015. * @param f A path cursor onchange callback
  65016. * @returns This path cursor
  65017. */
  65018. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65019. }
  65020. }
  65021. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65022. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65023. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65024. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65025. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65026. }
  65027. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65028. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65029. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65030. }
  65031. declare module "babylonjs/Engines/Processors/index" {
  65032. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65033. export * from "babylonjs/Engines/Processors/Expressions/index";
  65034. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65035. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65036. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65037. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65038. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65039. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65040. }
  65041. declare module "babylonjs/Legacy/legacy" {
  65042. import * as Babylon from "babylonjs/index";
  65043. export * from "babylonjs/index";
  65044. }
  65045. declare module "babylonjs/Shaders/blur.fragment" {
  65046. /** @hidden */
  65047. export var blurPixelShader: {
  65048. name: string;
  65049. shader: string;
  65050. };
  65051. }
  65052. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65053. /** @hidden */
  65054. export var pointCloudVertexDeclaration: {
  65055. name: string;
  65056. shader: string;
  65057. };
  65058. }
  65059. declare module "babylonjs" {
  65060. export * from "babylonjs/Legacy/legacy";
  65061. }
  65062. declare module BABYLON {
  65063. /** Alias type for value that can be null */
  65064. export type Nullable<T> = T | null;
  65065. /**
  65066. * Alias type for number that are floats
  65067. * @ignorenaming
  65068. */
  65069. export type float = number;
  65070. /**
  65071. * Alias type for number that are doubles.
  65072. * @ignorenaming
  65073. */
  65074. export type double = number;
  65075. /**
  65076. * Alias type for number that are integer
  65077. * @ignorenaming
  65078. */
  65079. export type int = number;
  65080. /** Alias type for number array or Float32Array */
  65081. export type FloatArray = number[] | Float32Array;
  65082. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65083. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65084. /**
  65085. * Alias for types that can be used by a Buffer or VertexBuffer.
  65086. */
  65087. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65088. /**
  65089. * Alias type for primitive types
  65090. * @ignorenaming
  65091. */
  65092. type Primitive = undefined | null | boolean | string | number | Function;
  65093. /**
  65094. * Type modifier to make all the properties of an object Readonly
  65095. */
  65096. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65097. /**
  65098. * Type modifier to make all the properties of an object Readonly recursively
  65099. */
  65100. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65101. /** @hidden */
  65102. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65103. }
  65104. /** @hidden */
  65105. /** @hidden */
  65106. type DeepImmutableObject<T> = {
  65107. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65108. };
  65109. }
  65110. declare module BABYLON {
  65111. /**
  65112. * A class serves as a medium between the observable and its observers
  65113. */
  65114. export class EventState {
  65115. /**
  65116. * Create a new EventState
  65117. * @param mask defines the mask associated with this state
  65118. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65119. * @param target defines the original target of the state
  65120. * @param currentTarget defines the current target of the state
  65121. */
  65122. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65123. /**
  65124. * Initialize the current event state
  65125. * @param mask defines the mask associated with this state
  65126. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65127. * @param target defines the original target of the state
  65128. * @param currentTarget defines the current target of the state
  65129. * @returns the current event state
  65130. */
  65131. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65132. /**
  65133. * An Observer can set this property to true to prevent subsequent observers of being notified
  65134. */
  65135. skipNextObservers: boolean;
  65136. /**
  65137. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65138. */
  65139. mask: number;
  65140. /**
  65141. * The object that originally notified the event
  65142. */
  65143. target?: any;
  65144. /**
  65145. * The current object in the bubbling phase
  65146. */
  65147. currentTarget?: any;
  65148. /**
  65149. * This will be populated with the return value of the last function that was executed.
  65150. * If it is the first function in the callback chain it will be the event data.
  65151. */
  65152. lastReturnValue?: any;
  65153. }
  65154. /**
  65155. * Represent an Observer registered to a given Observable object.
  65156. */
  65157. export class Observer<T> {
  65158. /**
  65159. * Defines the callback to call when the observer is notified
  65160. */
  65161. callback: (eventData: T, eventState: EventState) => void;
  65162. /**
  65163. * Defines the mask of the observer (used to filter notifications)
  65164. */
  65165. mask: number;
  65166. /**
  65167. * Defines the current scope used to restore the JS context
  65168. */
  65169. scope: any;
  65170. /** @hidden */
  65171. _willBeUnregistered: boolean;
  65172. /**
  65173. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65174. */
  65175. unregisterOnNextCall: boolean;
  65176. /**
  65177. * Creates a new observer
  65178. * @param callback defines the callback to call when the observer is notified
  65179. * @param mask defines the mask of the observer (used to filter notifications)
  65180. * @param scope defines the current scope used to restore the JS context
  65181. */
  65182. constructor(
  65183. /**
  65184. * Defines the callback to call when the observer is notified
  65185. */
  65186. callback: (eventData: T, eventState: EventState) => void,
  65187. /**
  65188. * Defines the mask of the observer (used to filter notifications)
  65189. */
  65190. mask: number,
  65191. /**
  65192. * Defines the current scope used to restore the JS context
  65193. */
  65194. scope?: any);
  65195. }
  65196. /**
  65197. * Represent a list of observers registered to multiple Observables object.
  65198. */
  65199. export class MultiObserver<T> {
  65200. private _observers;
  65201. private _observables;
  65202. /**
  65203. * Release associated resources
  65204. */
  65205. dispose(): void;
  65206. /**
  65207. * Raise a callback when one of the observable will notify
  65208. * @param observables defines a list of observables to watch
  65209. * @param callback defines the callback to call on notification
  65210. * @param mask defines the mask used to filter notifications
  65211. * @param scope defines the current scope used to restore the JS context
  65212. * @returns the new MultiObserver
  65213. */
  65214. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65215. }
  65216. /**
  65217. * The Observable class is a simple implementation of the Observable pattern.
  65218. *
  65219. * 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.
  65220. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65221. * 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).
  65222. * 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.
  65223. */
  65224. export class Observable<T> {
  65225. private _observers;
  65226. private _eventState;
  65227. private _onObserverAdded;
  65228. /**
  65229. * Gets the list of observers
  65230. */
  65231. readonly observers: Array<Observer<T>>;
  65232. /**
  65233. * Creates a new observable
  65234. * @param onObserverAdded defines a callback to call when a new observer is added
  65235. */
  65236. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65237. /**
  65238. * Create a new Observer with the specified callback
  65239. * @param callback the callback that will be executed for that Observer
  65240. * @param mask the mask used to filter observers
  65241. * @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.
  65242. * @param scope optional scope for the callback to be called from
  65243. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65244. * @returns the new observer created for the callback
  65245. */
  65246. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65247. /**
  65248. * Create a new Observer with the specified callback and unregisters after the next notification
  65249. * @param callback the callback that will be executed for that Observer
  65250. * @returns the new observer created for the callback
  65251. */
  65252. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65253. /**
  65254. * Remove an Observer from the Observable object
  65255. * @param observer the instance of the Observer to remove
  65256. * @returns false if it doesn't belong to this Observable
  65257. */
  65258. remove(observer: Nullable<Observer<T>>): boolean;
  65259. /**
  65260. * Remove a callback from the Observable object
  65261. * @param callback the callback to remove
  65262. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65263. * @returns false if it doesn't belong to this Observable
  65264. */
  65265. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65266. private _deferUnregister;
  65267. private _remove;
  65268. /**
  65269. * Moves the observable to the top of the observer list making it get called first when notified
  65270. * @param observer the observer to move
  65271. */
  65272. makeObserverTopPriority(observer: Observer<T>): void;
  65273. /**
  65274. * Moves the observable to the bottom of the observer list making it get called last when notified
  65275. * @param observer the observer to move
  65276. */
  65277. makeObserverBottomPriority(observer: Observer<T>): void;
  65278. /**
  65279. * Notify all Observers by calling their respective callback with the given data
  65280. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65281. * @param eventData defines the data to send to all observers
  65282. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65283. * @param target defines the original target of the state
  65284. * @param currentTarget defines the current target of the state
  65285. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65286. */
  65287. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65288. /**
  65289. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65290. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65291. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65292. * and it is crucial that all callbacks will be executed.
  65293. * The order of the callbacks is kept, callbacks are not executed parallel.
  65294. *
  65295. * @param eventData The data to be sent to each callback
  65296. * @param mask is used to filter observers defaults to -1
  65297. * @param target defines the callback target (see EventState)
  65298. * @param currentTarget defines he current object in the bubbling phase
  65299. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65300. */
  65301. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65302. /**
  65303. * Notify a specific observer
  65304. * @param observer defines the observer to notify
  65305. * @param eventData defines the data to be sent to each callback
  65306. * @param mask is used to filter observers defaults to -1
  65307. */
  65308. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65309. /**
  65310. * Gets a boolean indicating if the observable has at least one observer
  65311. * @returns true is the Observable has at least one Observer registered
  65312. */
  65313. hasObservers(): boolean;
  65314. /**
  65315. * Clear the list of observers
  65316. */
  65317. clear(): void;
  65318. /**
  65319. * Clone the current observable
  65320. * @returns a new observable
  65321. */
  65322. clone(): Observable<T>;
  65323. /**
  65324. * Does this observable handles observer registered with a given mask
  65325. * @param mask defines the mask to be tested
  65326. * @return whether or not one observer registered with the given mask is handeled
  65327. **/
  65328. hasSpecificMask(mask?: number): boolean;
  65329. }
  65330. }
  65331. declare module BABYLON {
  65332. /**
  65333. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65334. * Babylon.js
  65335. */
  65336. export class DomManagement {
  65337. /**
  65338. * Checks if the window object exists
  65339. * @returns true if the window object exists
  65340. */
  65341. static IsWindowObjectExist(): boolean;
  65342. /**
  65343. * Extracts text content from a DOM element hierarchy
  65344. * @param element defines the root element
  65345. * @returns a string
  65346. */
  65347. static GetDOMTextContent(element: HTMLElement): string;
  65348. }
  65349. }
  65350. declare module BABYLON {
  65351. /**
  65352. * Logger used througouht the application to allow configuration of
  65353. * the log level required for the messages.
  65354. */
  65355. export class Logger {
  65356. /**
  65357. * No log
  65358. */
  65359. static readonly NoneLogLevel: number;
  65360. /**
  65361. * Only message logs
  65362. */
  65363. static readonly MessageLogLevel: number;
  65364. /**
  65365. * Only warning logs
  65366. */
  65367. static readonly WarningLogLevel: number;
  65368. /**
  65369. * Only error logs
  65370. */
  65371. static readonly ErrorLogLevel: number;
  65372. /**
  65373. * All logs
  65374. */
  65375. static readonly AllLogLevel: number;
  65376. private static _LogCache;
  65377. /**
  65378. * Gets a value indicating the number of loading errors
  65379. * @ignorenaming
  65380. */
  65381. static errorsCount: number;
  65382. /**
  65383. * Callback called when a new log is added
  65384. */
  65385. static OnNewCacheEntry: (entry: string) => void;
  65386. private static _AddLogEntry;
  65387. private static _FormatMessage;
  65388. private static _LogDisabled;
  65389. private static _LogEnabled;
  65390. private static _WarnDisabled;
  65391. private static _WarnEnabled;
  65392. private static _ErrorDisabled;
  65393. private static _ErrorEnabled;
  65394. /**
  65395. * Log a message to the console
  65396. */
  65397. static Log: (message: string) => void;
  65398. /**
  65399. * Write a warning message to the console
  65400. */
  65401. static Warn: (message: string) => void;
  65402. /**
  65403. * Write an error message to the console
  65404. */
  65405. static Error: (message: string) => void;
  65406. /**
  65407. * Gets current log cache (list of logs)
  65408. */
  65409. static readonly LogCache: string;
  65410. /**
  65411. * Clears the log cache
  65412. */
  65413. static ClearLogCache(): void;
  65414. /**
  65415. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65416. */
  65417. static LogLevels: number;
  65418. }
  65419. }
  65420. declare module BABYLON {
  65421. /** @hidden */
  65422. export class _TypeStore {
  65423. /** @hidden */
  65424. static RegisteredTypes: {
  65425. [key: string]: Object;
  65426. };
  65427. /** @hidden */
  65428. static GetClass(fqdn: string): any;
  65429. }
  65430. }
  65431. declare module BABYLON {
  65432. /**
  65433. * Class containing a set of static utilities functions for deep copy.
  65434. */
  65435. export class DeepCopier {
  65436. /**
  65437. * Tries to copy an object by duplicating every property
  65438. * @param source defines the source object
  65439. * @param destination defines the target object
  65440. * @param doNotCopyList defines a list of properties to avoid
  65441. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65442. */
  65443. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65444. }
  65445. }
  65446. declare module BABYLON {
  65447. /**
  65448. * Class containing a set of static utilities functions for precision date
  65449. */
  65450. export class PrecisionDate {
  65451. /**
  65452. * Gets either window.performance.now() if supported or Date.now() else
  65453. */
  65454. static readonly Now: number;
  65455. }
  65456. }
  65457. declare module BABYLON {
  65458. /** @hidden */
  65459. export class _DevTools {
  65460. static WarnImport(name: string): string;
  65461. }
  65462. }
  65463. declare module BABYLON {
  65464. /**
  65465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65466. */
  65467. export class WebRequest {
  65468. private _xhr;
  65469. /**
  65470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65471. * i.e. when loading files, where the server/service expects an Authorization header
  65472. */
  65473. static CustomRequestHeaders: {
  65474. [key: string]: string;
  65475. };
  65476. /**
  65477. * Add callback functions in this array to update all the requests before they get sent to the network
  65478. */
  65479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65480. private _injectCustomRequestHeaders;
  65481. /**
  65482. * Gets or sets a function to be called when loading progress changes
  65483. */
  65484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65485. /**
  65486. * Returns client's state
  65487. */
  65488. readonly readyState: number;
  65489. /**
  65490. * Returns client's status
  65491. */
  65492. readonly status: number;
  65493. /**
  65494. * Returns client's status as a text
  65495. */
  65496. readonly statusText: string;
  65497. /**
  65498. * Returns client's response
  65499. */
  65500. readonly response: any;
  65501. /**
  65502. * Returns client's response url
  65503. */
  65504. readonly responseURL: string;
  65505. /**
  65506. * Returns client's response as text
  65507. */
  65508. readonly responseText: string;
  65509. /**
  65510. * Gets or sets the expected response type
  65511. */
  65512. responseType: XMLHttpRequestResponseType;
  65513. /** @hidden */
  65514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65515. /** @hidden */
  65516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65517. /**
  65518. * Cancels any network activity
  65519. */
  65520. abort(): void;
  65521. /**
  65522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65523. * @param body defines an optional request body
  65524. */
  65525. send(body?: Document | BodyInit | null): void;
  65526. /**
  65527. * Sets the request method, request URL
  65528. * @param method defines the method to use (GET, POST, etc..)
  65529. * @param url defines the url to connect with
  65530. */
  65531. open(method: string, url: string): void;
  65532. }
  65533. }
  65534. declare module BABYLON {
  65535. /**
  65536. * File request interface
  65537. */
  65538. export interface IFileRequest {
  65539. /**
  65540. * Raised when the request is complete (success or error).
  65541. */
  65542. onCompleteObservable: Observable<IFileRequest>;
  65543. /**
  65544. * Aborts the request for a file.
  65545. */
  65546. abort: () => void;
  65547. }
  65548. }
  65549. declare module BABYLON {
  65550. /**
  65551. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65552. */
  65553. export class PerformanceMonitor {
  65554. private _enabled;
  65555. private _rollingFrameTime;
  65556. private _lastFrameTimeMs;
  65557. /**
  65558. * constructor
  65559. * @param frameSampleSize The number of samples required to saturate the sliding window
  65560. */
  65561. constructor(frameSampleSize?: number);
  65562. /**
  65563. * Samples current frame
  65564. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65565. */
  65566. sampleFrame(timeMs?: number): void;
  65567. /**
  65568. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65569. */
  65570. readonly averageFrameTime: number;
  65571. /**
  65572. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65573. */
  65574. readonly averageFrameTimeVariance: number;
  65575. /**
  65576. * Returns the frame time of the most recent frame
  65577. */
  65578. readonly instantaneousFrameTime: number;
  65579. /**
  65580. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65581. */
  65582. readonly averageFPS: number;
  65583. /**
  65584. * Returns the average framerate in frames per second using the most recent frame time
  65585. */
  65586. readonly instantaneousFPS: number;
  65587. /**
  65588. * Returns true if enough samples have been taken to completely fill the sliding window
  65589. */
  65590. readonly isSaturated: boolean;
  65591. /**
  65592. * Enables contributions to the sliding window sample set
  65593. */
  65594. enable(): void;
  65595. /**
  65596. * Disables contributions to the sliding window sample set
  65597. * Samples will not be interpolated over the disabled period
  65598. */
  65599. disable(): void;
  65600. /**
  65601. * Returns true if sampling is enabled
  65602. */
  65603. readonly isEnabled: boolean;
  65604. /**
  65605. * Resets performance monitor
  65606. */
  65607. reset(): void;
  65608. }
  65609. /**
  65610. * RollingAverage
  65611. *
  65612. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65613. */
  65614. export class RollingAverage {
  65615. /**
  65616. * Current average
  65617. */
  65618. average: number;
  65619. /**
  65620. * Current variance
  65621. */
  65622. variance: number;
  65623. protected _samples: Array<number>;
  65624. protected _sampleCount: number;
  65625. protected _pos: number;
  65626. protected _m2: number;
  65627. /**
  65628. * constructor
  65629. * @param length The number of samples required to saturate the sliding window
  65630. */
  65631. constructor(length: number);
  65632. /**
  65633. * Adds a sample to the sample set
  65634. * @param v The sample value
  65635. */
  65636. add(v: number): void;
  65637. /**
  65638. * Returns previously added values or null if outside of history or outside the sliding window domain
  65639. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65640. * @return Value previously recorded with add() or null if outside of range
  65641. */
  65642. history(i: number): number;
  65643. /**
  65644. * Returns true if enough samples have been taken to completely fill the sliding window
  65645. * @return true if sample-set saturated
  65646. */
  65647. isSaturated(): boolean;
  65648. /**
  65649. * Resets the rolling average (equivalent to 0 samples taken so far)
  65650. */
  65651. reset(): void;
  65652. /**
  65653. * Wraps a value around the sample range boundaries
  65654. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65655. * @return Wrapped position in sample range
  65656. */
  65657. protected _wrapPosition(i: number): number;
  65658. }
  65659. }
  65660. declare module BABYLON {
  65661. /**
  65662. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65663. * The underlying implementation relies on an associative array to ensure the best performances.
  65664. * The value can be anything including 'null' but except 'undefined'
  65665. */
  65666. export class StringDictionary<T> {
  65667. /**
  65668. * This will clear this dictionary and copy the content from the 'source' one.
  65669. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65670. * @param source the dictionary to take the content from and copy to this dictionary
  65671. */
  65672. copyFrom(source: StringDictionary<T>): void;
  65673. /**
  65674. * Get a value based from its key
  65675. * @param key the given key to get the matching value from
  65676. * @return the value if found, otherwise undefined is returned
  65677. */
  65678. get(key: string): T | undefined;
  65679. /**
  65680. * Get a value from its key or add it if it doesn't exist.
  65681. * This method will ensure you that a given key/data will be present in the dictionary.
  65682. * @param key the given key to get the matching value from
  65683. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65684. * The factory will only be invoked if there's no data for the given key.
  65685. * @return the value corresponding to the key.
  65686. */
  65687. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65688. /**
  65689. * Get a value from its key if present in the dictionary otherwise add it
  65690. * @param key the key to get the value from
  65691. * @param val if there's no such key/value pair in the dictionary add it with this value
  65692. * @return the value corresponding to the key
  65693. */
  65694. getOrAdd(key: string, val: T): T;
  65695. /**
  65696. * Check if there's a given key in the dictionary
  65697. * @param key the key to check for
  65698. * @return true if the key is present, false otherwise
  65699. */
  65700. contains(key: string): boolean;
  65701. /**
  65702. * Add a new key and its corresponding value
  65703. * @param key the key to add
  65704. * @param value the value corresponding to the key
  65705. * @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
  65706. */
  65707. add(key: string, value: T): boolean;
  65708. /**
  65709. * Update a specific value associated to a key
  65710. * @param key defines the key to use
  65711. * @param value defines the value to store
  65712. * @returns true if the value was updated (or false if the key was not found)
  65713. */
  65714. set(key: string, value: T): boolean;
  65715. /**
  65716. * Get the element of the given key and remove it from the dictionary
  65717. * @param key defines the key to search
  65718. * @returns the value associated with the key or null if not found
  65719. */
  65720. getAndRemove(key: string): Nullable<T>;
  65721. /**
  65722. * Remove a key/value from the dictionary.
  65723. * @param key the key to remove
  65724. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65725. */
  65726. remove(key: string): boolean;
  65727. /**
  65728. * Clear the whole content of the dictionary
  65729. */
  65730. clear(): void;
  65731. /**
  65732. * Gets the current count
  65733. */
  65734. readonly count: number;
  65735. /**
  65736. * Execute a callback on each key/val of the dictionary.
  65737. * Note that you can remove any element in this dictionary in the callback implementation
  65738. * @param callback the callback to execute on a given key/value pair
  65739. */
  65740. forEach(callback: (key: string, val: T) => void): void;
  65741. /**
  65742. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65743. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65744. * Note that you can remove any element in this dictionary in the callback implementation
  65745. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65746. * @returns the first item
  65747. */
  65748. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65749. private _count;
  65750. private _data;
  65751. }
  65752. }
  65753. declare module BABYLON {
  65754. /**
  65755. * Class used to store gfx data (like WebGLBuffer)
  65756. */
  65757. export class DataBuffer {
  65758. /**
  65759. * Gets or sets the number of objects referencing this buffer
  65760. */
  65761. references: number;
  65762. /** Gets or sets the size of the underlying buffer */
  65763. capacity: number;
  65764. /**
  65765. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65766. */
  65767. is32Bits: boolean;
  65768. /**
  65769. * Gets the underlying buffer
  65770. */
  65771. readonly underlyingResource: any;
  65772. }
  65773. }
  65774. declare module BABYLON {
  65775. /**
  65776. * Class used to store data that will be store in GPU memory
  65777. */
  65778. export class Buffer {
  65779. private _engine;
  65780. private _buffer;
  65781. /** @hidden */
  65782. _data: Nullable<DataArray>;
  65783. private _updatable;
  65784. private _instanced;
  65785. /**
  65786. * Gets the byte stride.
  65787. */
  65788. readonly byteStride: number;
  65789. /**
  65790. * Constructor
  65791. * @param engine the engine
  65792. * @param data the data to use for this buffer
  65793. * @param updatable whether the data is updatable
  65794. * @param stride the stride (optional)
  65795. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65796. * @param instanced whether the buffer is instanced (optional)
  65797. * @param useBytes set to true if the stride in in bytes (optional)
  65798. */
  65799. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65800. /**
  65801. * Create a new VertexBuffer based on the current buffer
  65802. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65803. * @param offset defines offset in the buffer (0 by default)
  65804. * @param size defines the size in floats of attributes (position is 3 for instance)
  65805. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65806. * @param instanced defines if the vertex buffer contains indexed data
  65807. * @param useBytes defines if the offset and stride are in bytes
  65808. * @returns the new vertex buffer
  65809. */
  65810. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65811. /**
  65812. * Gets a boolean indicating if the Buffer is updatable?
  65813. * @returns true if the buffer is updatable
  65814. */
  65815. isUpdatable(): boolean;
  65816. /**
  65817. * Gets current buffer's data
  65818. * @returns a DataArray or null
  65819. */
  65820. getData(): Nullable<DataArray>;
  65821. /**
  65822. * Gets underlying native buffer
  65823. * @returns underlying native buffer
  65824. */
  65825. getBuffer(): Nullable<DataBuffer>;
  65826. /**
  65827. * Gets the stride in float32 units (i.e. byte stride / 4).
  65828. * May not be an integer if the byte stride is not divisible by 4.
  65829. * DEPRECATED. Use byteStride instead.
  65830. * @returns the stride in float32 units
  65831. */
  65832. getStrideSize(): number;
  65833. /**
  65834. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65835. * @param data defines the data to store
  65836. */
  65837. create(data?: Nullable<DataArray>): void;
  65838. /** @hidden */
  65839. _rebuild(): void;
  65840. /**
  65841. * Update current buffer data
  65842. * @param data defines the data to store
  65843. */
  65844. update(data: DataArray): void;
  65845. /**
  65846. * Updates the data directly.
  65847. * @param data the new data
  65848. * @param offset the new offset
  65849. * @param vertexCount the vertex count (optional)
  65850. * @param useBytes set to true if the offset is in bytes
  65851. */
  65852. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65853. /**
  65854. * Release all resources
  65855. */
  65856. dispose(): void;
  65857. }
  65858. /**
  65859. * Specialized buffer used to store vertex data
  65860. */
  65861. export class VertexBuffer {
  65862. /** @hidden */
  65863. _buffer: Buffer;
  65864. private _kind;
  65865. private _size;
  65866. private _ownsBuffer;
  65867. private _instanced;
  65868. private _instanceDivisor;
  65869. /**
  65870. * The byte type.
  65871. */
  65872. static readonly BYTE: number;
  65873. /**
  65874. * The unsigned byte type.
  65875. */
  65876. static readonly UNSIGNED_BYTE: number;
  65877. /**
  65878. * The short type.
  65879. */
  65880. static readonly SHORT: number;
  65881. /**
  65882. * The unsigned short type.
  65883. */
  65884. static readonly UNSIGNED_SHORT: number;
  65885. /**
  65886. * The integer type.
  65887. */
  65888. static readonly INT: number;
  65889. /**
  65890. * The unsigned integer type.
  65891. */
  65892. static readonly UNSIGNED_INT: number;
  65893. /**
  65894. * The float type.
  65895. */
  65896. static readonly FLOAT: number;
  65897. /**
  65898. * Gets or sets the instance divisor when in instanced mode
  65899. */
  65900. instanceDivisor: number;
  65901. /**
  65902. * Gets the byte stride.
  65903. */
  65904. readonly byteStride: number;
  65905. /**
  65906. * Gets the byte offset.
  65907. */
  65908. readonly byteOffset: number;
  65909. /**
  65910. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65911. */
  65912. readonly normalized: boolean;
  65913. /**
  65914. * Gets the data type of each component in the array.
  65915. */
  65916. readonly type: number;
  65917. /**
  65918. * Constructor
  65919. * @param engine the engine
  65920. * @param data the data to use for this vertex buffer
  65921. * @param kind the vertex buffer kind
  65922. * @param updatable whether the data is updatable
  65923. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65924. * @param stride the stride (optional)
  65925. * @param instanced whether the buffer is instanced (optional)
  65926. * @param offset the offset of the data (optional)
  65927. * @param size the number of components (optional)
  65928. * @param type the type of the component (optional)
  65929. * @param normalized whether the data contains normalized data (optional)
  65930. * @param useBytes set to true if stride and offset are in bytes (optional)
  65931. */
  65932. 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);
  65933. /** @hidden */
  65934. _rebuild(): void;
  65935. /**
  65936. * Returns the kind of the VertexBuffer (string)
  65937. * @returns a string
  65938. */
  65939. getKind(): string;
  65940. /**
  65941. * Gets a boolean indicating if the VertexBuffer is updatable?
  65942. * @returns true if the buffer is updatable
  65943. */
  65944. isUpdatable(): boolean;
  65945. /**
  65946. * Gets current buffer's data
  65947. * @returns a DataArray or null
  65948. */
  65949. getData(): Nullable<DataArray>;
  65950. /**
  65951. * Gets underlying native buffer
  65952. * @returns underlying native buffer
  65953. */
  65954. getBuffer(): Nullable<DataBuffer>;
  65955. /**
  65956. * Gets the stride in float32 units (i.e. byte stride / 4).
  65957. * May not be an integer if the byte stride is not divisible by 4.
  65958. * DEPRECATED. Use byteStride instead.
  65959. * @returns the stride in float32 units
  65960. */
  65961. getStrideSize(): number;
  65962. /**
  65963. * Returns the offset as a multiple of the type byte length.
  65964. * DEPRECATED. Use byteOffset instead.
  65965. * @returns the offset in bytes
  65966. */
  65967. getOffset(): number;
  65968. /**
  65969. * Returns the number of components per vertex attribute (integer)
  65970. * @returns the size in float
  65971. */
  65972. getSize(): number;
  65973. /**
  65974. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65975. * @returns true if this buffer is instanced
  65976. */
  65977. getIsInstanced(): boolean;
  65978. /**
  65979. * Returns the instancing divisor, zero for non-instanced (integer).
  65980. * @returns a number
  65981. */
  65982. getInstanceDivisor(): number;
  65983. /**
  65984. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65985. * @param data defines the data to store
  65986. */
  65987. create(data?: DataArray): void;
  65988. /**
  65989. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65990. * This function will create a new buffer if the current one is not updatable
  65991. * @param data defines the data to store
  65992. */
  65993. update(data: DataArray): void;
  65994. /**
  65995. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65996. * Returns the directly updated WebGLBuffer.
  65997. * @param data the new data
  65998. * @param offset the new offset
  65999. * @param useBytes set to true if the offset is in bytes
  66000. */
  66001. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66002. /**
  66003. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66004. */
  66005. dispose(): void;
  66006. /**
  66007. * Enumerates each value of this vertex buffer as numbers.
  66008. * @param count the number of values to enumerate
  66009. * @param callback the callback function called for each value
  66010. */
  66011. forEach(count: number, callback: (value: number, index: number) => void): void;
  66012. /**
  66013. * Positions
  66014. */
  66015. static readonly PositionKind: string;
  66016. /**
  66017. * Normals
  66018. */
  66019. static readonly NormalKind: string;
  66020. /**
  66021. * Tangents
  66022. */
  66023. static readonly TangentKind: string;
  66024. /**
  66025. * Texture coordinates
  66026. */
  66027. static readonly UVKind: string;
  66028. /**
  66029. * Texture coordinates 2
  66030. */
  66031. static readonly UV2Kind: string;
  66032. /**
  66033. * Texture coordinates 3
  66034. */
  66035. static readonly UV3Kind: string;
  66036. /**
  66037. * Texture coordinates 4
  66038. */
  66039. static readonly UV4Kind: string;
  66040. /**
  66041. * Texture coordinates 5
  66042. */
  66043. static readonly UV5Kind: string;
  66044. /**
  66045. * Texture coordinates 6
  66046. */
  66047. static readonly UV6Kind: string;
  66048. /**
  66049. * Colors
  66050. */
  66051. static readonly ColorKind: string;
  66052. /**
  66053. * Matrix indices (for bones)
  66054. */
  66055. static readonly MatricesIndicesKind: string;
  66056. /**
  66057. * Matrix weights (for bones)
  66058. */
  66059. static readonly MatricesWeightsKind: string;
  66060. /**
  66061. * Additional matrix indices (for bones)
  66062. */
  66063. static readonly MatricesIndicesExtraKind: string;
  66064. /**
  66065. * Additional matrix weights (for bones)
  66066. */
  66067. static readonly MatricesWeightsExtraKind: string;
  66068. /**
  66069. * Deduces the stride given a kind.
  66070. * @param kind The kind string to deduce
  66071. * @returns The deduced stride
  66072. */
  66073. static DeduceStride(kind: string): number;
  66074. /**
  66075. * Gets the byte length of the given type.
  66076. * @param type the type
  66077. * @returns the number of bytes
  66078. */
  66079. static GetTypeByteLength(type: number): number;
  66080. /**
  66081. * Enumerates each value of the given parameters as numbers.
  66082. * @param data the data to enumerate
  66083. * @param byteOffset the byte offset of the data
  66084. * @param byteStride the byte stride of the data
  66085. * @param componentCount the number of components per element
  66086. * @param componentType the type of the component
  66087. * @param count the number of values to enumerate
  66088. * @param normalized whether the data is normalized
  66089. * @param callback the callback function called for each value
  66090. */
  66091. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66092. private static _GetFloatValue;
  66093. }
  66094. }
  66095. declare module BABYLON {
  66096. /**
  66097. * Scalar computation library
  66098. */
  66099. export class Scalar {
  66100. /**
  66101. * Two pi constants convenient for computation.
  66102. */
  66103. static TwoPi: number;
  66104. /**
  66105. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66106. * @param a number
  66107. * @param b number
  66108. * @param epsilon (default = 1.401298E-45)
  66109. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66110. */
  66111. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66112. /**
  66113. * Returns a string : the upper case translation of the number i to hexadecimal.
  66114. * @param i number
  66115. * @returns the upper case translation of the number i to hexadecimal.
  66116. */
  66117. static ToHex(i: number): string;
  66118. /**
  66119. * Returns -1 if value is negative and +1 is value is positive.
  66120. * @param value the value
  66121. * @returns the value itself if it's equal to zero.
  66122. */
  66123. static Sign(value: number): number;
  66124. /**
  66125. * Returns the value itself if it's between min and max.
  66126. * Returns min if the value is lower than min.
  66127. * Returns max if the value is greater than max.
  66128. * @param value the value to clmap
  66129. * @param min the min value to clamp to (default: 0)
  66130. * @param max the max value to clamp to (default: 1)
  66131. * @returns the clamped value
  66132. */
  66133. static Clamp(value: number, min?: number, max?: number): number;
  66134. /**
  66135. * the log2 of value.
  66136. * @param value the value to compute log2 of
  66137. * @returns the log2 of value.
  66138. */
  66139. static Log2(value: number): number;
  66140. /**
  66141. * Loops the value, so that it is never larger than length and never smaller than 0.
  66142. *
  66143. * This is similar to the modulo operator but it works with floating point numbers.
  66144. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66145. * With t = 5 and length = 2.5, the result would be 0.0.
  66146. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66147. * @param value the value
  66148. * @param length the length
  66149. * @returns the looped value
  66150. */
  66151. static Repeat(value: number, length: number): number;
  66152. /**
  66153. * Normalize the value between 0.0 and 1.0 using min and max values
  66154. * @param value value to normalize
  66155. * @param min max to normalize between
  66156. * @param max min to normalize between
  66157. * @returns the normalized value
  66158. */
  66159. static Normalize(value: number, min: number, max: number): number;
  66160. /**
  66161. * Denormalize the value from 0.0 and 1.0 using min and max values
  66162. * @param normalized value to denormalize
  66163. * @param min max to denormalize between
  66164. * @param max min to denormalize between
  66165. * @returns the denormalized value
  66166. */
  66167. static Denormalize(normalized: number, min: number, max: number): number;
  66168. /**
  66169. * Calculates the shortest difference between two given angles given in degrees.
  66170. * @param current current angle in degrees
  66171. * @param target target angle in degrees
  66172. * @returns the delta
  66173. */
  66174. static DeltaAngle(current: number, target: number): number;
  66175. /**
  66176. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66177. * @param tx value
  66178. * @param length length
  66179. * @returns The returned value will move back and forth between 0 and length
  66180. */
  66181. static PingPong(tx: number, length: number): number;
  66182. /**
  66183. * Interpolates between min and max with smoothing at the limits.
  66184. *
  66185. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66186. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66187. * @param from from
  66188. * @param to to
  66189. * @param tx value
  66190. * @returns the smooth stepped value
  66191. */
  66192. static SmoothStep(from: number, to: number, tx: number): number;
  66193. /**
  66194. * Moves a value current towards target.
  66195. *
  66196. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66197. * Negative values of maxDelta pushes the value away from target.
  66198. * @param current current value
  66199. * @param target target value
  66200. * @param maxDelta max distance to move
  66201. * @returns resulting value
  66202. */
  66203. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66204. /**
  66205. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66206. *
  66207. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66208. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66209. * @param current current value
  66210. * @param target target value
  66211. * @param maxDelta max distance to move
  66212. * @returns resulting angle
  66213. */
  66214. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66215. /**
  66216. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66217. * @param start start value
  66218. * @param end target value
  66219. * @param amount amount to lerp between
  66220. * @returns the lerped value
  66221. */
  66222. static Lerp(start: number, end: number, amount: number): number;
  66223. /**
  66224. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66225. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66226. * @param start start value
  66227. * @param end target value
  66228. * @param amount amount to lerp between
  66229. * @returns the lerped value
  66230. */
  66231. static LerpAngle(start: number, end: number, amount: number): number;
  66232. /**
  66233. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66234. * @param a start value
  66235. * @param b target value
  66236. * @param value value between a and b
  66237. * @returns the inverseLerp value
  66238. */
  66239. static InverseLerp(a: number, b: number, value: number): number;
  66240. /**
  66241. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66242. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66243. * @param value1 spline value
  66244. * @param tangent1 spline value
  66245. * @param value2 spline value
  66246. * @param tangent2 spline value
  66247. * @param amount input value
  66248. * @returns hermite result
  66249. */
  66250. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66251. /**
  66252. * Returns a random float number between and min and max values
  66253. * @param min min value of random
  66254. * @param max max value of random
  66255. * @returns random value
  66256. */
  66257. static RandomRange(min: number, max: number): number;
  66258. /**
  66259. * This function returns percentage of a number in a given range.
  66260. *
  66261. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66262. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66263. * @param number to convert to percentage
  66264. * @param min min range
  66265. * @param max max range
  66266. * @returns the percentage
  66267. */
  66268. static RangeToPercent(number: number, min: number, max: number): number;
  66269. /**
  66270. * This function returns number that corresponds to the percentage in a given range.
  66271. *
  66272. * PercentToRange(0.34,0,100) will return 34.
  66273. * @param percent to convert to number
  66274. * @param min min range
  66275. * @param max max range
  66276. * @returns the number
  66277. */
  66278. static PercentToRange(percent: number, min: number, max: number): number;
  66279. /**
  66280. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66281. * @param angle The angle to normalize in radian.
  66282. * @return The converted angle.
  66283. */
  66284. static NormalizeRadians(angle: number): number;
  66285. }
  66286. }
  66287. declare module BABYLON {
  66288. /**
  66289. * Constant used to convert a value to gamma space
  66290. * @ignorenaming
  66291. */
  66292. export const ToGammaSpace: number;
  66293. /**
  66294. * Constant used to convert a value to linear space
  66295. * @ignorenaming
  66296. */
  66297. export const ToLinearSpace = 2.2;
  66298. /**
  66299. * Constant used to define the minimal number value in Babylon.js
  66300. * @ignorenaming
  66301. */
  66302. let Epsilon: number;
  66303. }
  66304. declare module BABYLON {
  66305. /**
  66306. * Class used to represent a viewport on screen
  66307. */
  66308. export class Viewport {
  66309. /** viewport left coordinate */
  66310. x: number;
  66311. /** viewport top coordinate */
  66312. y: number;
  66313. /**viewport width */
  66314. width: number;
  66315. /** viewport height */
  66316. height: number;
  66317. /**
  66318. * Creates a Viewport object located at (x, y) and sized (width, height)
  66319. * @param x defines viewport left coordinate
  66320. * @param y defines viewport top coordinate
  66321. * @param width defines the viewport width
  66322. * @param height defines the viewport height
  66323. */
  66324. constructor(
  66325. /** viewport left coordinate */
  66326. x: number,
  66327. /** viewport top coordinate */
  66328. y: number,
  66329. /**viewport width */
  66330. width: number,
  66331. /** viewport height */
  66332. height: number);
  66333. /**
  66334. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66335. * @param renderWidth defines the rendering width
  66336. * @param renderHeight defines the rendering height
  66337. * @returns a new Viewport
  66338. */
  66339. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66340. /**
  66341. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66342. * @param renderWidth defines the rendering width
  66343. * @param renderHeight defines the rendering height
  66344. * @param ref defines the target viewport
  66345. * @returns the current viewport
  66346. */
  66347. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66348. /**
  66349. * Returns a new Viewport copied from the current one
  66350. * @returns a new Viewport
  66351. */
  66352. clone(): Viewport;
  66353. }
  66354. }
  66355. declare module BABYLON {
  66356. /**
  66357. * Class containing a set of static utilities functions for arrays.
  66358. */
  66359. export class ArrayTools {
  66360. /**
  66361. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66362. * @param size the number of element to construct and put in the array
  66363. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66364. * @returns a new array filled with new objects
  66365. */
  66366. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66367. }
  66368. }
  66369. declare module BABYLON {
  66370. /**
  66371. * @hidden
  66372. */
  66373. export interface IColor4Like {
  66374. r: float;
  66375. g: float;
  66376. b: float;
  66377. a: float;
  66378. }
  66379. /**
  66380. * @hidden
  66381. */
  66382. export interface IColor3Like {
  66383. r: float;
  66384. g: float;
  66385. b: float;
  66386. }
  66387. /**
  66388. * @hidden
  66389. */
  66390. export interface IVector4Like {
  66391. x: float;
  66392. y: float;
  66393. z: float;
  66394. w: float;
  66395. }
  66396. /**
  66397. * @hidden
  66398. */
  66399. export interface IVector3Like {
  66400. x: float;
  66401. y: float;
  66402. z: float;
  66403. }
  66404. /**
  66405. * @hidden
  66406. */
  66407. export interface IVector2Like {
  66408. x: float;
  66409. y: float;
  66410. }
  66411. /**
  66412. * @hidden
  66413. */
  66414. export interface IMatrixLike {
  66415. toArray(): DeepImmutable<Float32Array>;
  66416. updateFlag: int;
  66417. }
  66418. /**
  66419. * @hidden
  66420. */
  66421. export interface IViewportLike {
  66422. x: float;
  66423. y: float;
  66424. width: float;
  66425. height: float;
  66426. }
  66427. /**
  66428. * @hidden
  66429. */
  66430. export interface IPlaneLike {
  66431. normal: IVector3Like;
  66432. d: float;
  66433. normalize(): void;
  66434. }
  66435. }
  66436. declare module BABYLON {
  66437. /**
  66438. * Class representing a vector containing 2 coordinates
  66439. */
  66440. export class Vector2 {
  66441. /** defines the first coordinate */
  66442. x: number;
  66443. /** defines the second coordinate */
  66444. y: number;
  66445. /**
  66446. * Creates a new Vector2 from the given x and y coordinates
  66447. * @param x defines the first coordinate
  66448. * @param y defines the second coordinate
  66449. */
  66450. constructor(
  66451. /** defines the first coordinate */
  66452. x?: number,
  66453. /** defines the second coordinate */
  66454. y?: number);
  66455. /**
  66456. * Gets a string with the Vector2 coordinates
  66457. * @returns a string with the Vector2 coordinates
  66458. */
  66459. toString(): string;
  66460. /**
  66461. * Gets class name
  66462. * @returns the string "Vector2"
  66463. */
  66464. getClassName(): string;
  66465. /**
  66466. * Gets current vector hash code
  66467. * @returns the Vector2 hash code as a number
  66468. */
  66469. getHashCode(): number;
  66470. /**
  66471. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66472. * @param array defines the source array
  66473. * @param index defines the offset in source array
  66474. * @returns the current Vector2
  66475. */
  66476. toArray(array: FloatArray, index?: number): Vector2;
  66477. /**
  66478. * Copy the current vector to an array
  66479. * @returns a new array with 2 elements: the Vector2 coordinates.
  66480. */
  66481. asArray(): number[];
  66482. /**
  66483. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66484. * @param source defines the source Vector2
  66485. * @returns the current updated Vector2
  66486. */
  66487. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66488. /**
  66489. * Sets the Vector2 coordinates with the given floats
  66490. * @param x defines the first coordinate
  66491. * @param y defines the second coordinate
  66492. * @returns the current updated Vector2
  66493. */
  66494. copyFromFloats(x: number, y: number): Vector2;
  66495. /**
  66496. * Sets the Vector2 coordinates with the given floats
  66497. * @param x defines the first coordinate
  66498. * @param y defines the second coordinate
  66499. * @returns the current updated Vector2
  66500. */
  66501. set(x: number, y: number): Vector2;
  66502. /**
  66503. * Add another vector with the current one
  66504. * @param otherVector defines the other vector
  66505. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66506. */
  66507. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66508. /**
  66509. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66510. * @param otherVector defines the other vector
  66511. * @param result defines the target vector
  66512. * @returns the unmodified current Vector2
  66513. */
  66514. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66515. /**
  66516. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66517. * @param otherVector defines the other vector
  66518. * @returns the current updated Vector2
  66519. */
  66520. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66521. /**
  66522. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66523. * @param otherVector defines the other vector
  66524. * @returns a new Vector2
  66525. */
  66526. addVector3(otherVector: Vector3): Vector2;
  66527. /**
  66528. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66529. * @param otherVector defines the other vector
  66530. * @returns a new Vector2
  66531. */
  66532. subtract(otherVector: Vector2): Vector2;
  66533. /**
  66534. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66535. * @param otherVector defines the other vector
  66536. * @param result defines the target vector
  66537. * @returns the unmodified current Vector2
  66538. */
  66539. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66540. /**
  66541. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66542. * @param otherVector defines the other vector
  66543. * @returns the current updated Vector2
  66544. */
  66545. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66546. /**
  66547. * Multiplies in place the current Vector2 coordinates by the given ones
  66548. * @param otherVector defines the other vector
  66549. * @returns the current updated Vector2
  66550. */
  66551. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66552. /**
  66553. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66554. * @param otherVector defines the other vector
  66555. * @returns a new Vector2
  66556. */
  66557. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66558. /**
  66559. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66560. * @param otherVector defines the other vector
  66561. * @param result defines the target vector
  66562. * @returns the unmodified current Vector2
  66563. */
  66564. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66565. /**
  66566. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66567. * @param x defines the first coordinate
  66568. * @param y defines the second coordinate
  66569. * @returns a new Vector2
  66570. */
  66571. multiplyByFloats(x: number, y: number): Vector2;
  66572. /**
  66573. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66574. * @param otherVector defines the other vector
  66575. * @returns a new Vector2
  66576. */
  66577. divide(otherVector: Vector2): Vector2;
  66578. /**
  66579. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66580. * @param otherVector defines the other vector
  66581. * @param result defines the target vector
  66582. * @returns the unmodified current Vector2
  66583. */
  66584. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66585. /**
  66586. * Divides the current Vector2 coordinates by the given ones
  66587. * @param otherVector defines the other vector
  66588. * @returns the current updated Vector2
  66589. */
  66590. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66591. /**
  66592. * Gets a new Vector2 with current Vector2 negated coordinates
  66593. * @returns a new Vector2
  66594. */
  66595. negate(): Vector2;
  66596. /**
  66597. * Multiply the Vector2 coordinates by scale
  66598. * @param scale defines the scaling factor
  66599. * @returns the current updated Vector2
  66600. */
  66601. scaleInPlace(scale: number): Vector2;
  66602. /**
  66603. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66604. * @param scale defines the scaling factor
  66605. * @returns a new Vector2
  66606. */
  66607. scale(scale: number): Vector2;
  66608. /**
  66609. * Scale the current Vector2 values by a factor to a given Vector2
  66610. * @param scale defines the scale factor
  66611. * @param result defines the Vector2 object where to store the result
  66612. * @returns the unmodified current Vector2
  66613. */
  66614. scaleToRef(scale: number, result: Vector2): Vector2;
  66615. /**
  66616. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66617. * @param scale defines the scale factor
  66618. * @param result defines the Vector2 object where to store the result
  66619. * @returns the unmodified current Vector2
  66620. */
  66621. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66622. /**
  66623. * Gets a boolean if two vectors are equals
  66624. * @param otherVector defines the other vector
  66625. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66626. */
  66627. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66628. /**
  66629. * Gets a boolean if two vectors are equals (using an epsilon value)
  66630. * @param otherVector defines the other vector
  66631. * @param epsilon defines the minimal distance to consider equality
  66632. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66633. */
  66634. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66635. /**
  66636. * Gets a new Vector2 from current Vector2 floored values
  66637. * @returns a new Vector2
  66638. */
  66639. floor(): Vector2;
  66640. /**
  66641. * Gets a new Vector2 from current Vector2 floored values
  66642. * @returns a new Vector2
  66643. */
  66644. fract(): Vector2;
  66645. /**
  66646. * Gets the length of the vector
  66647. * @returns the vector length (float)
  66648. */
  66649. length(): number;
  66650. /**
  66651. * Gets the vector squared length
  66652. * @returns the vector squared length (float)
  66653. */
  66654. lengthSquared(): number;
  66655. /**
  66656. * Normalize the vector
  66657. * @returns the current updated Vector2
  66658. */
  66659. normalize(): Vector2;
  66660. /**
  66661. * Gets a new Vector2 copied from the Vector2
  66662. * @returns a new Vector2
  66663. */
  66664. clone(): Vector2;
  66665. /**
  66666. * Gets a new Vector2(0, 0)
  66667. * @returns a new Vector2
  66668. */
  66669. static Zero(): Vector2;
  66670. /**
  66671. * Gets a new Vector2(1, 1)
  66672. * @returns a new Vector2
  66673. */
  66674. static One(): Vector2;
  66675. /**
  66676. * Gets a new Vector2 set from the given index element of the given array
  66677. * @param array defines the data source
  66678. * @param offset defines the offset in the data source
  66679. * @returns a new Vector2
  66680. */
  66681. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66682. /**
  66683. * Sets "result" from the given index element of the given array
  66684. * @param array defines the data source
  66685. * @param offset defines the offset in the data source
  66686. * @param result defines the target vector
  66687. */
  66688. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66689. /**
  66690. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66691. * @param value1 defines 1st point of control
  66692. * @param value2 defines 2nd point of control
  66693. * @param value3 defines 3rd point of control
  66694. * @param value4 defines 4th point of control
  66695. * @param amount defines the interpolation factor
  66696. * @returns a new Vector2
  66697. */
  66698. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66699. /**
  66700. * 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".
  66701. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66702. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66703. * @param value defines the value to clamp
  66704. * @param min defines the lower limit
  66705. * @param max defines the upper limit
  66706. * @returns a new Vector2
  66707. */
  66708. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66709. /**
  66710. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66711. * @param value1 defines the 1st control point
  66712. * @param tangent1 defines the outgoing tangent
  66713. * @param value2 defines the 2nd control point
  66714. * @param tangent2 defines the incoming tangent
  66715. * @param amount defines the interpolation factor
  66716. * @returns a new Vector2
  66717. */
  66718. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66719. /**
  66720. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66721. * @param start defines the start vector
  66722. * @param end defines the end vector
  66723. * @param amount defines the interpolation factor
  66724. * @returns a new Vector2
  66725. */
  66726. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66727. /**
  66728. * Gets the dot product of the vector "left" and the vector "right"
  66729. * @param left defines first vector
  66730. * @param right defines second vector
  66731. * @returns the dot product (float)
  66732. */
  66733. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66734. /**
  66735. * Returns a new Vector2 equal to the normalized given vector
  66736. * @param vector defines the vector to normalize
  66737. * @returns a new Vector2
  66738. */
  66739. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66740. /**
  66741. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66742. * @param left defines 1st vector
  66743. * @param right defines 2nd vector
  66744. * @returns a new Vector2
  66745. */
  66746. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66747. /**
  66748. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66749. * @param left defines 1st vector
  66750. * @param right defines 2nd vector
  66751. * @returns a new Vector2
  66752. */
  66753. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66754. /**
  66755. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66756. * @param vector defines the vector to transform
  66757. * @param transformation defines the matrix to apply
  66758. * @returns a new Vector2
  66759. */
  66760. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66761. /**
  66762. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66763. * @param vector defines the vector to transform
  66764. * @param transformation defines the matrix to apply
  66765. * @param result defines the target vector
  66766. */
  66767. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66768. /**
  66769. * Determines if a given vector is included in a triangle
  66770. * @param p defines the vector to test
  66771. * @param p0 defines 1st triangle point
  66772. * @param p1 defines 2nd triangle point
  66773. * @param p2 defines 3rd triangle point
  66774. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66775. */
  66776. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66777. /**
  66778. * Gets the distance between the vectors "value1" and "value2"
  66779. * @param value1 defines first vector
  66780. * @param value2 defines second vector
  66781. * @returns the distance between vectors
  66782. */
  66783. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66784. /**
  66785. * Returns the squared distance between the vectors "value1" and "value2"
  66786. * @param value1 defines first vector
  66787. * @param value2 defines second vector
  66788. * @returns the squared distance between vectors
  66789. */
  66790. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66791. /**
  66792. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66793. * @param value1 defines first vector
  66794. * @param value2 defines second vector
  66795. * @returns a new Vector2
  66796. */
  66797. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66798. /**
  66799. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66800. * @param p defines the middle point
  66801. * @param segA defines one point of the segment
  66802. * @param segB defines the other point of the segment
  66803. * @returns the shortest distance
  66804. */
  66805. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66806. }
  66807. /**
  66808. * Classed used to store (x,y,z) vector representation
  66809. * A Vector3 is the main object used in 3D geometry
  66810. * It can represent etiher the coordinates of a point the space, either a direction
  66811. * Reminder: js uses a left handed forward facing system
  66812. */
  66813. export class Vector3 {
  66814. /**
  66815. * Defines the first coordinates (on X axis)
  66816. */
  66817. x: number;
  66818. /**
  66819. * Defines the second coordinates (on Y axis)
  66820. */
  66821. y: number;
  66822. /**
  66823. * Defines the third coordinates (on Z axis)
  66824. */
  66825. z: number;
  66826. private static _UpReadOnly;
  66827. private static _ZeroReadOnly;
  66828. /**
  66829. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66830. * @param x defines the first coordinates (on X axis)
  66831. * @param y defines the second coordinates (on Y axis)
  66832. * @param z defines the third coordinates (on Z axis)
  66833. */
  66834. constructor(
  66835. /**
  66836. * Defines the first coordinates (on X axis)
  66837. */
  66838. x?: number,
  66839. /**
  66840. * Defines the second coordinates (on Y axis)
  66841. */
  66842. y?: number,
  66843. /**
  66844. * Defines the third coordinates (on Z axis)
  66845. */
  66846. z?: number);
  66847. /**
  66848. * Creates a string representation of the Vector3
  66849. * @returns a string with the Vector3 coordinates.
  66850. */
  66851. toString(): string;
  66852. /**
  66853. * Gets the class name
  66854. * @returns the string "Vector3"
  66855. */
  66856. getClassName(): string;
  66857. /**
  66858. * Creates the Vector3 hash code
  66859. * @returns a number which tends to be unique between Vector3 instances
  66860. */
  66861. getHashCode(): number;
  66862. /**
  66863. * Creates an array containing three elements : the coordinates of the Vector3
  66864. * @returns a new array of numbers
  66865. */
  66866. asArray(): number[];
  66867. /**
  66868. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66869. * @param array defines the destination array
  66870. * @param index defines the offset in the destination array
  66871. * @returns the current Vector3
  66872. */
  66873. toArray(array: FloatArray, index?: number): Vector3;
  66874. /**
  66875. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66876. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66877. */
  66878. toQuaternion(): Quaternion;
  66879. /**
  66880. * Adds the given vector to the current Vector3
  66881. * @param otherVector defines the second operand
  66882. * @returns the current updated Vector3
  66883. */
  66884. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66885. /**
  66886. * Adds the given coordinates to the current Vector3
  66887. * @param x defines the x coordinate of the operand
  66888. * @param y defines the y coordinate of the operand
  66889. * @param z defines the z coordinate of the operand
  66890. * @returns the current updated Vector3
  66891. */
  66892. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66893. /**
  66894. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66895. * @param otherVector defines the second operand
  66896. * @returns the resulting Vector3
  66897. */
  66898. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66899. /**
  66900. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66901. * @param otherVector defines the second operand
  66902. * @param result defines the Vector3 object where to store the result
  66903. * @returns the current Vector3
  66904. */
  66905. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66906. /**
  66907. * Subtract the given vector from the current Vector3
  66908. * @param otherVector defines the second operand
  66909. * @returns the current updated Vector3
  66910. */
  66911. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66912. /**
  66913. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66914. * @param otherVector defines the second operand
  66915. * @returns the resulting Vector3
  66916. */
  66917. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66918. /**
  66919. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66920. * @param otherVector defines the second operand
  66921. * @param result defines the Vector3 object where to store the result
  66922. * @returns the current Vector3
  66923. */
  66924. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66925. /**
  66926. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66927. * @param x defines the x coordinate of the operand
  66928. * @param y defines the y coordinate of the operand
  66929. * @param z defines the z coordinate of the operand
  66930. * @returns the resulting Vector3
  66931. */
  66932. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66933. /**
  66934. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66935. * @param x defines the x coordinate of the operand
  66936. * @param y defines the y coordinate of the operand
  66937. * @param z defines the z coordinate of the operand
  66938. * @param result defines the Vector3 object where to store the result
  66939. * @returns the current Vector3
  66940. */
  66941. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66942. /**
  66943. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66944. * @returns a new Vector3
  66945. */
  66946. negate(): Vector3;
  66947. /**
  66948. * Multiplies the Vector3 coordinates by the float "scale"
  66949. * @param scale defines the multiplier factor
  66950. * @returns the current updated Vector3
  66951. */
  66952. scaleInPlace(scale: number): Vector3;
  66953. /**
  66954. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66955. * @param scale defines the multiplier factor
  66956. * @returns a new Vector3
  66957. */
  66958. scale(scale: number): Vector3;
  66959. /**
  66960. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66961. * @param scale defines the multiplier factor
  66962. * @param result defines the Vector3 object where to store the result
  66963. * @returns the current Vector3
  66964. */
  66965. scaleToRef(scale: number, result: Vector3): Vector3;
  66966. /**
  66967. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66968. * @param scale defines the scale factor
  66969. * @param result defines the Vector3 object where to store the result
  66970. * @returns the unmodified current Vector3
  66971. */
  66972. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66973. /**
  66974. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66975. * @param otherVector defines the second operand
  66976. * @returns true if both vectors are equals
  66977. */
  66978. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66979. /**
  66980. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66981. * @param otherVector defines the second operand
  66982. * @param epsilon defines the minimal distance to define values as equals
  66983. * @returns true if both vectors are distant less than epsilon
  66984. */
  66985. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66986. /**
  66987. * Returns true if the current Vector3 coordinates equals the given floats
  66988. * @param x defines the x coordinate of the operand
  66989. * @param y defines the y coordinate of the operand
  66990. * @param z defines the z coordinate of the operand
  66991. * @returns true if both vectors are equals
  66992. */
  66993. equalsToFloats(x: number, y: number, z: number): boolean;
  66994. /**
  66995. * Multiplies the current Vector3 coordinates by the given ones
  66996. * @param otherVector defines the second operand
  66997. * @returns the current updated Vector3
  66998. */
  66999. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67000. /**
  67001. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67002. * @param otherVector defines the second operand
  67003. * @returns the new Vector3
  67004. */
  67005. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67006. /**
  67007. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67008. * @param otherVector defines the second operand
  67009. * @param result defines the Vector3 object where to store the result
  67010. * @returns the current Vector3
  67011. */
  67012. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67013. /**
  67014. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67015. * @param x defines the x coordinate of the operand
  67016. * @param y defines the y coordinate of the operand
  67017. * @param z defines the z coordinate of the operand
  67018. * @returns the new Vector3
  67019. */
  67020. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67021. /**
  67022. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67023. * @param otherVector defines the second operand
  67024. * @returns the new Vector3
  67025. */
  67026. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67027. /**
  67028. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67029. * @param otherVector defines the second operand
  67030. * @param result defines the Vector3 object where to store the result
  67031. * @returns the current Vector3
  67032. */
  67033. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67034. /**
  67035. * Divides the current Vector3 coordinates by the given ones.
  67036. * @param otherVector defines the second operand
  67037. * @returns the current updated Vector3
  67038. */
  67039. divideInPlace(otherVector: Vector3): Vector3;
  67040. /**
  67041. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67042. * @param other defines the second operand
  67043. * @returns the current updated Vector3
  67044. */
  67045. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67046. /**
  67047. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67048. * @param other defines the second operand
  67049. * @returns the current updated Vector3
  67050. */
  67051. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67052. /**
  67053. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67054. * @param x defines the x coordinate of the operand
  67055. * @param y defines the y coordinate of the operand
  67056. * @param z defines the z coordinate of the operand
  67057. * @returns the current updated Vector3
  67058. */
  67059. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67060. /**
  67061. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67062. * @param x defines the x coordinate of the operand
  67063. * @param y defines the y coordinate of the operand
  67064. * @param z defines the z coordinate of the operand
  67065. * @returns the current updated Vector3
  67066. */
  67067. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67068. /**
  67069. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67070. * Check if is non uniform within a certain amount of decimal places to account for this
  67071. * @param epsilon the amount the values can differ
  67072. * @returns if the the vector is non uniform to a certain number of decimal places
  67073. */
  67074. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67075. /**
  67076. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67077. */
  67078. readonly isNonUniform: boolean;
  67079. /**
  67080. * Gets a new Vector3 from current Vector3 floored values
  67081. * @returns a new Vector3
  67082. */
  67083. floor(): Vector3;
  67084. /**
  67085. * Gets a new Vector3 from current Vector3 floored values
  67086. * @returns a new Vector3
  67087. */
  67088. fract(): Vector3;
  67089. /**
  67090. * Gets the length of the Vector3
  67091. * @returns the length of the Vector3
  67092. */
  67093. length(): number;
  67094. /**
  67095. * Gets the squared length of the Vector3
  67096. * @returns squared length of the Vector3
  67097. */
  67098. lengthSquared(): number;
  67099. /**
  67100. * Normalize the current Vector3.
  67101. * Please note that this is an in place operation.
  67102. * @returns the current updated Vector3
  67103. */
  67104. normalize(): Vector3;
  67105. /**
  67106. * Reorders the x y z properties of the vector in place
  67107. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67108. * @returns the current updated vector
  67109. */
  67110. reorderInPlace(order: string): this;
  67111. /**
  67112. * Rotates the vector around 0,0,0 by a quaternion
  67113. * @param quaternion the rotation quaternion
  67114. * @param result vector to store the result
  67115. * @returns the resulting vector
  67116. */
  67117. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67118. /**
  67119. * Rotates a vector around a given point
  67120. * @param quaternion the rotation quaternion
  67121. * @param point the point to rotate around
  67122. * @param result vector to store the result
  67123. * @returns the resulting vector
  67124. */
  67125. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67126. /**
  67127. * Normalize the current Vector3 with the given input length.
  67128. * Please note that this is an in place operation.
  67129. * @param len the length of the vector
  67130. * @returns the current updated Vector3
  67131. */
  67132. normalizeFromLength(len: number): Vector3;
  67133. /**
  67134. * Normalize the current Vector3 to a new vector
  67135. * @returns the new Vector3
  67136. */
  67137. normalizeToNew(): Vector3;
  67138. /**
  67139. * Normalize the current Vector3 to the reference
  67140. * @param reference define the Vector3 to update
  67141. * @returns the updated Vector3
  67142. */
  67143. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67144. /**
  67145. * Creates a new Vector3 copied from the current Vector3
  67146. * @returns the new Vector3
  67147. */
  67148. clone(): Vector3;
  67149. /**
  67150. * Copies the given vector coordinates to the current Vector3 ones
  67151. * @param source defines the source Vector3
  67152. * @returns the current updated Vector3
  67153. */
  67154. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67155. /**
  67156. * Copies the given floats to the current Vector3 coordinates
  67157. * @param x defines the x coordinate of the operand
  67158. * @param y defines the y coordinate of the operand
  67159. * @param z defines the z coordinate of the operand
  67160. * @returns the current updated Vector3
  67161. */
  67162. copyFromFloats(x: number, y: number, z: number): Vector3;
  67163. /**
  67164. * Copies the given floats to the current Vector3 coordinates
  67165. * @param x defines the x coordinate of the operand
  67166. * @param y defines the y coordinate of the operand
  67167. * @param z defines the z coordinate of the operand
  67168. * @returns the current updated Vector3
  67169. */
  67170. set(x: number, y: number, z: number): Vector3;
  67171. /**
  67172. * Copies the given float to the current Vector3 coordinates
  67173. * @param v defines the x, y and z coordinates of the operand
  67174. * @returns the current updated Vector3
  67175. */
  67176. setAll(v: number): Vector3;
  67177. /**
  67178. * Get the clip factor between two vectors
  67179. * @param vector0 defines the first operand
  67180. * @param vector1 defines the second operand
  67181. * @param axis defines the axis to use
  67182. * @param size defines the size along the axis
  67183. * @returns the clip factor
  67184. */
  67185. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67186. /**
  67187. * Get angle between two vectors
  67188. * @param vector0 angle between vector0 and vector1
  67189. * @param vector1 angle between vector0 and vector1
  67190. * @param normal direction of the normal
  67191. * @return the angle between vector0 and vector1
  67192. */
  67193. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67194. /**
  67195. * Returns a new Vector3 set from the index "offset" of the given array
  67196. * @param array defines the source array
  67197. * @param offset defines the offset in the source array
  67198. * @returns the new Vector3
  67199. */
  67200. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67201. /**
  67202. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67203. * This function is deprecated. Use FromArray instead
  67204. * @param array defines the source array
  67205. * @param offset defines the offset in the source array
  67206. * @returns the new Vector3
  67207. */
  67208. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67209. /**
  67210. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67211. * @param array defines the source array
  67212. * @param offset defines the offset in the source array
  67213. * @param result defines the Vector3 where to store the result
  67214. */
  67215. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67216. /**
  67217. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67218. * This function is deprecated. Use FromArrayToRef instead.
  67219. * @param array defines the source array
  67220. * @param offset defines the offset in the source array
  67221. * @param result defines the Vector3 where to store the result
  67222. */
  67223. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67224. /**
  67225. * Sets the given vector "result" with the given floats.
  67226. * @param x defines the x coordinate of the source
  67227. * @param y defines the y coordinate of the source
  67228. * @param z defines the z coordinate of the source
  67229. * @param result defines the Vector3 where to store the result
  67230. */
  67231. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67232. /**
  67233. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67234. * @returns a new empty Vector3
  67235. */
  67236. static Zero(): Vector3;
  67237. /**
  67238. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67239. * @returns a new unit Vector3
  67240. */
  67241. static One(): Vector3;
  67242. /**
  67243. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67244. * @returns a new up Vector3
  67245. */
  67246. static Up(): Vector3;
  67247. /**
  67248. * Gets a up Vector3 that must not be updated
  67249. */
  67250. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67251. /**
  67252. * Gets a zero Vector3 that must not be updated
  67253. */
  67254. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67255. /**
  67256. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67257. * @returns a new down Vector3
  67258. */
  67259. static Down(): Vector3;
  67260. /**
  67261. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67262. * @returns a new forward Vector3
  67263. */
  67264. static Forward(): Vector3;
  67265. /**
  67266. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67267. * @returns a new forward Vector3
  67268. */
  67269. static Backward(): Vector3;
  67270. /**
  67271. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67272. * @returns a new right Vector3
  67273. */
  67274. static Right(): Vector3;
  67275. /**
  67276. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67277. * @returns a new left Vector3
  67278. */
  67279. static Left(): Vector3;
  67280. /**
  67281. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67282. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67283. * @param vector defines the Vector3 to transform
  67284. * @param transformation defines the transformation matrix
  67285. * @returns the transformed Vector3
  67286. */
  67287. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67288. /**
  67289. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67290. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67291. * @param vector defines the Vector3 to transform
  67292. * @param transformation defines the transformation matrix
  67293. * @param result defines the Vector3 where to store the result
  67294. */
  67295. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67296. /**
  67297. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67298. * This method computes tranformed coordinates only, not transformed direction vectors
  67299. * @param x define the x coordinate of the source vector
  67300. * @param y define the y coordinate of the source vector
  67301. * @param z define the z coordinate of the source vector
  67302. * @param transformation defines the transformation matrix
  67303. * @param result defines the Vector3 where to store the result
  67304. */
  67305. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67306. /**
  67307. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67308. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67309. * @param vector defines the Vector3 to transform
  67310. * @param transformation defines the transformation matrix
  67311. * @returns the new Vector3
  67312. */
  67313. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67314. /**
  67315. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67316. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67317. * @param vector defines the Vector3 to transform
  67318. * @param transformation defines the transformation matrix
  67319. * @param result defines the Vector3 where to store the result
  67320. */
  67321. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67322. /**
  67323. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67324. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67325. * @param x define the x coordinate of the source vector
  67326. * @param y define the y coordinate of the source vector
  67327. * @param z define the z coordinate of the source vector
  67328. * @param transformation defines the transformation matrix
  67329. * @param result defines the Vector3 where to store the result
  67330. */
  67331. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67332. /**
  67333. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67334. * @param value1 defines the first control point
  67335. * @param value2 defines the second control point
  67336. * @param value3 defines the third control point
  67337. * @param value4 defines the fourth control point
  67338. * @param amount defines the amount on the spline to use
  67339. * @returns the new Vector3
  67340. */
  67341. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67342. /**
  67343. * 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"
  67344. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67345. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67346. * @param value defines the current value
  67347. * @param min defines the lower range value
  67348. * @param max defines the upper range value
  67349. * @returns the new Vector3
  67350. */
  67351. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67352. /**
  67353. * 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"
  67354. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67355. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67356. * @param value defines the current value
  67357. * @param min defines the lower range value
  67358. * @param max defines the upper range value
  67359. * @param result defines the Vector3 where to store the result
  67360. */
  67361. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67362. /**
  67363. * Checks if a given vector is inside a specific range
  67364. * @param v defines the vector to test
  67365. * @param min defines the minimum range
  67366. * @param max defines the maximum range
  67367. */
  67368. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67369. /**
  67370. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67371. * @param value1 defines the first control point
  67372. * @param tangent1 defines the first tangent vector
  67373. * @param value2 defines the second control point
  67374. * @param tangent2 defines the second tangent vector
  67375. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67376. * @returns the new Vector3
  67377. */
  67378. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67379. /**
  67380. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67381. * @param start defines the start value
  67382. * @param end defines the end value
  67383. * @param amount max defines amount between both (between 0 and 1)
  67384. * @returns the new Vector3
  67385. */
  67386. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67387. /**
  67388. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67389. * @param start defines the start value
  67390. * @param end defines the end value
  67391. * @param amount max defines amount between both (between 0 and 1)
  67392. * @param result defines the Vector3 where to store the result
  67393. */
  67394. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67395. /**
  67396. * Returns the dot product (float) between the vectors "left" and "right"
  67397. * @param left defines the left operand
  67398. * @param right defines the right operand
  67399. * @returns the dot product
  67400. */
  67401. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67402. /**
  67403. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67404. * The cross product is then orthogonal to both "left" and "right"
  67405. * @param left defines the left operand
  67406. * @param right defines the right operand
  67407. * @returns the cross product
  67408. */
  67409. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67410. /**
  67411. * Sets the given vector "result" with the cross product of "left" and "right"
  67412. * The cross product is then orthogonal to both "left" and "right"
  67413. * @param left defines the left operand
  67414. * @param right defines the right operand
  67415. * @param result defines the Vector3 where to store the result
  67416. */
  67417. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67418. /**
  67419. * Returns a new Vector3 as the normalization of the given vector
  67420. * @param vector defines the Vector3 to normalize
  67421. * @returns the new Vector3
  67422. */
  67423. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67424. /**
  67425. * Sets the given vector "result" with the normalization of the given first vector
  67426. * @param vector defines the Vector3 to normalize
  67427. * @param result defines the Vector3 where to store the result
  67428. */
  67429. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67430. /**
  67431. * Project a Vector3 onto screen space
  67432. * @param vector defines the Vector3 to project
  67433. * @param world defines the world matrix to use
  67434. * @param transform defines the transform (view x projection) matrix to use
  67435. * @param viewport defines the screen viewport to use
  67436. * @returns the new Vector3
  67437. */
  67438. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67439. /** @hidden */
  67440. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67441. /**
  67442. * Unproject from screen space to object space
  67443. * @param source defines the screen space Vector3 to use
  67444. * @param viewportWidth defines the current width of the viewport
  67445. * @param viewportHeight defines the current height of the viewport
  67446. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67447. * @param transform defines the transform (view x projection) matrix to use
  67448. * @returns the new Vector3
  67449. */
  67450. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67451. /**
  67452. * Unproject from screen space to object space
  67453. * @param source defines the screen space Vector3 to use
  67454. * @param viewportWidth defines the current width of the viewport
  67455. * @param viewportHeight defines the current height of the viewport
  67456. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67457. * @param view defines the view matrix to use
  67458. * @param projection defines the projection matrix to use
  67459. * @returns the new Vector3
  67460. */
  67461. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67462. /**
  67463. * Unproject from screen space to object space
  67464. * @param source defines the screen space Vector3 to use
  67465. * @param viewportWidth defines the current width of the viewport
  67466. * @param viewportHeight defines the current height of the viewport
  67467. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67468. * @param view defines the view matrix to use
  67469. * @param projection defines the projection matrix to use
  67470. * @param result defines the Vector3 where to store the result
  67471. */
  67472. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67473. /**
  67474. * Unproject from screen space to object space
  67475. * @param sourceX defines the screen space x coordinate to use
  67476. * @param sourceY defines the screen space y coordinate to use
  67477. * @param sourceZ defines the screen space z coordinate to use
  67478. * @param viewportWidth defines the current width of the viewport
  67479. * @param viewportHeight defines the current height of the viewport
  67480. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67481. * @param view defines the view matrix to use
  67482. * @param projection defines the projection matrix to use
  67483. * @param result defines the Vector3 where to store the result
  67484. */
  67485. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67486. /**
  67487. * Gets the minimal coordinate values between two Vector3
  67488. * @param left defines the first operand
  67489. * @param right defines the second operand
  67490. * @returns the new Vector3
  67491. */
  67492. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67493. /**
  67494. * Gets the maximal coordinate values between two Vector3
  67495. * @param left defines the first operand
  67496. * @param right defines the second operand
  67497. * @returns the new Vector3
  67498. */
  67499. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67500. /**
  67501. * Returns the distance between the vectors "value1" and "value2"
  67502. * @param value1 defines the first operand
  67503. * @param value2 defines the second operand
  67504. * @returns the distance
  67505. */
  67506. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67507. /**
  67508. * Returns the squared distance between the vectors "value1" and "value2"
  67509. * @param value1 defines the first operand
  67510. * @param value2 defines the second operand
  67511. * @returns the squared distance
  67512. */
  67513. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67514. /**
  67515. * Returns a new Vector3 located at the center between "value1" and "value2"
  67516. * @param value1 defines the first operand
  67517. * @param value2 defines the second operand
  67518. * @returns the new Vector3
  67519. */
  67520. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67521. /**
  67522. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67523. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67524. * to something in order to rotate it from its local system to the given target system
  67525. * Note: axis1, axis2 and axis3 are normalized during this operation
  67526. * @param axis1 defines the first axis
  67527. * @param axis2 defines the second axis
  67528. * @param axis3 defines the third axis
  67529. * @returns a new Vector3
  67530. */
  67531. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67532. /**
  67533. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67534. * @param axis1 defines the first axis
  67535. * @param axis2 defines the second axis
  67536. * @param axis3 defines the third axis
  67537. * @param ref defines the Vector3 where to store the result
  67538. */
  67539. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67540. }
  67541. /**
  67542. * Vector4 class created for EulerAngle class conversion to Quaternion
  67543. */
  67544. export class Vector4 {
  67545. /** x value of the vector */
  67546. x: number;
  67547. /** y value of the vector */
  67548. y: number;
  67549. /** z value of the vector */
  67550. z: number;
  67551. /** w value of the vector */
  67552. w: number;
  67553. /**
  67554. * Creates a Vector4 object from the given floats.
  67555. * @param x x value of the vector
  67556. * @param y y value of the vector
  67557. * @param z z value of the vector
  67558. * @param w w value of the vector
  67559. */
  67560. constructor(
  67561. /** x value of the vector */
  67562. x: number,
  67563. /** y value of the vector */
  67564. y: number,
  67565. /** z value of the vector */
  67566. z: number,
  67567. /** w value of the vector */
  67568. w: number);
  67569. /**
  67570. * Returns the string with the Vector4 coordinates.
  67571. * @returns a string containing all the vector values
  67572. */
  67573. toString(): string;
  67574. /**
  67575. * Returns the string "Vector4".
  67576. * @returns "Vector4"
  67577. */
  67578. getClassName(): string;
  67579. /**
  67580. * Returns the Vector4 hash code.
  67581. * @returns a unique hash code
  67582. */
  67583. getHashCode(): number;
  67584. /**
  67585. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67586. * @returns the resulting array
  67587. */
  67588. asArray(): number[];
  67589. /**
  67590. * Populates the given array from the given index with the Vector4 coordinates.
  67591. * @param array array to populate
  67592. * @param index index of the array to start at (default: 0)
  67593. * @returns the Vector4.
  67594. */
  67595. toArray(array: FloatArray, index?: number): Vector4;
  67596. /**
  67597. * Adds the given vector to the current Vector4.
  67598. * @param otherVector the vector to add
  67599. * @returns the updated Vector4.
  67600. */
  67601. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67602. /**
  67603. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67604. * @param otherVector the vector to add
  67605. * @returns the resulting vector
  67606. */
  67607. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67608. /**
  67609. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67610. * @param otherVector the vector to add
  67611. * @param result the vector to store the result
  67612. * @returns the current Vector4.
  67613. */
  67614. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67615. /**
  67616. * Subtract in place the given vector from the current Vector4.
  67617. * @param otherVector the vector to subtract
  67618. * @returns the updated Vector4.
  67619. */
  67620. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67621. /**
  67622. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67623. * @param otherVector the vector to add
  67624. * @returns the new vector with the result
  67625. */
  67626. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67627. /**
  67628. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67629. * @param otherVector the vector to subtract
  67630. * @param result the vector to store the result
  67631. * @returns the current Vector4.
  67632. */
  67633. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67634. /**
  67635. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67636. */
  67637. /**
  67638. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67639. * @param x value to subtract
  67640. * @param y value to subtract
  67641. * @param z value to subtract
  67642. * @param w value to subtract
  67643. * @returns new vector containing the result
  67644. */
  67645. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67646. /**
  67647. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67648. * @param x value to subtract
  67649. * @param y value to subtract
  67650. * @param z value to subtract
  67651. * @param w value to subtract
  67652. * @param result the vector to store the result in
  67653. * @returns the current Vector4.
  67654. */
  67655. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67656. /**
  67657. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67658. * @returns a new vector with the negated values
  67659. */
  67660. negate(): Vector4;
  67661. /**
  67662. * Multiplies the current Vector4 coordinates by scale (float).
  67663. * @param scale the number to scale with
  67664. * @returns the updated Vector4.
  67665. */
  67666. scaleInPlace(scale: number): Vector4;
  67667. /**
  67668. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67669. * @param scale the number to scale with
  67670. * @returns a new vector with the result
  67671. */
  67672. scale(scale: number): Vector4;
  67673. /**
  67674. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67675. * @param scale the number to scale with
  67676. * @param result a vector to store the result in
  67677. * @returns the current Vector4.
  67678. */
  67679. scaleToRef(scale: number, result: Vector4): Vector4;
  67680. /**
  67681. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67682. * @param scale defines the scale factor
  67683. * @param result defines the Vector4 object where to store the result
  67684. * @returns the unmodified current Vector4
  67685. */
  67686. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67687. /**
  67688. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67689. * @param otherVector the vector to compare against
  67690. * @returns true if they are equal
  67691. */
  67692. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67693. /**
  67694. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67695. * @param otherVector vector to compare against
  67696. * @param epsilon (Default: very small number)
  67697. * @returns true if they are equal
  67698. */
  67699. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67700. /**
  67701. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67702. * @param x x value to compare against
  67703. * @param y y value to compare against
  67704. * @param z z value to compare against
  67705. * @param w w value to compare against
  67706. * @returns true if equal
  67707. */
  67708. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67709. /**
  67710. * Multiplies in place the current Vector4 by the given one.
  67711. * @param otherVector vector to multiple with
  67712. * @returns the updated Vector4.
  67713. */
  67714. multiplyInPlace(otherVector: Vector4): Vector4;
  67715. /**
  67716. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67717. * @param otherVector vector to multiple with
  67718. * @returns resulting new vector
  67719. */
  67720. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67721. /**
  67722. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67723. * @param otherVector vector to multiple with
  67724. * @param result vector to store the result
  67725. * @returns the current Vector4.
  67726. */
  67727. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67728. /**
  67729. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67730. * @param x x value multiply with
  67731. * @param y y value multiply with
  67732. * @param z z value multiply with
  67733. * @param w w value multiply with
  67734. * @returns resulting new vector
  67735. */
  67736. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67737. /**
  67738. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67739. * @param otherVector vector to devide with
  67740. * @returns resulting new vector
  67741. */
  67742. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67743. /**
  67744. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67745. * @param otherVector vector to devide with
  67746. * @param result vector to store the result
  67747. * @returns the current Vector4.
  67748. */
  67749. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67750. /**
  67751. * Divides the current Vector3 coordinates by the given ones.
  67752. * @param otherVector vector to devide with
  67753. * @returns the updated Vector3.
  67754. */
  67755. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67756. /**
  67757. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67758. * @param other defines the second operand
  67759. * @returns the current updated Vector4
  67760. */
  67761. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67762. /**
  67763. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67764. * @param other defines the second operand
  67765. * @returns the current updated Vector4
  67766. */
  67767. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67768. /**
  67769. * Gets a new Vector4 from current Vector4 floored values
  67770. * @returns a new Vector4
  67771. */
  67772. floor(): Vector4;
  67773. /**
  67774. * Gets a new Vector4 from current Vector3 floored values
  67775. * @returns a new Vector4
  67776. */
  67777. fract(): Vector4;
  67778. /**
  67779. * Returns the Vector4 length (float).
  67780. * @returns the length
  67781. */
  67782. length(): number;
  67783. /**
  67784. * Returns the Vector4 squared length (float).
  67785. * @returns the length squared
  67786. */
  67787. lengthSquared(): number;
  67788. /**
  67789. * Normalizes in place the Vector4.
  67790. * @returns the updated Vector4.
  67791. */
  67792. normalize(): Vector4;
  67793. /**
  67794. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67795. * @returns this converted to a new vector3
  67796. */
  67797. toVector3(): Vector3;
  67798. /**
  67799. * Returns a new Vector4 copied from the current one.
  67800. * @returns the new cloned vector
  67801. */
  67802. clone(): Vector4;
  67803. /**
  67804. * Updates the current Vector4 with the given one coordinates.
  67805. * @param source the source vector to copy from
  67806. * @returns the updated Vector4.
  67807. */
  67808. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67809. /**
  67810. * Updates the current Vector4 coordinates with the given floats.
  67811. * @param x float to copy from
  67812. * @param y float to copy from
  67813. * @param z float to copy from
  67814. * @param w float to copy from
  67815. * @returns the updated Vector4.
  67816. */
  67817. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67818. /**
  67819. * Updates the current Vector4 coordinates with the given floats.
  67820. * @param x float to set from
  67821. * @param y float to set from
  67822. * @param z float to set from
  67823. * @param w float to set from
  67824. * @returns the updated Vector4.
  67825. */
  67826. set(x: number, y: number, z: number, w: number): Vector4;
  67827. /**
  67828. * Copies the given float to the current Vector3 coordinates
  67829. * @param v defines the x, y, z and w coordinates of the operand
  67830. * @returns the current updated Vector3
  67831. */
  67832. setAll(v: number): Vector4;
  67833. /**
  67834. * Returns a new Vector4 set from the starting index of the given array.
  67835. * @param array the array to pull values from
  67836. * @param offset the offset into the array to start at
  67837. * @returns the new vector
  67838. */
  67839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67840. /**
  67841. * Updates the given vector "result" from the starting index of the given array.
  67842. * @param array the array to pull values from
  67843. * @param offset the offset into the array to start at
  67844. * @param result the vector to store the result in
  67845. */
  67846. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67847. /**
  67848. * Updates the given vector "result" from the starting index of the given Float32Array.
  67849. * @param array the array to pull values from
  67850. * @param offset the offset into the array to start at
  67851. * @param result the vector to store the result in
  67852. */
  67853. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67854. /**
  67855. * Updates the given vector "result" coordinates from the given floats.
  67856. * @param x float to set from
  67857. * @param y float to set from
  67858. * @param z float to set from
  67859. * @param w float to set from
  67860. * @param result the vector to the floats in
  67861. */
  67862. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67863. /**
  67864. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67865. * @returns the new vector
  67866. */
  67867. static Zero(): Vector4;
  67868. /**
  67869. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67870. * @returns the new vector
  67871. */
  67872. static One(): Vector4;
  67873. /**
  67874. * Returns a new normalized Vector4 from the given one.
  67875. * @param vector the vector to normalize
  67876. * @returns the vector
  67877. */
  67878. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67879. /**
  67880. * Updates the given vector "result" from the normalization of the given one.
  67881. * @param vector the vector to normalize
  67882. * @param result the vector to store the result in
  67883. */
  67884. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67885. /**
  67886. * Returns a vector with the minimum values from the left and right vectors
  67887. * @param left left vector to minimize
  67888. * @param right right vector to minimize
  67889. * @returns a new vector with the minimum of the left and right vector values
  67890. */
  67891. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67892. /**
  67893. * Returns a vector with the maximum values from the left and right vectors
  67894. * @param left left vector to maximize
  67895. * @param right right vector to maximize
  67896. * @returns a new vector with the maximum of the left and right vector values
  67897. */
  67898. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67899. /**
  67900. * Returns the distance (float) between the vectors "value1" and "value2".
  67901. * @param value1 value to calulate the distance between
  67902. * @param value2 value to calulate the distance between
  67903. * @return the distance between the two vectors
  67904. */
  67905. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67906. /**
  67907. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67908. * @param value1 value to calulate the distance between
  67909. * @param value2 value to calulate the distance between
  67910. * @return the distance between the two vectors squared
  67911. */
  67912. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67913. /**
  67914. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67915. * @param value1 value to calulate the center between
  67916. * @param value2 value to calulate the center between
  67917. * @return the center between the two vectors
  67918. */
  67919. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67920. /**
  67921. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67922. * This methods computes transformed normalized direction vectors only.
  67923. * @param vector the vector to transform
  67924. * @param transformation the transformation matrix to apply
  67925. * @returns the new vector
  67926. */
  67927. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67928. /**
  67929. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67930. * This methods computes transformed normalized direction vectors only.
  67931. * @param vector the vector to transform
  67932. * @param transformation the transformation matrix to apply
  67933. * @param result the vector to store the result in
  67934. */
  67935. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67936. /**
  67937. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67938. * This methods computes transformed normalized direction vectors only.
  67939. * @param x value to transform
  67940. * @param y value to transform
  67941. * @param z value to transform
  67942. * @param w value to transform
  67943. * @param transformation the transformation matrix to apply
  67944. * @param result the vector to store the results in
  67945. */
  67946. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67947. /**
  67948. * Creates a new Vector4 from a Vector3
  67949. * @param source defines the source data
  67950. * @param w defines the 4th component (default is 0)
  67951. * @returns a new Vector4
  67952. */
  67953. static FromVector3(source: Vector3, w?: number): Vector4;
  67954. }
  67955. /**
  67956. * Class used to store quaternion data
  67957. * @see https://en.wikipedia.org/wiki/Quaternion
  67958. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67959. */
  67960. export class Quaternion {
  67961. /** defines the first component (0 by default) */
  67962. x: number;
  67963. /** defines the second component (0 by default) */
  67964. y: number;
  67965. /** defines the third component (0 by default) */
  67966. z: number;
  67967. /** defines the fourth component (1.0 by default) */
  67968. w: number;
  67969. /**
  67970. * Creates a new Quaternion from the given floats
  67971. * @param x defines the first component (0 by default)
  67972. * @param y defines the second component (0 by default)
  67973. * @param z defines the third component (0 by default)
  67974. * @param w defines the fourth component (1.0 by default)
  67975. */
  67976. constructor(
  67977. /** defines the first component (0 by default) */
  67978. x?: number,
  67979. /** defines the second component (0 by default) */
  67980. y?: number,
  67981. /** defines the third component (0 by default) */
  67982. z?: number,
  67983. /** defines the fourth component (1.0 by default) */
  67984. w?: number);
  67985. /**
  67986. * Gets a string representation for the current quaternion
  67987. * @returns a string with the Quaternion coordinates
  67988. */
  67989. toString(): string;
  67990. /**
  67991. * Gets the class name of the quaternion
  67992. * @returns the string "Quaternion"
  67993. */
  67994. getClassName(): string;
  67995. /**
  67996. * Gets a hash code for this quaternion
  67997. * @returns the quaternion hash code
  67998. */
  67999. getHashCode(): number;
  68000. /**
  68001. * Copy the quaternion to an array
  68002. * @returns a new array populated with 4 elements from the quaternion coordinates
  68003. */
  68004. asArray(): number[];
  68005. /**
  68006. * Check if two quaternions are equals
  68007. * @param otherQuaternion defines the second operand
  68008. * @return true if the current quaternion and the given one coordinates are strictly equals
  68009. */
  68010. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68011. /**
  68012. * Clone the current quaternion
  68013. * @returns a new quaternion copied from the current one
  68014. */
  68015. clone(): Quaternion;
  68016. /**
  68017. * Copy a quaternion to the current one
  68018. * @param other defines the other quaternion
  68019. * @returns the updated current quaternion
  68020. */
  68021. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68022. /**
  68023. * Updates the current quaternion with the given float coordinates
  68024. * @param x defines the x coordinate
  68025. * @param y defines the y coordinate
  68026. * @param z defines the z coordinate
  68027. * @param w defines the w coordinate
  68028. * @returns the updated current quaternion
  68029. */
  68030. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68031. /**
  68032. * Updates the current quaternion from the given float coordinates
  68033. * @param x defines the x coordinate
  68034. * @param y defines the y coordinate
  68035. * @param z defines the z coordinate
  68036. * @param w defines the w coordinate
  68037. * @returns the updated current quaternion
  68038. */
  68039. set(x: number, y: number, z: number, w: number): Quaternion;
  68040. /**
  68041. * Adds two quaternions
  68042. * @param other defines the second operand
  68043. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68044. */
  68045. add(other: DeepImmutable<Quaternion>): Quaternion;
  68046. /**
  68047. * Add a quaternion to the current one
  68048. * @param other defines the quaternion to add
  68049. * @returns the current quaternion
  68050. */
  68051. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68052. /**
  68053. * Subtract two quaternions
  68054. * @param other defines the second operand
  68055. * @returns a new quaternion as the subtraction result of the given one from the current one
  68056. */
  68057. subtract(other: Quaternion): Quaternion;
  68058. /**
  68059. * Multiplies the current quaternion by a scale factor
  68060. * @param value defines the scale factor
  68061. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68062. */
  68063. scale(value: number): Quaternion;
  68064. /**
  68065. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68066. * @param scale defines the scale factor
  68067. * @param result defines the Quaternion object where to store the result
  68068. * @returns the unmodified current quaternion
  68069. */
  68070. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68071. /**
  68072. * Multiplies in place the current quaternion by a scale factor
  68073. * @param value defines the scale factor
  68074. * @returns the current modified quaternion
  68075. */
  68076. scaleInPlace(value: number): Quaternion;
  68077. /**
  68078. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68079. * @param scale defines the scale factor
  68080. * @param result defines the Quaternion object where to store the result
  68081. * @returns the unmodified current quaternion
  68082. */
  68083. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68084. /**
  68085. * Multiplies two quaternions
  68086. * @param q1 defines the second operand
  68087. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68088. */
  68089. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68090. /**
  68091. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68092. * @param q1 defines the second operand
  68093. * @param result defines the target quaternion
  68094. * @returns the current quaternion
  68095. */
  68096. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68097. /**
  68098. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68099. * @param q1 defines the second operand
  68100. * @returns the currentupdated quaternion
  68101. */
  68102. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68103. /**
  68104. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68105. * @param ref defines the target quaternion
  68106. * @returns the current quaternion
  68107. */
  68108. conjugateToRef(ref: Quaternion): Quaternion;
  68109. /**
  68110. * Conjugates in place (1-q) the current quaternion
  68111. * @returns the current updated quaternion
  68112. */
  68113. conjugateInPlace(): Quaternion;
  68114. /**
  68115. * Conjugates in place (1-q) the current quaternion
  68116. * @returns a new quaternion
  68117. */
  68118. conjugate(): Quaternion;
  68119. /**
  68120. * Gets length of current quaternion
  68121. * @returns the quaternion length (float)
  68122. */
  68123. length(): number;
  68124. /**
  68125. * Normalize in place the current quaternion
  68126. * @returns the current updated quaternion
  68127. */
  68128. normalize(): Quaternion;
  68129. /**
  68130. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68131. * @param order is a reserved parameter and is ignore for now
  68132. * @returns a new Vector3 containing the Euler angles
  68133. */
  68134. toEulerAngles(order?: string): Vector3;
  68135. /**
  68136. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68137. * @param result defines the vector which will be filled with the Euler angles
  68138. * @param order is a reserved parameter and is ignore for now
  68139. * @returns the current unchanged quaternion
  68140. */
  68141. toEulerAnglesToRef(result: Vector3): Quaternion;
  68142. /**
  68143. * Updates the given rotation matrix with the current quaternion values
  68144. * @param result defines the target matrix
  68145. * @returns the current unchanged quaternion
  68146. */
  68147. toRotationMatrix(result: Matrix): Quaternion;
  68148. /**
  68149. * Updates the current quaternion from the given rotation matrix values
  68150. * @param matrix defines the source matrix
  68151. * @returns the current updated quaternion
  68152. */
  68153. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68154. /**
  68155. * Creates a new quaternion from a rotation matrix
  68156. * @param matrix defines the source matrix
  68157. * @returns a new quaternion created from the given rotation matrix values
  68158. */
  68159. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68160. /**
  68161. * Updates the given quaternion with the given rotation matrix values
  68162. * @param matrix defines the source matrix
  68163. * @param result defines the target quaternion
  68164. */
  68165. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68166. /**
  68167. * Returns the dot product (float) between the quaternions "left" and "right"
  68168. * @param left defines the left operand
  68169. * @param right defines the right operand
  68170. * @returns the dot product
  68171. */
  68172. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68173. /**
  68174. * Checks if the two quaternions are close to each other
  68175. * @param quat0 defines the first quaternion to check
  68176. * @param quat1 defines the second quaternion to check
  68177. * @returns true if the two quaternions are close to each other
  68178. */
  68179. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68180. /**
  68181. * Creates an empty quaternion
  68182. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68183. */
  68184. static Zero(): Quaternion;
  68185. /**
  68186. * Inverse a given quaternion
  68187. * @param q defines the source quaternion
  68188. * @returns a new quaternion as the inverted current quaternion
  68189. */
  68190. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68191. /**
  68192. * Inverse a given quaternion
  68193. * @param q defines the source quaternion
  68194. * @param result the quaternion the result will be stored in
  68195. * @returns the result quaternion
  68196. */
  68197. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68198. /**
  68199. * Creates an identity quaternion
  68200. * @returns the identity quaternion
  68201. */
  68202. static Identity(): Quaternion;
  68203. /**
  68204. * Gets a boolean indicating if the given quaternion is identity
  68205. * @param quaternion defines the quaternion to check
  68206. * @returns true if the quaternion is identity
  68207. */
  68208. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68209. /**
  68210. * Creates a quaternion from a rotation around an axis
  68211. * @param axis defines the axis to use
  68212. * @param angle defines the angle to use
  68213. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68214. */
  68215. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68216. /**
  68217. * Creates a rotation around an axis and stores it into the given quaternion
  68218. * @param axis defines the axis to use
  68219. * @param angle defines the angle to use
  68220. * @param result defines the target quaternion
  68221. * @returns the target quaternion
  68222. */
  68223. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68224. /**
  68225. * Creates a new quaternion from data stored into an array
  68226. * @param array defines the data source
  68227. * @param offset defines the offset in the source array where the data starts
  68228. * @returns a new quaternion
  68229. */
  68230. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68231. /**
  68232. * Create a quaternion from Euler rotation angles
  68233. * @param x Pitch
  68234. * @param y Yaw
  68235. * @param z Roll
  68236. * @returns the new Quaternion
  68237. */
  68238. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68239. /**
  68240. * Updates a quaternion from Euler rotation angles
  68241. * @param x Pitch
  68242. * @param y Yaw
  68243. * @param z Roll
  68244. * @param result the quaternion to store the result
  68245. * @returns the updated quaternion
  68246. */
  68247. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68248. /**
  68249. * Create a quaternion from Euler rotation vector
  68250. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68251. * @returns the new Quaternion
  68252. */
  68253. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68254. /**
  68255. * Updates a quaternion from Euler rotation vector
  68256. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68257. * @param result the quaternion to store the result
  68258. * @returns the updated quaternion
  68259. */
  68260. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68261. /**
  68262. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68263. * @param yaw defines the rotation around Y axis
  68264. * @param pitch defines the rotation around X axis
  68265. * @param roll defines the rotation around Z axis
  68266. * @returns the new quaternion
  68267. */
  68268. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68269. /**
  68270. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68271. * @param yaw defines the rotation around Y axis
  68272. * @param pitch defines the rotation around X axis
  68273. * @param roll defines the rotation around Z axis
  68274. * @param result defines the target quaternion
  68275. */
  68276. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68277. /**
  68278. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68279. * @param alpha defines the rotation around first axis
  68280. * @param beta defines the rotation around second axis
  68281. * @param gamma defines the rotation around third axis
  68282. * @returns the new quaternion
  68283. */
  68284. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68285. /**
  68286. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68287. * @param alpha defines the rotation around first axis
  68288. * @param beta defines the rotation around second axis
  68289. * @param gamma defines the rotation around third axis
  68290. * @param result defines the target quaternion
  68291. */
  68292. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68293. /**
  68294. * 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)
  68295. * @param axis1 defines the first axis
  68296. * @param axis2 defines the second axis
  68297. * @param axis3 defines the third axis
  68298. * @returns the new quaternion
  68299. */
  68300. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68301. /**
  68302. * 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
  68303. * @param axis1 defines the first axis
  68304. * @param axis2 defines the second axis
  68305. * @param axis3 defines the third axis
  68306. * @param ref defines the target quaternion
  68307. */
  68308. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68309. /**
  68310. * Interpolates between two quaternions
  68311. * @param left defines first quaternion
  68312. * @param right defines second quaternion
  68313. * @param amount defines the gradient to use
  68314. * @returns the new interpolated quaternion
  68315. */
  68316. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68317. /**
  68318. * Interpolates between two quaternions and stores it into a target quaternion
  68319. * @param left defines first quaternion
  68320. * @param right defines second quaternion
  68321. * @param amount defines the gradient to use
  68322. * @param result defines the target quaternion
  68323. */
  68324. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68325. /**
  68326. * Interpolate between two quaternions using Hermite interpolation
  68327. * @param value1 defines first quaternion
  68328. * @param tangent1 defines the incoming tangent
  68329. * @param value2 defines second quaternion
  68330. * @param tangent2 defines the outgoing tangent
  68331. * @param amount defines the target quaternion
  68332. * @returns the new interpolated quaternion
  68333. */
  68334. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68335. }
  68336. /**
  68337. * Class used to store matrix data (4x4)
  68338. */
  68339. export class Matrix {
  68340. private static _updateFlagSeed;
  68341. private static _identityReadOnly;
  68342. private _isIdentity;
  68343. private _isIdentityDirty;
  68344. private _isIdentity3x2;
  68345. private _isIdentity3x2Dirty;
  68346. /**
  68347. * Gets the update flag of the matrix which is an unique number for the matrix.
  68348. * It will be incremented every time the matrix data change.
  68349. * You can use it to speed the comparison between two versions of the same matrix.
  68350. */
  68351. updateFlag: number;
  68352. private readonly _m;
  68353. /**
  68354. * Gets the internal data of the matrix
  68355. */
  68356. readonly m: DeepImmutable<Float32Array>;
  68357. /** @hidden */
  68358. _markAsUpdated(): void;
  68359. /** @hidden */
  68360. private _updateIdentityStatus;
  68361. /**
  68362. * Creates an empty matrix (filled with zeros)
  68363. */
  68364. constructor();
  68365. /**
  68366. * Check if the current matrix is identity
  68367. * @returns true is the matrix is the identity matrix
  68368. */
  68369. isIdentity(): boolean;
  68370. /**
  68371. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68372. * @returns true is the matrix is the identity matrix
  68373. */
  68374. isIdentityAs3x2(): boolean;
  68375. /**
  68376. * Gets the determinant of the matrix
  68377. * @returns the matrix determinant
  68378. */
  68379. determinant(): number;
  68380. /**
  68381. * Returns the matrix as a Float32Array
  68382. * @returns the matrix underlying array
  68383. */
  68384. toArray(): DeepImmutable<Float32Array>;
  68385. /**
  68386. * Returns the matrix as a Float32Array
  68387. * @returns the matrix underlying array.
  68388. */
  68389. asArray(): DeepImmutable<Float32Array>;
  68390. /**
  68391. * Inverts the current matrix in place
  68392. * @returns the current inverted matrix
  68393. */
  68394. invert(): Matrix;
  68395. /**
  68396. * Sets all the matrix elements to zero
  68397. * @returns the current matrix
  68398. */
  68399. reset(): Matrix;
  68400. /**
  68401. * Adds the current matrix with a second one
  68402. * @param other defines the matrix to add
  68403. * @returns a new matrix as the addition of the current matrix and the given one
  68404. */
  68405. add(other: DeepImmutable<Matrix>): Matrix;
  68406. /**
  68407. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68408. * @param other defines the matrix to add
  68409. * @param result defines the target matrix
  68410. * @returns the current matrix
  68411. */
  68412. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68413. /**
  68414. * Adds in place the given matrix to the current matrix
  68415. * @param other defines the second operand
  68416. * @returns the current updated matrix
  68417. */
  68418. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68419. /**
  68420. * Sets the given matrix to the current inverted Matrix
  68421. * @param other defines the target matrix
  68422. * @returns the unmodified current matrix
  68423. */
  68424. invertToRef(other: Matrix): Matrix;
  68425. /**
  68426. * add a value at the specified position in the current Matrix
  68427. * @param index the index of the value within the matrix. between 0 and 15.
  68428. * @param value the value to be added
  68429. * @returns the current updated matrix
  68430. */
  68431. addAtIndex(index: number, value: number): Matrix;
  68432. /**
  68433. * mutiply the specified position in the current Matrix by a value
  68434. * @param index the index of the value within the matrix. between 0 and 15.
  68435. * @param value the value to be added
  68436. * @returns the current updated matrix
  68437. */
  68438. multiplyAtIndex(index: number, value: number): Matrix;
  68439. /**
  68440. * Inserts the translation vector (using 3 floats) in the current matrix
  68441. * @param x defines the 1st component of the translation
  68442. * @param y defines the 2nd component of the translation
  68443. * @param z defines the 3rd component of the translation
  68444. * @returns the current updated matrix
  68445. */
  68446. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68447. /**
  68448. * Adds the translation vector (using 3 floats) in the current matrix
  68449. * @param x defines the 1st component of the translation
  68450. * @param y defines the 2nd component of the translation
  68451. * @param z defines the 3rd component of the translation
  68452. * @returns the current updated matrix
  68453. */
  68454. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68455. /**
  68456. * Inserts the translation vector in the current matrix
  68457. * @param vector3 defines the translation to insert
  68458. * @returns the current updated matrix
  68459. */
  68460. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68461. /**
  68462. * Gets the translation value of the current matrix
  68463. * @returns a new Vector3 as the extracted translation from the matrix
  68464. */
  68465. getTranslation(): Vector3;
  68466. /**
  68467. * Fill a Vector3 with the extracted translation from the matrix
  68468. * @param result defines the Vector3 where to store the translation
  68469. * @returns the current matrix
  68470. */
  68471. getTranslationToRef(result: Vector3): Matrix;
  68472. /**
  68473. * Remove rotation and scaling part from the matrix
  68474. * @returns the updated matrix
  68475. */
  68476. removeRotationAndScaling(): Matrix;
  68477. /**
  68478. * Multiply two matrices
  68479. * @param other defines the second operand
  68480. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68481. */
  68482. multiply(other: DeepImmutable<Matrix>): Matrix;
  68483. /**
  68484. * Copy the current matrix from the given one
  68485. * @param other defines the source matrix
  68486. * @returns the current updated matrix
  68487. */
  68488. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68489. /**
  68490. * Populates the given array from the starting index with the current matrix values
  68491. * @param array defines the target array
  68492. * @param offset defines the offset in the target array where to start storing values
  68493. * @returns the current matrix
  68494. */
  68495. copyToArray(array: Float32Array, offset?: number): Matrix;
  68496. /**
  68497. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68498. * @param other defines the second operand
  68499. * @param result defines the matrix where to store the multiplication
  68500. * @returns the current matrix
  68501. */
  68502. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68503. /**
  68504. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68505. * @param other defines the second operand
  68506. * @param result defines the array where to store the multiplication
  68507. * @param offset defines the offset in the target array where to start storing values
  68508. * @returns the current matrix
  68509. */
  68510. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68511. /**
  68512. * Check equality between this matrix and a second one
  68513. * @param value defines the second matrix to compare
  68514. * @returns true is the current matrix and the given one values are strictly equal
  68515. */
  68516. equals(value: DeepImmutable<Matrix>): boolean;
  68517. /**
  68518. * Clone the current matrix
  68519. * @returns a new matrix from the current matrix
  68520. */
  68521. clone(): Matrix;
  68522. /**
  68523. * Returns the name of the current matrix class
  68524. * @returns the string "Matrix"
  68525. */
  68526. getClassName(): string;
  68527. /**
  68528. * Gets the hash code of the current matrix
  68529. * @returns the hash code
  68530. */
  68531. getHashCode(): number;
  68532. /**
  68533. * Decomposes the current Matrix into a translation, rotation and scaling components
  68534. * @param scale defines the scale vector3 given as a reference to update
  68535. * @param rotation defines the rotation quaternion given as a reference to update
  68536. * @param translation defines the translation vector3 given as a reference to update
  68537. * @returns true if operation was successful
  68538. */
  68539. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68540. /**
  68541. * Gets specific row of the matrix
  68542. * @param index defines the number of the row to get
  68543. * @returns the index-th row of the current matrix as a new Vector4
  68544. */
  68545. getRow(index: number): Nullable<Vector4>;
  68546. /**
  68547. * Sets the index-th row of the current matrix to the vector4 values
  68548. * @param index defines the number of the row to set
  68549. * @param row defines the target vector4
  68550. * @returns the updated current matrix
  68551. */
  68552. setRow(index: number, row: Vector4): Matrix;
  68553. /**
  68554. * Compute the transpose of the matrix
  68555. * @returns the new transposed matrix
  68556. */
  68557. transpose(): Matrix;
  68558. /**
  68559. * Compute the transpose of the matrix and store it in a given matrix
  68560. * @param result defines the target matrix
  68561. * @returns the current matrix
  68562. */
  68563. transposeToRef(result: Matrix): Matrix;
  68564. /**
  68565. * Sets the index-th row of the current matrix with the given 4 x float values
  68566. * @param index defines the row index
  68567. * @param x defines the x component to set
  68568. * @param y defines the y component to set
  68569. * @param z defines the z component to set
  68570. * @param w defines the w component to set
  68571. * @returns the updated current matrix
  68572. */
  68573. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68574. /**
  68575. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68576. * @param scale defines the scale factor
  68577. * @returns a new matrix
  68578. */
  68579. scale(scale: number): Matrix;
  68580. /**
  68581. * Scale the current matrix values by a factor to a given result matrix
  68582. * @param scale defines the scale factor
  68583. * @param result defines the matrix to store the result
  68584. * @returns the current matrix
  68585. */
  68586. scaleToRef(scale: number, result: Matrix): Matrix;
  68587. /**
  68588. * Scale the current matrix values by a factor and add the result to a given matrix
  68589. * @param scale defines the scale factor
  68590. * @param result defines the Matrix to store the result
  68591. * @returns the current matrix
  68592. */
  68593. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68594. /**
  68595. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68596. * @param ref matrix to store the result
  68597. */
  68598. toNormalMatrix(ref: Matrix): void;
  68599. /**
  68600. * Gets only rotation part of the current matrix
  68601. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68602. */
  68603. getRotationMatrix(): Matrix;
  68604. /**
  68605. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68606. * @param result defines the target matrix to store data to
  68607. * @returns the current matrix
  68608. */
  68609. getRotationMatrixToRef(result: Matrix): Matrix;
  68610. /**
  68611. * Toggles model matrix from being right handed to left handed in place and vice versa
  68612. */
  68613. toggleModelMatrixHandInPlace(): void;
  68614. /**
  68615. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68616. */
  68617. toggleProjectionMatrixHandInPlace(): void;
  68618. /**
  68619. * Creates a matrix from an array
  68620. * @param array defines the source array
  68621. * @param offset defines an offset in the source array
  68622. * @returns a new Matrix set from the starting index of the given array
  68623. */
  68624. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68625. /**
  68626. * Copy the content of an array into a given matrix
  68627. * @param array defines the source array
  68628. * @param offset defines an offset in the source array
  68629. * @param result defines the target matrix
  68630. */
  68631. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68632. /**
  68633. * Stores an array into a matrix after having multiplied each component by a given factor
  68634. * @param array defines the source array
  68635. * @param offset defines the offset in the source array
  68636. * @param scale defines the scaling factor
  68637. * @param result defines the target matrix
  68638. */
  68639. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68640. /**
  68641. * Gets an identity matrix that must not be updated
  68642. */
  68643. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68644. /**
  68645. * Stores a list of values (16) inside a given matrix
  68646. * @param initialM11 defines 1st value of 1st row
  68647. * @param initialM12 defines 2nd value of 1st row
  68648. * @param initialM13 defines 3rd value of 1st row
  68649. * @param initialM14 defines 4th value of 1st row
  68650. * @param initialM21 defines 1st value of 2nd row
  68651. * @param initialM22 defines 2nd value of 2nd row
  68652. * @param initialM23 defines 3rd value of 2nd row
  68653. * @param initialM24 defines 4th value of 2nd row
  68654. * @param initialM31 defines 1st value of 3rd row
  68655. * @param initialM32 defines 2nd value of 3rd row
  68656. * @param initialM33 defines 3rd value of 3rd row
  68657. * @param initialM34 defines 4th value of 3rd row
  68658. * @param initialM41 defines 1st value of 4th row
  68659. * @param initialM42 defines 2nd value of 4th row
  68660. * @param initialM43 defines 3rd value of 4th row
  68661. * @param initialM44 defines 4th value of 4th row
  68662. * @param result defines the target matrix
  68663. */
  68664. 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;
  68665. /**
  68666. * Creates new matrix from a list of values (16)
  68667. * @param initialM11 defines 1st value of 1st row
  68668. * @param initialM12 defines 2nd value of 1st row
  68669. * @param initialM13 defines 3rd value of 1st row
  68670. * @param initialM14 defines 4th value of 1st row
  68671. * @param initialM21 defines 1st value of 2nd row
  68672. * @param initialM22 defines 2nd value of 2nd row
  68673. * @param initialM23 defines 3rd value of 2nd row
  68674. * @param initialM24 defines 4th value of 2nd row
  68675. * @param initialM31 defines 1st value of 3rd row
  68676. * @param initialM32 defines 2nd value of 3rd row
  68677. * @param initialM33 defines 3rd value of 3rd row
  68678. * @param initialM34 defines 4th value of 3rd row
  68679. * @param initialM41 defines 1st value of 4th row
  68680. * @param initialM42 defines 2nd value of 4th row
  68681. * @param initialM43 defines 3rd value of 4th row
  68682. * @param initialM44 defines 4th value of 4th row
  68683. * @returns the new matrix
  68684. */
  68685. 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;
  68686. /**
  68687. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68688. * @param scale defines the scale vector3
  68689. * @param rotation defines the rotation quaternion
  68690. * @param translation defines the translation vector3
  68691. * @returns a new matrix
  68692. */
  68693. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68694. /**
  68695. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68696. * @param scale defines the scale vector3
  68697. * @param rotation defines the rotation quaternion
  68698. * @param translation defines the translation vector3
  68699. * @param result defines the target matrix
  68700. */
  68701. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68702. /**
  68703. * Creates a new identity matrix
  68704. * @returns a new identity matrix
  68705. */
  68706. static Identity(): Matrix;
  68707. /**
  68708. * Creates a new identity matrix and stores the result in a given matrix
  68709. * @param result defines the target matrix
  68710. */
  68711. static IdentityToRef(result: Matrix): void;
  68712. /**
  68713. * Creates a new zero matrix
  68714. * @returns a new zero matrix
  68715. */
  68716. static Zero(): Matrix;
  68717. /**
  68718. * Creates a new rotation matrix for "angle" radians around the X axis
  68719. * @param angle defines the angle (in radians) to use
  68720. * @return the new matrix
  68721. */
  68722. static RotationX(angle: number): Matrix;
  68723. /**
  68724. * Creates a new matrix as the invert of a given matrix
  68725. * @param source defines the source matrix
  68726. * @returns the new matrix
  68727. */
  68728. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68729. /**
  68730. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68731. * @param angle defines the angle (in radians) to use
  68732. * @param result defines the target matrix
  68733. */
  68734. static RotationXToRef(angle: number, result: Matrix): void;
  68735. /**
  68736. * Creates a new rotation matrix for "angle" radians around the Y axis
  68737. * @param angle defines the angle (in radians) to use
  68738. * @return the new matrix
  68739. */
  68740. static RotationY(angle: number): Matrix;
  68741. /**
  68742. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68743. * @param angle defines the angle (in radians) to use
  68744. * @param result defines the target matrix
  68745. */
  68746. static RotationYToRef(angle: number, result: Matrix): void;
  68747. /**
  68748. * Creates a new rotation matrix for "angle" radians around the Z axis
  68749. * @param angle defines the angle (in radians) to use
  68750. * @return the new matrix
  68751. */
  68752. static RotationZ(angle: number): Matrix;
  68753. /**
  68754. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68755. * @param angle defines the angle (in radians) to use
  68756. * @param result defines the target matrix
  68757. */
  68758. static RotationZToRef(angle: number, result: Matrix): void;
  68759. /**
  68760. * Creates a new rotation matrix for "angle" radians around the given axis
  68761. * @param axis defines the axis to use
  68762. * @param angle defines the angle (in radians) to use
  68763. * @return the new matrix
  68764. */
  68765. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68766. /**
  68767. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68768. * @param axis defines the axis to use
  68769. * @param angle defines the angle (in radians) to use
  68770. * @param result defines the target matrix
  68771. */
  68772. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68773. /**
  68774. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68775. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68776. * @param from defines the vector to align
  68777. * @param to defines the vector to align to
  68778. * @param result defines the target matrix
  68779. */
  68780. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68781. /**
  68782. * Creates a rotation matrix
  68783. * @param yaw defines the yaw angle in radians (Y axis)
  68784. * @param pitch defines the pitch angle in radians (X axis)
  68785. * @param roll defines the roll angle in radians (X axis)
  68786. * @returns the new rotation matrix
  68787. */
  68788. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68789. /**
  68790. * Creates a rotation matrix and stores it in a given matrix
  68791. * @param yaw defines the yaw angle in radians (Y axis)
  68792. * @param pitch defines the pitch angle in radians (X axis)
  68793. * @param roll defines the roll angle in radians (X axis)
  68794. * @param result defines the target matrix
  68795. */
  68796. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68797. /**
  68798. * Creates a scaling matrix
  68799. * @param x defines the scale factor on X axis
  68800. * @param y defines the scale factor on Y axis
  68801. * @param z defines the scale factor on Z axis
  68802. * @returns the new matrix
  68803. */
  68804. static Scaling(x: number, y: number, z: number): Matrix;
  68805. /**
  68806. * Creates a scaling matrix and stores it in a given matrix
  68807. * @param x defines the scale factor on X axis
  68808. * @param y defines the scale factor on Y axis
  68809. * @param z defines the scale factor on Z axis
  68810. * @param result defines the target matrix
  68811. */
  68812. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68813. /**
  68814. * Creates a translation matrix
  68815. * @param x defines the translation on X axis
  68816. * @param y defines the translation on Y axis
  68817. * @param z defines the translationon Z axis
  68818. * @returns the new matrix
  68819. */
  68820. static Translation(x: number, y: number, z: number): Matrix;
  68821. /**
  68822. * Creates a translation matrix and stores it in a given matrix
  68823. * @param x defines the translation on X axis
  68824. * @param y defines the translation on Y axis
  68825. * @param z defines the translationon Z axis
  68826. * @param result defines the target matrix
  68827. */
  68828. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68829. /**
  68830. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68831. * @param startValue defines the start value
  68832. * @param endValue defines the end value
  68833. * @param gradient defines the gradient factor
  68834. * @returns the new matrix
  68835. */
  68836. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68837. /**
  68838. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68839. * @param startValue defines the start value
  68840. * @param endValue defines the end value
  68841. * @param gradient defines the gradient factor
  68842. * @param result defines the Matrix object where to store data
  68843. */
  68844. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68845. /**
  68846. * Builds a new matrix whose values are computed by:
  68847. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68848. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68849. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68850. * @param startValue defines the first matrix
  68851. * @param endValue defines the second matrix
  68852. * @param gradient defines the gradient between the two matrices
  68853. * @returns the new matrix
  68854. */
  68855. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68856. /**
  68857. * Update a matrix to values which are computed by:
  68858. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68859. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68860. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68861. * @param startValue defines the first matrix
  68862. * @param endValue defines the second matrix
  68863. * @param gradient defines the gradient between the two matrices
  68864. * @param result defines the target matrix
  68865. */
  68866. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68867. /**
  68868. * 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"
  68869. * This function works in left handed mode
  68870. * @param eye defines the final position of the entity
  68871. * @param target defines where the entity should look at
  68872. * @param up defines the up vector for the entity
  68873. * @returns the new matrix
  68874. */
  68875. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68876. /**
  68877. * 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".
  68878. * This function works in left handed mode
  68879. * @param eye defines the final position of the entity
  68880. * @param target defines where the entity should look at
  68881. * @param up defines the up vector for the entity
  68882. * @param result defines the target matrix
  68883. */
  68884. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68885. /**
  68886. * 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"
  68887. * This function works in right handed mode
  68888. * @param eye defines the final position of the entity
  68889. * @param target defines where the entity should look at
  68890. * @param up defines the up vector for the entity
  68891. * @returns the new matrix
  68892. */
  68893. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68894. /**
  68895. * 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".
  68896. * This function works in right handed mode
  68897. * @param eye defines the final position of the entity
  68898. * @param target defines where the entity should look at
  68899. * @param up defines the up vector for the entity
  68900. * @param result defines the target matrix
  68901. */
  68902. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68903. /**
  68904. * Create a left-handed orthographic projection matrix
  68905. * @param width defines the viewport width
  68906. * @param height defines the viewport height
  68907. * @param znear defines the near clip plane
  68908. * @param zfar defines the far clip plane
  68909. * @returns a new matrix as a left-handed orthographic projection matrix
  68910. */
  68911. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68912. /**
  68913. * Store a left-handed orthographic projection to a given matrix
  68914. * @param width defines the viewport width
  68915. * @param height defines the viewport height
  68916. * @param znear defines the near clip plane
  68917. * @param zfar defines the far clip plane
  68918. * @param result defines the target matrix
  68919. */
  68920. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68921. /**
  68922. * Create a left-handed orthographic projection matrix
  68923. * @param left defines the viewport left coordinate
  68924. * @param right defines the viewport right coordinate
  68925. * @param bottom defines the viewport bottom coordinate
  68926. * @param top defines the viewport top coordinate
  68927. * @param znear defines the near clip plane
  68928. * @param zfar defines the far clip plane
  68929. * @returns a new matrix as a left-handed orthographic projection matrix
  68930. */
  68931. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68932. /**
  68933. * Stores a left-handed orthographic projection into a given matrix
  68934. * @param left defines the viewport left coordinate
  68935. * @param right defines the viewport right coordinate
  68936. * @param bottom defines the viewport bottom coordinate
  68937. * @param top defines the viewport top coordinate
  68938. * @param znear defines the near clip plane
  68939. * @param zfar defines the far clip plane
  68940. * @param result defines the target matrix
  68941. */
  68942. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68943. /**
  68944. * Creates a right-handed orthographic projection matrix
  68945. * @param left defines the viewport left coordinate
  68946. * @param right defines the viewport right coordinate
  68947. * @param bottom defines the viewport bottom coordinate
  68948. * @param top defines the viewport top coordinate
  68949. * @param znear defines the near clip plane
  68950. * @param zfar defines the far clip plane
  68951. * @returns a new matrix as a right-handed orthographic projection matrix
  68952. */
  68953. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68954. /**
  68955. * Stores a right-handed orthographic projection into a given matrix
  68956. * @param left defines the viewport left coordinate
  68957. * @param right defines the viewport right coordinate
  68958. * @param bottom defines the viewport bottom coordinate
  68959. * @param top defines the viewport top coordinate
  68960. * @param znear defines the near clip plane
  68961. * @param zfar defines the far clip plane
  68962. * @param result defines the target matrix
  68963. */
  68964. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68965. /**
  68966. * Creates a left-handed perspective projection matrix
  68967. * @param width defines the viewport width
  68968. * @param height defines the viewport height
  68969. * @param znear defines the near clip plane
  68970. * @param zfar defines the far clip plane
  68971. * @returns a new matrix as a left-handed perspective projection matrix
  68972. */
  68973. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68974. /**
  68975. * Creates a left-handed perspective projection matrix
  68976. * @param fov defines the horizontal field of view
  68977. * @param aspect defines the aspect ratio
  68978. * @param znear defines the near clip plane
  68979. * @param zfar defines the far clip plane
  68980. * @returns a new matrix as a left-handed perspective projection matrix
  68981. */
  68982. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68983. /**
  68984. * Stores a left-handed perspective projection into a given matrix
  68985. * @param fov defines the horizontal field of view
  68986. * @param aspect defines the aspect ratio
  68987. * @param znear defines the near clip plane
  68988. * @param zfar defines the far clip plane
  68989. * @param result defines the target matrix
  68990. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68991. */
  68992. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68993. /**
  68994. * Creates a right-handed perspective projection matrix
  68995. * @param fov defines the horizontal field of view
  68996. * @param aspect defines the aspect ratio
  68997. * @param znear defines the near clip plane
  68998. * @param zfar defines the far clip plane
  68999. * @returns a new matrix as a right-handed perspective projection matrix
  69000. */
  69001. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69002. /**
  69003. * Stores a right-handed perspective projection into a given matrix
  69004. * @param fov defines the horizontal field of view
  69005. * @param aspect defines the aspect ratio
  69006. * @param znear defines the near clip plane
  69007. * @param zfar defines the far clip plane
  69008. * @param result defines the target matrix
  69009. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69010. */
  69011. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69012. /**
  69013. * Stores a perspective projection for WebVR info a given matrix
  69014. * @param fov defines the field of view
  69015. * @param znear defines the near clip plane
  69016. * @param zfar defines the far clip plane
  69017. * @param result defines the target matrix
  69018. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69019. */
  69020. static PerspectiveFovWebVRToRef(fov: {
  69021. upDegrees: number;
  69022. downDegrees: number;
  69023. leftDegrees: number;
  69024. rightDegrees: number;
  69025. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69026. /**
  69027. * Computes a complete transformation matrix
  69028. * @param viewport defines the viewport to use
  69029. * @param world defines the world matrix
  69030. * @param view defines the view matrix
  69031. * @param projection defines the projection matrix
  69032. * @param zmin defines the near clip plane
  69033. * @param zmax defines the far clip plane
  69034. * @returns the transformation matrix
  69035. */
  69036. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69037. /**
  69038. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69039. * @param matrix defines the matrix to use
  69040. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69041. */
  69042. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69043. /**
  69044. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69045. * @param matrix defines the matrix to use
  69046. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69047. */
  69048. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69049. /**
  69050. * Compute the transpose of a given matrix
  69051. * @param matrix defines the matrix to transpose
  69052. * @returns the new matrix
  69053. */
  69054. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69055. /**
  69056. * Compute the transpose of a matrix and store it in a target matrix
  69057. * @param matrix defines the matrix to transpose
  69058. * @param result defines the target matrix
  69059. */
  69060. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69061. /**
  69062. * Computes a reflection matrix from a plane
  69063. * @param plane defines the reflection plane
  69064. * @returns a new matrix
  69065. */
  69066. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69067. /**
  69068. * Computes a reflection matrix from a plane
  69069. * @param plane defines the reflection plane
  69070. * @param result defines the target matrix
  69071. */
  69072. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69073. /**
  69074. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69075. * @param xaxis defines the value of the 1st axis
  69076. * @param yaxis defines the value of the 2nd axis
  69077. * @param zaxis defines the value of the 3rd axis
  69078. * @param result defines the target matrix
  69079. */
  69080. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69081. /**
  69082. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69083. * @param quat defines the quaternion to use
  69084. * @param result defines the target matrix
  69085. */
  69086. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69087. }
  69088. /**
  69089. * @hidden
  69090. */
  69091. export class TmpVectors {
  69092. static Vector2: Vector2[];
  69093. static Vector3: Vector3[];
  69094. static Vector4: Vector4[];
  69095. static Quaternion: Quaternion[];
  69096. static Matrix: Matrix[];
  69097. }
  69098. }
  69099. declare module BABYLON {
  69100. /** Defines the cross module used constants to avoid circular dependncies */
  69101. export class Constants {
  69102. /** Defines that alpha blending is disabled */
  69103. static readonly ALPHA_DISABLE: number;
  69104. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69105. static readonly ALPHA_ADD: number;
  69106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69107. static readonly ALPHA_COMBINE: number;
  69108. /** Defines that alpha blending to DEST - SRC * DEST */
  69109. static readonly ALPHA_SUBTRACT: number;
  69110. /** Defines that alpha blending to SRC * DEST */
  69111. static readonly ALPHA_MULTIPLY: number;
  69112. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69113. static readonly ALPHA_MAXIMIZED: number;
  69114. /** Defines that alpha blending to SRC + DEST */
  69115. static readonly ALPHA_ONEONE: number;
  69116. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69117. static readonly ALPHA_PREMULTIPLIED: number;
  69118. /**
  69119. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69120. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69121. */
  69122. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69123. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69124. static readonly ALPHA_INTERPOLATE: number;
  69125. /**
  69126. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69127. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69128. */
  69129. static readonly ALPHA_SCREENMODE: number;
  69130. /** Defines that the ressource is not delayed*/
  69131. static readonly DELAYLOADSTATE_NONE: number;
  69132. /** Defines that the ressource was successfully delay loaded */
  69133. static readonly DELAYLOADSTATE_LOADED: number;
  69134. /** Defines that the ressource is currently delay loading */
  69135. static readonly DELAYLOADSTATE_LOADING: number;
  69136. /** Defines that the ressource is delayed and has not started loading */
  69137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69139. static readonly NEVER: number;
  69140. /** 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 */
  69141. static readonly ALWAYS: number;
  69142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69143. static readonly LESS: number;
  69144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69145. static readonly EQUAL: number;
  69146. /** 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 */
  69147. static readonly LEQUAL: number;
  69148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69149. static readonly GREATER: number;
  69150. /** 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 */
  69151. static readonly GEQUAL: number;
  69152. /** 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 */
  69153. static readonly NOTEQUAL: number;
  69154. /** Passed to stencilOperation to specify that stencil value must be kept */
  69155. static readonly KEEP: number;
  69156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69157. static readonly REPLACE: number;
  69158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69159. static readonly INCR: number;
  69160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69161. static readonly DECR: number;
  69162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69163. static readonly INVERT: number;
  69164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69165. static readonly INCR_WRAP: number;
  69166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69167. static readonly DECR_WRAP: number;
  69168. /** Texture is not repeating outside of 0..1 UVs */
  69169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69170. /** Texture is repeating outside of 0..1 UVs */
  69171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69172. /** Texture is repeating and mirrored */
  69173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69174. /** ALPHA */
  69175. static readonly TEXTUREFORMAT_ALPHA: number;
  69176. /** LUMINANCE */
  69177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69178. /** LUMINANCE_ALPHA */
  69179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69180. /** RGB */
  69181. static readonly TEXTUREFORMAT_RGB: number;
  69182. /** RGBA */
  69183. static readonly TEXTUREFORMAT_RGBA: number;
  69184. /** RED */
  69185. static readonly TEXTUREFORMAT_RED: number;
  69186. /** RED (2nd reference) */
  69187. static readonly TEXTUREFORMAT_R: number;
  69188. /** RG */
  69189. static readonly TEXTUREFORMAT_RG: number;
  69190. /** RED_INTEGER */
  69191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69192. /** RED_INTEGER (2nd reference) */
  69193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69194. /** RG_INTEGER */
  69195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69196. /** RGB_INTEGER */
  69197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69198. /** RGBA_INTEGER */
  69199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69200. /** UNSIGNED_BYTE */
  69201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69202. /** UNSIGNED_BYTE (2nd reference) */
  69203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69204. /** FLOAT */
  69205. static readonly TEXTURETYPE_FLOAT: number;
  69206. /** HALF_FLOAT */
  69207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69208. /** BYTE */
  69209. static readonly TEXTURETYPE_BYTE: number;
  69210. /** SHORT */
  69211. static readonly TEXTURETYPE_SHORT: number;
  69212. /** UNSIGNED_SHORT */
  69213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69214. /** INT */
  69215. static readonly TEXTURETYPE_INT: number;
  69216. /** UNSIGNED_INT */
  69217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69218. /** UNSIGNED_SHORT_4_4_4_4 */
  69219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69220. /** UNSIGNED_SHORT_5_5_5_1 */
  69221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69222. /** UNSIGNED_SHORT_5_6_5 */
  69223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69224. /** UNSIGNED_INT_2_10_10_10_REV */
  69225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69226. /** UNSIGNED_INT_24_8 */
  69227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69228. /** UNSIGNED_INT_10F_11F_11F_REV */
  69229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69230. /** UNSIGNED_INT_5_9_9_9_REV */
  69231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69234. /** nearest is mag = nearest and min = nearest and mip = linear */
  69235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69238. /** Trilinear is mag = linear and min = linear and mip = linear */
  69239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69240. /** nearest is mag = nearest and min = nearest and mip = linear */
  69241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69244. /** Trilinear is mag = linear and min = linear and mip = linear */
  69245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69246. /** mag = nearest and min = nearest and mip = nearest */
  69247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69248. /** mag = nearest and min = linear and mip = nearest */
  69249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69250. /** mag = nearest and min = linear and mip = linear */
  69251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69252. /** mag = nearest and min = linear and mip = none */
  69253. static readonly TEXTURE_NEAREST_LINEAR: number;
  69254. /** mag = nearest and min = nearest and mip = none */
  69255. static readonly TEXTURE_NEAREST_NEAREST: number;
  69256. /** mag = linear and min = nearest and mip = nearest */
  69257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69258. /** mag = linear and min = nearest and mip = linear */
  69259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69260. /** mag = linear and min = linear and mip = none */
  69261. static readonly TEXTURE_LINEAR_LINEAR: number;
  69262. /** mag = linear and min = nearest and mip = none */
  69263. static readonly TEXTURE_LINEAR_NEAREST: number;
  69264. /** Explicit coordinates mode */
  69265. static readonly TEXTURE_EXPLICIT_MODE: number;
  69266. /** Spherical coordinates mode */
  69267. static readonly TEXTURE_SPHERICAL_MODE: number;
  69268. /** Planar coordinates mode */
  69269. static readonly TEXTURE_PLANAR_MODE: number;
  69270. /** Cubic coordinates mode */
  69271. static readonly TEXTURE_CUBIC_MODE: number;
  69272. /** Projection coordinates mode */
  69273. static readonly TEXTURE_PROJECTION_MODE: number;
  69274. /** Skybox coordinates mode */
  69275. static readonly TEXTURE_SKYBOX_MODE: number;
  69276. /** Inverse Cubic coordinates mode */
  69277. static readonly TEXTURE_INVCUBIC_MODE: number;
  69278. /** Equirectangular coordinates mode */
  69279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69280. /** Equirectangular Fixed coordinates mode */
  69281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69282. /** Equirectangular Fixed Mirrored coordinates mode */
  69283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69285. static readonly SCALEMODE_FLOOR: number;
  69286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69287. static readonly SCALEMODE_NEAREST: number;
  69288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69289. static readonly SCALEMODE_CEILING: number;
  69290. /**
  69291. * The dirty texture flag value
  69292. */
  69293. static readonly MATERIAL_TextureDirtyFlag: number;
  69294. /**
  69295. * The dirty light flag value
  69296. */
  69297. static readonly MATERIAL_LightDirtyFlag: number;
  69298. /**
  69299. * The dirty fresnel flag value
  69300. */
  69301. static readonly MATERIAL_FresnelDirtyFlag: number;
  69302. /**
  69303. * The dirty attribute flag value
  69304. */
  69305. static readonly MATERIAL_AttributesDirtyFlag: number;
  69306. /**
  69307. * The dirty misc flag value
  69308. */
  69309. static readonly MATERIAL_MiscDirtyFlag: number;
  69310. /**
  69311. * The all dirty flag value
  69312. */
  69313. static readonly MATERIAL_AllDirtyFlag: number;
  69314. /**
  69315. * Returns the triangle fill mode
  69316. */
  69317. static readonly MATERIAL_TriangleFillMode: number;
  69318. /**
  69319. * Returns the wireframe mode
  69320. */
  69321. static readonly MATERIAL_WireFrameFillMode: number;
  69322. /**
  69323. * Returns the point fill mode
  69324. */
  69325. static readonly MATERIAL_PointFillMode: number;
  69326. /**
  69327. * Returns the point list draw mode
  69328. */
  69329. static readonly MATERIAL_PointListDrawMode: number;
  69330. /**
  69331. * Returns the line list draw mode
  69332. */
  69333. static readonly MATERIAL_LineListDrawMode: number;
  69334. /**
  69335. * Returns the line loop draw mode
  69336. */
  69337. static readonly MATERIAL_LineLoopDrawMode: number;
  69338. /**
  69339. * Returns the line strip draw mode
  69340. */
  69341. static readonly MATERIAL_LineStripDrawMode: number;
  69342. /**
  69343. * Returns the triangle strip draw mode
  69344. */
  69345. static readonly MATERIAL_TriangleStripDrawMode: number;
  69346. /**
  69347. * Returns the triangle fan draw mode
  69348. */
  69349. static readonly MATERIAL_TriangleFanDrawMode: number;
  69350. /**
  69351. * Stores the clock-wise side orientation
  69352. */
  69353. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69354. /**
  69355. * Stores the counter clock-wise side orientation
  69356. */
  69357. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69358. /**
  69359. * Nothing
  69360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69361. */
  69362. static readonly ACTION_NothingTrigger: number;
  69363. /**
  69364. * On pick
  69365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69366. */
  69367. static readonly ACTION_OnPickTrigger: number;
  69368. /**
  69369. * On left pick
  69370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69371. */
  69372. static readonly ACTION_OnLeftPickTrigger: number;
  69373. /**
  69374. * On right pick
  69375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69376. */
  69377. static readonly ACTION_OnRightPickTrigger: number;
  69378. /**
  69379. * On center pick
  69380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69381. */
  69382. static readonly ACTION_OnCenterPickTrigger: number;
  69383. /**
  69384. * On pick down
  69385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69386. */
  69387. static readonly ACTION_OnPickDownTrigger: number;
  69388. /**
  69389. * On double pick
  69390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69391. */
  69392. static readonly ACTION_OnDoublePickTrigger: number;
  69393. /**
  69394. * On pick up
  69395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69396. */
  69397. static readonly ACTION_OnPickUpTrigger: number;
  69398. /**
  69399. * On pick out.
  69400. * This trigger will only be raised if you also declared a OnPickDown
  69401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69402. */
  69403. static readonly ACTION_OnPickOutTrigger: number;
  69404. /**
  69405. * On long press
  69406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69407. */
  69408. static readonly ACTION_OnLongPressTrigger: number;
  69409. /**
  69410. * On pointer over
  69411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69412. */
  69413. static readonly ACTION_OnPointerOverTrigger: number;
  69414. /**
  69415. * On pointer out
  69416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69417. */
  69418. static readonly ACTION_OnPointerOutTrigger: number;
  69419. /**
  69420. * On every frame
  69421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69422. */
  69423. static readonly ACTION_OnEveryFrameTrigger: number;
  69424. /**
  69425. * On intersection enter
  69426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69427. */
  69428. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69429. /**
  69430. * On intersection exit
  69431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69432. */
  69433. static readonly ACTION_OnIntersectionExitTrigger: number;
  69434. /**
  69435. * On key down
  69436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69437. */
  69438. static readonly ACTION_OnKeyDownTrigger: number;
  69439. /**
  69440. * On key up
  69441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69442. */
  69443. static readonly ACTION_OnKeyUpTrigger: number;
  69444. /**
  69445. * Billboard mode will only apply to Y axis
  69446. */
  69447. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69448. /**
  69449. * Billboard mode will apply to all axes
  69450. */
  69451. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69452. /**
  69453. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69454. */
  69455. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69456. /**
  69457. * Gets or sets base Assets URL
  69458. */
  69459. static PARTICLES_BaseAssetsUrl: string;
  69460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69461. * Test order :
  69462. * Is the bounding sphere outside the frustum ?
  69463. * If not, are the bounding box vertices outside the frustum ?
  69464. * It not, then the cullable object is in the frustum.
  69465. */
  69466. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69467. /** Culling strategy : Bounding Sphere Only.
  69468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69469. * It's also less accurate than the standard because some not visible objects can still be selected.
  69470. * Test : is the bounding sphere outside the frustum ?
  69471. * If not, then the cullable object is in the frustum.
  69472. */
  69473. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69474. /** Culling strategy : Optimistic Inclusion.
  69475. * This in an inclusion test first, then the standard exclusion test.
  69476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69477. * 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.
  69478. * Anyway, it's as accurate as the standard strategy.
  69479. * Test :
  69480. * Is the cullable object bounding sphere center in the frustum ?
  69481. * If not, apply the default culling strategy.
  69482. */
  69483. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69487. * 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.
  69488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69489. * Test :
  69490. * Is the cullable object bounding sphere center in the frustum ?
  69491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69492. */
  69493. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69494. /**
  69495. * No logging while loading
  69496. */
  69497. static readonly SCENELOADER_NO_LOGGING: number;
  69498. /**
  69499. * Minimal logging while loading
  69500. */
  69501. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69502. /**
  69503. * Summary logging while loading
  69504. */
  69505. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69506. /**
  69507. * Detailled logging while loading
  69508. */
  69509. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69510. }
  69511. }
  69512. declare module BABYLON {
  69513. /**
  69514. * Class used to store and describe the pipeline context associated with an effect
  69515. */
  69516. export interface IPipelineContext {
  69517. /**
  69518. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69519. */
  69520. isAsync: boolean;
  69521. /**
  69522. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69523. */
  69524. isReady: boolean;
  69525. /** @hidden */
  69526. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69527. }
  69528. }
  69529. declare module BABYLON {
  69530. /** @hidden */
  69531. export interface IShaderProcessor {
  69532. attributeProcessor?: (attribute: string) => string;
  69533. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69534. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69535. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69536. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69537. lineProcessor?: (line: string, isFragment: boolean) => string;
  69538. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69539. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69540. }
  69541. }
  69542. declare module BABYLON {
  69543. /** @hidden */
  69544. export interface ProcessingOptions {
  69545. defines: string[];
  69546. indexParameters: any;
  69547. isFragment: boolean;
  69548. shouldUseHighPrecisionShader: boolean;
  69549. supportsUniformBuffers: boolean;
  69550. shadersRepository: string;
  69551. includesShadersStore: {
  69552. [key: string]: string;
  69553. };
  69554. processor?: IShaderProcessor;
  69555. version: string;
  69556. platformName: string;
  69557. lookForClosingBracketForUniformBuffer?: boolean;
  69558. }
  69559. }
  69560. declare module BABYLON {
  69561. /**
  69562. * Helper to manipulate strings
  69563. */
  69564. export class StringTools {
  69565. /**
  69566. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69567. * @param str Source string
  69568. * @param suffix Suffix to search for in the source string
  69569. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69570. */
  69571. static EndsWith(str: string, suffix: string): boolean;
  69572. /**
  69573. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69574. * @param str Source string
  69575. * @param suffix Suffix to search for in the source string
  69576. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69577. */
  69578. static StartsWith(str: string, suffix: string): boolean;
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /** @hidden */
  69583. export class ShaderCodeNode {
  69584. line: string;
  69585. children: ShaderCodeNode[];
  69586. additionalDefineKey?: string;
  69587. additionalDefineValue?: string;
  69588. isValid(preprocessors: {
  69589. [key: string]: string;
  69590. }): boolean;
  69591. process(preprocessors: {
  69592. [key: string]: string;
  69593. }, options: ProcessingOptions): string;
  69594. }
  69595. }
  69596. declare module BABYLON {
  69597. /** @hidden */
  69598. export class ShaderCodeCursor {
  69599. private _lines;
  69600. lineIndex: number;
  69601. readonly currentLine: string;
  69602. readonly canRead: boolean;
  69603. lines: string[];
  69604. }
  69605. }
  69606. declare module BABYLON {
  69607. /** @hidden */
  69608. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69609. process(preprocessors: {
  69610. [key: string]: string;
  69611. }, options: ProcessingOptions): string;
  69612. }
  69613. }
  69614. declare module BABYLON {
  69615. /** @hidden */
  69616. export class ShaderDefineExpression {
  69617. isTrue(preprocessors: {
  69618. [key: string]: string;
  69619. }): boolean;
  69620. }
  69621. }
  69622. declare module BABYLON {
  69623. /** @hidden */
  69624. export class ShaderCodeTestNode extends ShaderCodeNode {
  69625. testExpression: ShaderDefineExpression;
  69626. isValid(preprocessors: {
  69627. [key: string]: string;
  69628. }): boolean;
  69629. }
  69630. }
  69631. declare module BABYLON {
  69632. /** @hidden */
  69633. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69634. define: string;
  69635. not: boolean;
  69636. constructor(define: string, not?: boolean);
  69637. isTrue(preprocessors: {
  69638. [key: string]: string;
  69639. }): boolean;
  69640. }
  69641. }
  69642. declare module BABYLON {
  69643. /** @hidden */
  69644. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69645. leftOperand: ShaderDefineExpression;
  69646. rightOperand: ShaderDefineExpression;
  69647. isTrue(preprocessors: {
  69648. [key: string]: string;
  69649. }): boolean;
  69650. }
  69651. }
  69652. declare module BABYLON {
  69653. /** @hidden */
  69654. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69655. leftOperand: ShaderDefineExpression;
  69656. rightOperand: ShaderDefineExpression;
  69657. isTrue(preprocessors: {
  69658. [key: string]: string;
  69659. }): boolean;
  69660. }
  69661. }
  69662. declare module BABYLON {
  69663. /** @hidden */
  69664. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69665. define: string;
  69666. operand: string;
  69667. testValue: string;
  69668. constructor(define: string, operand: string, testValue: string);
  69669. isTrue(preprocessors: {
  69670. [key: string]: string;
  69671. }): boolean;
  69672. }
  69673. }
  69674. declare module BABYLON {
  69675. /**
  69676. * @ignore
  69677. * Application error to support additional information when loading a file
  69678. */
  69679. export class LoadFileError extends Error {
  69680. /** defines the optional web request */
  69681. request?: WebRequest | undefined;
  69682. private static _setPrototypeOf;
  69683. /**
  69684. * Creates a new LoadFileError
  69685. * @param message defines the message of the error
  69686. * @param request defines the optional web request
  69687. */
  69688. constructor(message: string,
  69689. /** defines the optional web request */
  69690. request?: WebRequest | undefined);
  69691. }
  69692. }
  69693. declare module BABYLON {
  69694. /**
  69695. * Class used to enable access to offline support
  69696. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69697. */
  69698. export interface IOfflineProvider {
  69699. /**
  69700. * Gets a boolean indicating if scene must be saved in the database
  69701. */
  69702. enableSceneOffline: boolean;
  69703. /**
  69704. * Gets a boolean indicating if textures must be saved in the database
  69705. */
  69706. enableTexturesOffline: boolean;
  69707. /**
  69708. * Open the offline support and make it available
  69709. * @param successCallback defines the callback to call on success
  69710. * @param errorCallback defines the callback to call on error
  69711. */
  69712. open(successCallback: () => void, errorCallback: () => void): void;
  69713. /**
  69714. * Loads an image from the offline support
  69715. * @param url defines the url to load from
  69716. * @param image defines the target DOM image
  69717. */
  69718. loadImage(url: string, image: HTMLImageElement): void;
  69719. /**
  69720. * Loads a file from offline support
  69721. * @param url defines the URL to load from
  69722. * @param sceneLoaded defines a callback to call on success
  69723. * @param progressCallBack defines a callback to call when progress changed
  69724. * @param errorCallback defines a callback to call on error
  69725. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69726. */
  69727. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69728. }
  69729. }
  69730. declare module BABYLON {
  69731. /**
  69732. * Class used to help managing file picking and drag'n'drop
  69733. * File Storage
  69734. */
  69735. export class FilesInputStore {
  69736. /**
  69737. * List of files ready to be loaded
  69738. */
  69739. static FilesToLoad: {
  69740. [key: string]: File;
  69741. };
  69742. }
  69743. }
  69744. declare module BABYLON {
  69745. /**
  69746. * Class used to define a retry strategy when error happens while loading assets
  69747. */
  69748. export class RetryStrategy {
  69749. /**
  69750. * Function used to defines an exponential back off strategy
  69751. * @param maxRetries defines the maximum number of retries (3 by default)
  69752. * @param baseInterval defines the interval between retries
  69753. * @returns the strategy function to use
  69754. */
  69755. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69756. }
  69757. }
  69758. declare module BABYLON {
  69759. /**
  69760. * @hidden
  69761. */
  69762. export class FileTools {
  69763. /**
  69764. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69765. */
  69766. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69767. /**
  69768. * Gets or sets the base URL to use to load assets
  69769. */
  69770. static BaseUrl: string;
  69771. /**
  69772. * Default behaviour for cors in the application.
  69773. * It can be a string if the expected behavior is identical in the entire app.
  69774. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69775. */
  69776. static CorsBehavior: string | ((url: string | string[]) => string);
  69777. /**
  69778. * Gets or sets a function used to pre-process url before using them to load assets
  69779. */
  69780. static PreprocessUrl: (url: string) => string;
  69781. /**
  69782. * Removes unwanted characters from an url
  69783. * @param url defines the url to clean
  69784. * @returns the cleaned url
  69785. */
  69786. private static _CleanUrl;
  69787. /**
  69788. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69789. * @param url define the url we are trying
  69790. * @param element define the dom element where to configure the cors policy
  69791. */
  69792. static SetCorsBehavior(url: string | string[], element: {
  69793. crossOrigin: string | null;
  69794. }): void;
  69795. /**
  69796. * Loads an image as an HTMLImageElement.
  69797. * @param input url string, ArrayBuffer, or Blob to load
  69798. * @param onLoad callback called when the image successfully loads
  69799. * @param onError callback called when the image fails to load
  69800. * @param offlineProvider offline provider for caching
  69801. * @returns the HTMLImageElement of the loaded image
  69802. */
  69803. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69804. /**
  69805. * Loads a file
  69806. * @param fileToLoad defines the file to load
  69807. * @param callback defines the callback to call when data is loaded
  69808. * @param progressCallBack defines the callback to call during loading process
  69809. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69810. * @returns a file request object
  69811. */
  69812. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69813. /**
  69814. * Loads a file
  69815. * @param url url string, ArrayBuffer, or Blob to load
  69816. * @param onSuccess callback called when the file successfully loads
  69817. * @param onProgress callback called while file is loading (if the server supports this mode)
  69818. * @param offlineProvider defines the offline provider for caching
  69819. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69820. * @param onError callback called when the file fails to load
  69821. * @returns a file request object
  69822. */
  69823. 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;
  69824. /**
  69825. * Checks if the loaded document was accessed via `file:`-Protocol.
  69826. * @returns boolean
  69827. */
  69828. static IsFileURL(): boolean;
  69829. }
  69830. }
  69831. declare module BABYLON {
  69832. /** @hidden */
  69833. export class ShaderProcessor {
  69834. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69835. private static _ProcessPrecision;
  69836. private static _ExtractOperation;
  69837. private static _BuildSubExpression;
  69838. private static _BuildExpression;
  69839. private static _MoveCursorWithinIf;
  69840. private static _MoveCursor;
  69841. private static _EvaluatePreProcessors;
  69842. private static _PreparePreProcessors;
  69843. private static _ProcessShaderConversion;
  69844. private static _ProcessIncludes;
  69845. }
  69846. }
  69847. declare module BABYLON {
  69848. /**
  69849. * Class used to hold a RBG color
  69850. */
  69851. export class Color3 {
  69852. /**
  69853. * Defines the red component (between 0 and 1, default is 0)
  69854. */
  69855. r: number;
  69856. /**
  69857. * Defines the green component (between 0 and 1, default is 0)
  69858. */
  69859. g: number;
  69860. /**
  69861. * Defines the blue component (between 0 and 1, default is 0)
  69862. */
  69863. b: number;
  69864. /**
  69865. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69866. * @param r defines the red component (between 0 and 1, default is 0)
  69867. * @param g defines the green component (between 0 and 1, default is 0)
  69868. * @param b defines the blue component (between 0 and 1, default is 0)
  69869. */
  69870. constructor(
  69871. /**
  69872. * Defines the red component (between 0 and 1, default is 0)
  69873. */
  69874. r?: number,
  69875. /**
  69876. * Defines the green component (between 0 and 1, default is 0)
  69877. */
  69878. g?: number,
  69879. /**
  69880. * Defines the blue component (between 0 and 1, default is 0)
  69881. */
  69882. b?: number);
  69883. /**
  69884. * Creates a string with the Color3 current values
  69885. * @returns the string representation of the Color3 object
  69886. */
  69887. toString(): string;
  69888. /**
  69889. * Returns the string "Color3"
  69890. * @returns "Color3"
  69891. */
  69892. getClassName(): string;
  69893. /**
  69894. * Compute the Color3 hash code
  69895. * @returns an unique number that can be used to hash Color3 objects
  69896. */
  69897. getHashCode(): number;
  69898. /**
  69899. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69900. * @param array defines the array where to store the r,g,b components
  69901. * @param index defines an optional index in the target array to define where to start storing values
  69902. * @returns the current Color3 object
  69903. */
  69904. toArray(array: FloatArray, index?: number): Color3;
  69905. /**
  69906. * Returns a new Color4 object from the current Color3 and the given alpha
  69907. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69908. * @returns a new Color4 object
  69909. */
  69910. toColor4(alpha?: number): Color4;
  69911. /**
  69912. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69913. * @returns the new array
  69914. */
  69915. asArray(): number[];
  69916. /**
  69917. * Returns the luminance value
  69918. * @returns a float value
  69919. */
  69920. toLuminance(): number;
  69921. /**
  69922. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69923. * @param otherColor defines the second operand
  69924. * @returns the new Color3 object
  69925. */
  69926. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69927. /**
  69928. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69929. * @param otherColor defines the second operand
  69930. * @param result defines the Color3 object where to store the result
  69931. * @returns the current Color3
  69932. */
  69933. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69934. /**
  69935. * Determines equality between Color3 objects
  69936. * @param otherColor defines the second operand
  69937. * @returns true if the rgb values are equal to the given ones
  69938. */
  69939. equals(otherColor: DeepImmutable<Color3>): boolean;
  69940. /**
  69941. * Determines equality between the current Color3 object and a set of r,b,g values
  69942. * @param r defines the red component to check
  69943. * @param g defines the green component to check
  69944. * @param b defines the blue component to check
  69945. * @returns true if the rgb values are equal to the given ones
  69946. */
  69947. equalsFloats(r: number, g: number, b: number): boolean;
  69948. /**
  69949. * Multiplies in place each rgb value by scale
  69950. * @param scale defines the scaling factor
  69951. * @returns the updated Color3
  69952. */
  69953. scale(scale: number): Color3;
  69954. /**
  69955. * Multiplies the rgb values by scale and stores the result into "result"
  69956. * @param scale defines the scaling factor
  69957. * @param result defines the Color3 object where to store the result
  69958. * @returns the unmodified current Color3
  69959. */
  69960. scaleToRef(scale: number, result: Color3): Color3;
  69961. /**
  69962. * Scale the current Color3 values by a factor and add the result to a given Color3
  69963. * @param scale defines the scale factor
  69964. * @param result defines color to store the result into
  69965. * @returns the unmodified current Color3
  69966. */
  69967. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69968. /**
  69969. * Clamps the rgb values by the min and max values and stores the result into "result"
  69970. * @param min defines minimum clamping value (default is 0)
  69971. * @param max defines maximum clamping value (default is 1)
  69972. * @param result defines color to store the result into
  69973. * @returns the original Color3
  69974. */
  69975. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69976. /**
  69977. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69978. * @param otherColor defines the second operand
  69979. * @returns the new Color3
  69980. */
  69981. add(otherColor: DeepImmutable<Color3>): Color3;
  69982. /**
  69983. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69984. * @param otherColor defines the second operand
  69985. * @param result defines Color3 object to store the result into
  69986. * @returns the unmodified current Color3
  69987. */
  69988. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69989. /**
  69990. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69991. * @param otherColor defines the second operand
  69992. * @returns the new Color3
  69993. */
  69994. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69995. /**
  69996. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69997. * @param otherColor defines the second operand
  69998. * @param result defines Color3 object to store the result into
  69999. * @returns the unmodified current Color3
  70000. */
  70001. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70002. /**
  70003. * Copy the current object
  70004. * @returns a new Color3 copied the current one
  70005. */
  70006. clone(): Color3;
  70007. /**
  70008. * Copies the rgb values from the source in the current Color3
  70009. * @param source defines the source Color3 object
  70010. * @returns the updated Color3 object
  70011. */
  70012. copyFrom(source: DeepImmutable<Color3>): Color3;
  70013. /**
  70014. * Updates the Color3 rgb values from the given floats
  70015. * @param r defines the red component to read from
  70016. * @param g defines the green component to read from
  70017. * @param b defines the blue component to read from
  70018. * @returns the current Color3 object
  70019. */
  70020. copyFromFloats(r: number, g: number, b: number): Color3;
  70021. /**
  70022. * Updates the Color3 rgb values from the given floats
  70023. * @param r defines the red component to read from
  70024. * @param g defines the green component to read from
  70025. * @param b defines the blue component to read from
  70026. * @returns the current Color3 object
  70027. */
  70028. set(r: number, g: number, b: number): Color3;
  70029. /**
  70030. * Compute the Color3 hexadecimal code as a string
  70031. * @returns a string containing the hexadecimal representation of the Color3 object
  70032. */
  70033. toHexString(): string;
  70034. /**
  70035. * Computes a new Color3 converted from the current one to linear space
  70036. * @returns a new Color3 object
  70037. */
  70038. toLinearSpace(): Color3;
  70039. /**
  70040. * Converts current color in rgb space to HSV values
  70041. * @returns a new color3 representing the HSV values
  70042. */
  70043. toHSV(): Color3;
  70044. /**
  70045. * Converts current color in rgb space to HSV values
  70046. * @param result defines the Color3 where to store the HSV values
  70047. */
  70048. toHSVToRef(result: Color3): void;
  70049. /**
  70050. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70051. * @param convertedColor defines the Color3 object where to store the linear space version
  70052. * @returns the unmodified Color3
  70053. */
  70054. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70055. /**
  70056. * Computes a new Color3 converted from the current one to gamma space
  70057. * @returns a new Color3 object
  70058. */
  70059. toGammaSpace(): Color3;
  70060. /**
  70061. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70062. * @param convertedColor defines the Color3 object where to store the gamma space version
  70063. * @returns the unmodified Color3
  70064. */
  70065. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70066. private static _BlackReadOnly;
  70067. /**
  70068. * Convert Hue, saturation and value to a Color3 (RGB)
  70069. * @param hue defines the hue
  70070. * @param saturation defines the saturation
  70071. * @param value defines the value
  70072. * @param result defines the Color3 where to store the RGB values
  70073. */
  70074. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70075. /**
  70076. * Creates a new Color3 from the string containing valid hexadecimal values
  70077. * @param hex defines a string containing valid hexadecimal values
  70078. * @returns a new Color3 object
  70079. */
  70080. static FromHexString(hex: string): Color3;
  70081. /**
  70082. * Creates a new Color3 from the starting index of the given array
  70083. * @param array defines the source array
  70084. * @param offset defines an offset in the source array
  70085. * @returns a new Color3 object
  70086. */
  70087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70088. /**
  70089. * Creates a new Color3 from integer values (< 256)
  70090. * @param r defines the red component to read from (value between 0 and 255)
  70091. * @param g defines the green component to read from (value between 0 and 255)
  70092. * @param b defines the blue component to read from (value between 0 and 255)
  70093. * @returns a new Color3 object
  70094. */
  70095. static FromInts(r: number, g: number, b: number): Color3;
  70096. /**
  70097. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70098. * @param start defines the start Color3 value
  70099. * @param end defines the end Color3 value
  70100. * @param amount defines the gradient value between start and end
  70101. * @returns a new Color3 object
  70102. */
  70103. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70104. /**
  70105. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70106. * @param left defines the start value
  70107. * @param right defines the end value
  70108. * @param amount defines the gradient factor
  70109. * @param result defines the Color3 object where to store the result
  70110. */
  70111. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70112. /**
  70113. * Returns a Color3 value containing a red color
  70114. * @returns a new Color3 object
  70115. */
  70116. static Red(): Color3;
  70117. /**
  70118. * Returns a Color3 value containing a green color
  70119. * @returns a new Color3 object
  70120. */
  70121. static Green(): Color3;
  70122. /**
  70123. * Returns a Color3 value containing a blue color
  70124. * @returns a new Color3 object
  70125. */
  70126. static Blue(): Color3;
  70127. /**
  70128. * Returns a Color3 value containing a black color
  70129. * @returns a new Color3 object
  70130. */
  70131. static Black(): Color3;
  70132. /**
  70133. * Gets a Color3 value containing a black color that must not be updated
  70134. */
  70135. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70136. /**
  70137. * Returns a Color3 value containing a white color
  70138. * @returns a new Color3 object
  70139. */
  70140. static White(): Color3;
  70141. /**
  70142. * Returns a Color3 value containing a purple color
  70143. * @returns a new Color3 object
  70144. */
  70145. static Purple(): Color3;
  70146. /**
  70147. * Returns a Color3 value containing a magenta color
  70148. * @returns a new Color3 object
  70149. */
  70150. static Magenta(): Color3;
  70151. /**
  70152. * Returns a Color3 value containing a yellow color
  70153. * @returns a new Color3 object
  70154. */
  70155. static Yellow(): Color3;
  70156. /**
  70157. * Returns a Color3 value containing a gray color
  70158. * @returns a new Color3 object
  70159. */
  70160. static Gray(): Color3;
  70161. /**
  70162. * Returns a Color3 value containing a teal color
  70163. * @returns a new Color3 object
  70164. */
  70165. static Teal(): Color3;
  70166. /**
  70167. * Returns a Color3 value containing a random color
  70168. * @returns a new Color3 object
  70169. */
  70170. static Random(): Color3;
  70171. }
  70172. /**
  70173. * Class used to hold a RBGA color
  70174. */
  70175. export class Color4 {
  70176. /**
  70177. * Defines the red component (between 0 and 1, default is 0)
  70178. */
  70179. r: number;
  70180. /**
  70181. * Defines the green component (between 0 and 1, default is 0)
  70182. */
  70183. g: number;
  70184. /**
  70185. * Defines the blue component (between 0 and 1, default is 0)
  70186. */
  70187. b: number;
  70188. /**
  70189. * Defines the alpha component (between 0 and 1, default is 1)
  70190. */
  70191. a: number;
  70192. /**
  70193. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70194. * @param r defines the red component (between 0 and 1, default is 0)
  70195. * @param g defines the green component (between 0 and 1, default is 0)
  70196. * @param b defines the blue component (between 0 and 1, default is 0)
  70197. * @param a defines the alpha component (between 0 and 1, default is 1)
  70198. */
  70199. constructor(
  70200. /**
  70201. * Defines the red component (between 0 and 1, default is 0)
  70202. */
  70203. r?: number,
  70204. /**
  70205. * Defines the green component (between 0 and 1, default is 0)
  70206. */
  70207. g?: number,
  70208. /**
  70209. * Defines the blue component (between 0 and 1, default is 0)
  70210. */
  70211. b?: number,
  70212. /**
  70213. * Defines the alpha component (between 0 and 1, default is 1)
  70214. */
  70215. a?: number);
  70216. /**
  70217. * Adds in place the given Color4 values to the current Color4 object
  70218. * @param right defines the second operand
  70219. * @returns the current updated Color4 object
  70220. */
  70221. addInPlace(right: DeepImmutable<Color4>): Color4;
  70222. /**
  70223. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70224. * @returns the new array
  70225. */
  70226. asArray(): number[];
  70227. /**
  70228. * Stores from the starting index in the given array the Color4 successive values
  70229. * @param array defines the array where to store the r,g,b components
  70230. * @param index defines an optional index in the target array to define where to start storing values
  70231. * @returns the current Color4 object
  70232. */
  70233. toArray(array: number[], index?: number): Color4;
  70234. /**
  70235. * Determines equality between Color4 objects
  70236. * @param otherColor defines the second operand
  70237. * @returns true if the rgba values are equal to the given ones
  70238. */
  70239. equals(otherColor: DeepImmutable<Color4>): boolean;
  70240. /**
  70241. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70242. * @param right defines the second operand
  70243. * @returns a new Color4 object
  70244. */
  70245. add(right: DeepImmutable<Color4>): Color4;
  70246. /**
  70247. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70248. * @param right defines the second operand
  70249. * @returns a new Color4 object
  70250. */
  70251. subtract(right: DeepImmutable<Color4>): Color4;
  70252. /**
  70253. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70254. * @param right defines the second operand
  70255. * @param result defines the Color4 object where to store the result
  70256. * @returns the current Color4 object
  70257. */
  70258. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70259. /**
  70260. * Creates a new Color4 with the current Color4 values multiplied by scale
  70261. * @param scale defines the scaling factor to apply
  70262. * @returns a new Color4 object
  70263. */
  70264. scale(scale: number): Color4;
  70265. /**
  70266. * Multiplies the current Color4 values by scale and stores the result in "result"
  70267. * @param scale defines the scaling factor to apply
  70268. * @param result defines the Color4 object where to store the result
  70269. * @returns the current unmodified Color4
  70270. */
  70271. scaleToRef(scale: number, result: Color4): Color4;
  70272. /**
  70273. * Scale the current Color4 values by a factor and add the result to a given Color4
  70274. * @param scale defines the scale factor
  70275. * @param result defines the Color4 object where to store the result
  70276. * @returns the unmodified current Color4
  70277. */
  70278. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70279. /**
  70280. * Clamps the rgb values by the min and max values and stores the result into "result"
  70281. * @param min defines minimum clamping value (default is 0)
  70282. * @param max defines maximum clamping value (default is 1)
  70283. * @param result defines color to store the result into.
  70284. * @returns the cuurent Color4
  70285. */
  70286. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70287. /**
  70288. * Multipy an Color4 value by another and return a new Color4 object
  70289. * @param color defines the Color4 value to multiply by
  70290. * @returns a new Color4 object
  70291. */
  70292. multiply(color: Color4): Color4;
  70293. /**
  70294. * Multipy a Color4 value by another and push the result in a reference value
  70295. * @param color defines the Color4 value to multiply by
  70296. * @param result defines the Color4 to fill the result in
  70297. * @returns the result Color4
  70298. */
  70299. multiplyToRef(color: Color4, result: Color4): Color4;
  70300. /**
  70301. * Creates a string with the Color4 current values
  70302. * @returns the string representation of the Color4 object
  70303. */
  70304. toString(): string;
  70305. /**
  70306. * Returns the string "Color4"
  70307. * @returns "Color4"
  70308. */
  70309. getClassName(): string;
  70310. /**
  70311. * Compute the Color4 hash code
  70312. * @returns an unique number that can be used to hash Color4 objects
  70313. */
  70314. getHashCode(): number;
  70315. /**
  70316. * Creates a new Color4 copied from the current one
  70317. * @returns a new Color4 object
  70318. */
  70319. clone(): Color4;
  70320. /**
  70321. * Copies the given Color4 values into the current one
  70322. * @param source defines the source Color4 object
  70323. * @returns the current updated Color4 object
  70324. */
  70325. copyFrom(source: Color4): Color4;
  70326. /**
  70327. * Copies the given float values into the current one
  70328. * @param r defines the red component to read from
  70329. * @param g defines the green component to read from
  70330. * @param b defines the blue component to read from
  70331. * @param a defines the alpha component to read from
  70332. * @returns the current updated Color4 object
  70333. */
  70334. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70335. /**
  70336. * Copies the given float values into the current one
  70337. * @param r defines the red component to read from
  70338. * @param g defines the green component to read from
  70339. * @param b defines the blue component to read from
  70340. * @param a defines the alpha component to read from
  70341. * @returns the current updated Color4 object
  70342. */
  70343. set(r: number, g: number, b: number, a: number): Color4;
  70344. /**
  70345. * Compute the Color4 hexadecimal code as a string
  70346. * @returns a string containing the hexadecimal representation of the Color4 object
  70347. */
  70348. toHexString(): string;
  70349. /**
  70350. * Computes a new Color4 converted from the current one to linear space
  70351. * @returns a new Color4 object
  70352. */
  70353. toLinearSpace(): Color4;
  70354. /**
  70355. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70356. * @param convertedColor defines the Color4 object where to store the linear space version
  70357. * @returns the unmodified Color4
  70358. */
  70359. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70360. /**
  70361. * Computes a new Color4 converted from the current one to gamma space
  70362. * @returns a new Color4 object
  70363. */
  70364. toGammaSpace(): Color4;
  70365. /**
  70366. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70367. * @param convertedColor defines the Color4 object where to store the gamma space version
  70368. * @returns the unmodified Color4
  70369. */
  70370. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70371. /**
  70372. * Creates a new Color4 from the string containing valid hexadecimal values
  70373. * @param hex defines a string containing valid hexadecimal values
  70374. * @returns a new Color4 object
  70375. */
  70376. static FromHexString(hex: string): Color4;
  70377. /**
  70378. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70379. * @param left defines the start value
  70380. * @param right defines the end value
  70381. * @param amount defines the gradient factor
  70382. * @returns a new Color4 object
  70383. */
  70384. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70385. /**
  70386. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70387. * @param left defines the start value
  70388. * @param right defines the end value
  70389. * @param amount defines the gradient factor
  70390. * @param result defines the Color4 object where to store data
  70391. */
  70392. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70393. /**
  70394. * Creates a new Color4 from a Color3 and an alpha value
  70395. * @param color3 defines the source Color3 to read from
  70396. * @param alpha defines the alpha component (1.0 by default)
  70397. * @returns a new Color4 object
  70398. */
  70399. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70400. /**
  70401. * Creates a new Color4 from the starting index element of the given array
  70402. * @param array defines the source array to read from
  70403. * @param offset defines the offset in the source array
  70404. * @returns a new Color4 object
  70405. */
  70406. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70407. /**
  70408. * Creates a new Color3 from integer values (< 256)
  70409. * @param r defines the red component to read from (value between 0 and 255)
  70410. * @param g defines the green component to read from (value between 0 and 255)
  70411. * @param b defines the blue component to read from (value between 0 and 255)
  70412. * @param a defines the alpha component to read from (value between 0 and 255)
  70413. * @returns a new Color3 object
  70414. */
  70415. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70416. /**
  70417. * Check the content of a given array and convert it to an array containing RGBA data
  70418. * If the original array was already containing count * 4 values then it is returned directly
  70419. * @param colors defines the array to check
  70420. * @param count defines the number of RGBA data to expect
  70421. * @returns an array containing count * 4 values (RGBA)
  70422. */
  70423. static CheckColors4(colors: number[], count: number): number[];
  70424. }
  70425. /**
  70426. * @hidden
  70427. */
  70428. export class TmpColors {
  70429. static Color3: Color3[];
  70430. static Color4: Color4[];
  70431. }
  70432. }
  70433. declare module BABYLON {
  70434. /**
  70435. * Class representing spherical harmonics coefficients to the 3rd degree
  70436. */
  70437. export class SphericalHarmonics {
  70438. /**
  70439. * Defines whether or not the harmonics have been prescaled for rendering.
  70440. */
  70441. preScaled: boolean;
  70442. /**
  70443. * The l0,0 coefficients of the spherical harmonics
  70444. */
  70445. l00: Vector3;
  70446. /**
  70447. * The l1,-1 coefficients of the spherical harmonics
  70448. */
  70449. l1_1: Vector3;
  70450. /**
  70451. * The l1,0 coefficients of the spherical harmonics
  70452. */
  70453. l10: Vector3;
  70454. /**
  70455. * The l1,1 coefficients of the spherical harmonics
  70456. */
  70457. l11: Vector3;
  70458. /**
  70459. * The l2,-2 coefficients of the spherical harmonics
  70460. */
  70461. l2_2: Vector3;
  70462. /**
  70463. * The l2,-1 coefficients of the spherical harmonics
  70464. */
  70465. l2_1: Vector3;
  70466. /**
  70467. * The l2,0 coefficients of the spherical harmonics
  70468. */
  70469. l20: Vector3;
  70470. /**
  70471. * The l2,1 coefficients of the spherical harmonics
  70472. */
  70473. l21: Vector3;
  70474. /**
  70475. * The l2,2 coefficients of the spherical harmonics
  70476. */
  70477. l22: Vector3;
  70478. /**
  70479. * Adds a light to the spherical harmonics
  70480. * @param direction the direction of the light
  70481. * @param color the color of the light
  70482. * @param deltaSolidAngle the delta solid angle of the light
  70483. */
  70484. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70485. /**
  70486. * Scales the spherical harmonics by the given amount
  70487. * @param scale the amount to scale
  70488. */
  70489. scaleInPlace(scale: number): void;
  70490. /**
  70491. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70492. *
  70493. * ```
  70494. * E_lm = A_l * L_lm
  70495. * ```
  70496. *
  70497. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70498. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70499. * the scaling factors are given in equation 9.
  70500. */
  70501. convertIncidentRadianceToIrradiance(): void;
  70502. /**
  70503. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70504. *
  70505. * ```
  70506. * L = (1/pi) * E * rho
  70507. * ```
  70508. *
  70509. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70510. */
  70511. convertIrradianceToLambertianRadiance(): void;
  70512. /**
  70513. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70514. * required operations at run time.
  70515. *
  70516. * This is simply done by scaling back the SH with Ylm constants parameter.
  70517. * The trigonometric part being applied by the shader at run time.
  70518. */
  70519. preScaleForRendering(): void;
  70520. /**
  70521. * Constructs a spherical harmonics from an array.
  70522. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70523. * @returns the spherical harmonics
  70524. */
  70525. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70526. /**
  70527. * Gets the spherical harmonics from polynomial
  70528. * @param polynomial the spherical polynomial
  70529. * @returns the spherical harmonics
  70530. */
  70531. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70532. }
  70533. /**
  70534. * Class representing spherical polynomial coefficients to the 3rd degree
  70535. */
  70536. export class SphericalPolynomial {
  70537. private _harmonics;
  70538. /**
  70539. * The spherical harmonics used to create the polynomials.
  70540. */
  70541. readonly preScaledHarmonics: SphericalHarmonics;
  70542. /**
  70543. * The x coefficients of the spherical polynomial
  70544. */
  70545. x: Vector3;
  70546. /**
  70547. * The y coefficients of the spherical polynomial
  70548. */
  70549. y: Vector3;
  70550. /**
  70551. * The z coefficients of the spherical polynomial
  70552. */
  70553. z: Vector3;
  70554. /**
  70555. * The xx coefficients of the spherical polynomial
  70556. */
  70557. xx: Vector3;
  70558. /**
  70559. * The yy coefficients of the spherical polynomial
  70560. */
  70561. yy: Vector3;
  70562. /**
  70563. * The zz coefficients of the spherical polynomial
  70564. */
  70565. zz: Vector3;
  70566. /**
  70567. * The xy coefficients of the spherical polynomial
  70568. */
  70569. xy: Vector3;
  70570. /**
  70571. * The yz coefficients of the spherical polynomial
  70572. */
  70573. yz: Vector3;
  70574. /**
  70575. * The zx coefficients of the spherical polynomial
  70576. */
  70577. zx: Vector3;
  70578. /**
  70579. * Adds an ambient color to the spherical polynomial
  70580. * @param color the color to add
  70581. */
  70582. addAmbient(color: Color3): void;
  70583. /**
  70584. * Scales the spherical polynomial by the given amount
  70585. * @param scale the amount to scale
  70586. */
  70587. scaleInPlace(scale: number): void;
  70588. /**
  70589. * Gets the spherical polynomial from harmonics
  70590. * @param harmonics the spherical harmonics
  70591. * @returns the spherical polynomial
  70592. */
  70593. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70594. /**
  70595. * Constructs a spherical polynomial from an array.
  70596. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70597. * @returns the spherical polynomial
  70598. */
  70599. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70600. }
  70601. }
  70602. declare module BABYLON {
  70603. /**
  70604. * Define options used to create a render target texture
  70605. */
  70606. export class RenderTargetCreationOptions {
  70607. /**
  70608. * Specifies is mipmaps must be generated
  70609. */
  70610. generateMipMaps?: boolean;
  70611. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70612. generateDepthBuffer?: boolean;
  70613. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70614. generateStencilBuffer?: boolean;
  70615. /** Defines texture type (int by default) */
  70616. type?: number;
  70617. /** Defines sampling mode (trilinear by default) */
  70618. samplingMode?: number;
  70619. /** Defines format (RGBA by default) */
  70620. format?: number;
  70621. }
  70622. }
  70623. declare module BABYLON {
  70624. /**
  70625. * @hidden
  70626. **/
  70627. export class _AlphaState {
  70628. private _isAlphaBlendDirty;
  70629. private _isBlendFunctionParametersDirty;
  70630. private _isBlendEquationParametersDirty;
  70631. private _isBlendConstantsDirty;
  70632. private _alphaBlend;
  70633. private _blendFunctionParameters;
  70634. private _blendEquationParameters;
  70635. private _blendConstants;
  70636. /**
  70637. * Initializes the state.
  70638. */
  70639. constructor();
  70640. readonly isDirty: boolean;
  70641. alphaBlend: boolean;
  70642. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70643. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70644. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70645. reset(): void;
  70646. apply(gl: WebGLRenderingContext): void;
  70647. }
  70648. }
  70649. declare module BABYLON {
  70650. /**
  70651. * @hidden
  70652. **/
  70653. export class _DepthCullingState {
  70654. private _isDepthTestDirty;
  70655. private _isDepthMaskDirty;
  70656. private _isDepthFuncDirty;
  70657. private _isCullFaceDirty;
  70658. private _isCullDirty;
  70659. private _isZOffsetDirty;
  70660. private _isFrontFaceDirty;
  70661. private _depthTest;
  70662. private _depthMask;
  70663. private _depthFunc;
  70664. private _cull;
  70665. private _cullFace;
  70666. private _zOffset;
  70667. private _frontFace;
  70668. /**
  70669. * Initializes the state.
  70670. */
  70671. constructor();
  70672. readonly isDirty: boolean;
  70673. zOffset: number;
  70674. cullFace: Nullable<number>;
  70675. cull: Nullable<boolean>;
  70676. depthFunc: Nullable<number>;
  70677. depthMask: boolean;
  70678. depthTest: boolean;
  70679. frontFace: Nullable<number>;
  70680. reset(): void;
  70681. apply(gl: WebGLRenderingContext): void;
  70682. }
  70683. }
  70684. declare module BABYLON {
  70685. /**
  70686. * @hidden
  70687. **/
  70688. export class _StencilState {
  70689. /** 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 */
  70690. static readonly ALWAYS: number;
  70691. /** Passed to stencilOperation to specify that stencil value must be kept */
  70692. static readonly KEEP: number;
  70693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70694. static readonly REPLACE: number;
  70695. private _isStencilTestDirty;
  70696. private _isStencilMaskDirty;
  70697. private _isStencilFuncDirty;
  70698. private _isStencilOpDirty;
  70699. private _stencilTest;
  70700. private _stencilMask;
  70701. private _stencilFunc;
  70702. private _stencilFuncRef;
  70703. private _stencilFuncMask;
  70704. private _stencilOpStencilFail;
  70705. private _stencilOpDepthFail;
  70706. private _stencilOpStencilDepthPass;
  70707. readonly isDirty: boolean;
  70708. stencilFunc: number;
  70709. stencilFuncRef: number;
  70710. stencilFuncMask: number;
  70711. stencilOpStencilFail: number;
  70712. stencilOpDepthFail: number;
  70713. stencilOpStencilDepthPass: number;
  70714. stencilMask: number;
  70715. stencilTest: boolean;
  70716. constructor();
  70717. reset(): void;
  70718. apply(gl: WebGLRenderingContext): void;
  70719. }
  70720. }
  70721. declare module BABYLON {
  70722. /**
  70723. * @hidden
  70724. **/
  70725. export class _TimeToken {
  70726. _startTimeQuery: Nullable<WebGLQuery>;
  70727. _endTimeQuery: Nullable<WebGLQuery>;
  70728. _timeElapsedQuery: Nullable<WebGLQuery>;
  70729. _timeElapsedQueryEnded: boolean;
  70730. }
  70731. }
  70732. declare module BABYLON {
  70733. /**
  70734. * Class used to evalaute queries containing `and` and `or` operators
  70735. */
  70736. export class AndOrNotEvaluator {
  70737. /**
  70738. * Evaluate a query
  70739. * @param query defines the query to evaluate
  70740. * @param evaluateCallback defines the callback used to filter result
  70741. * @returns true if the query matches
  70742. */
  70743. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70744. private static _HandleParenthesisContent;
  70745. private static _SimplifyNegation;
  70746. }
  70747. }
  70748. declare module BABYLON {
  70749. /**
  70750. * Class used to store custom tags
  70751. */
  70752. export class Tags {
  70753. /**
  70754. * Adds support for tags on the given object
  70755. * @param obj defines the object to use
  70756. */
  70757. static EnableFor(obj: any): void;
  70758. /**
  70759. * Removes tags support
  70760. * @param obj defines the object to use
  70761. */
  70762. static DisableFor(obj: any): void;
  70763. /**
  70764. * Gets a boolean indicating if the given object has tags
  70765. * @param obj defines the object to use
  70766. * @returns a boolean
  70767. */
  70768. static HasTags(obj: any): boolean;
  70769. /**
  70770. * Gets the tags available on a given object
  70771. * @param obj defines the object to use
  70772. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70773. * @returns the tags
  70774. */
  70775. static GetTags(obj: any, asString?: boolean): any;
  70776. /**
  70777. * Adds tags to an object
  70778. * @param obj defines the object to use
  70779. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70780. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70781. */
  70782. static AddTagsTo(obj: any, tagsString: string): void;
  70783. /**
  70784. * @hidden
  70785. */
  70786. static _AddTagTo(obj: any, tag: string): void;
  70787. /**
  70788. * Removes specific tags from a specific object
  70789. * @param obj defines the object to use
  70790. * @param tagsString defines the tags to remove
  70791. */
  70792. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70793. /**
  70794. * @hidden
  70795. */
  70796. static _RemoveTagFrom(obj: any, tag: string): void;
  70797. /**
  70798. * Defines if tags hosted on an object match a given query
  70799. * @param obj defines the object to use
  70800. * @param tagsQuery defines the tag query
  70801. * @returns a boolean
  70802. */
  70803. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70804. }
  70805. }
  70806. declare module BABYLON {
  70807. /**
  70808. * Defines potential orientation for back face culling
  70809. */
  70810. export enum Orientation {
  70811. /**
  70812. * Clockwise
  70813. */
  70814. CW = 0,
  70815. /** Counter clockwise */
  70816. CCW = 1
  70817. }
  70818. /** Class used to represent a Bezier curve */
  70819. export class BezierCurve {
  70820. /**
  70821. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70822. * @param t defines the time
  70823. * @param x1 defines the left coordinate on X axis
  70824. * @param y1 defines the left coordinate on Y axis
  70825. * @param x2 defines the right coordinate on X axis
  70826. * @param y2 defines the right coordinate on Y axis
  70827. * @returns the interpolated value
  70828. */
  70829. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70830. }
  70831. /**
  70832. * Defines angle representation
  70833. */
  70834. export class Angle {
  70835. private _radians;
  70836. /**
  70837. * Creates an Angle object of "radians" radians (float).
  70838. * @param radians the angle in radians
  70839. */
  70840. constructor(radians: number);
  70841. /**
  70842. * Get value in degrees
  70843. * @returns the Angle value in degrees (float)
  70844. */
  70845. degrees(): number;
  70846. /**
  70847. * Get value in radians
  70848. * @returns the Angle value in radians (float)
  70849. */
  70850. radians(): number;
  70851. /**
  70852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70853. * @param a defines first vector
  70854. * @param b defines second vector
  70855. * @returns a new Angle
  70856. */
  70857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70858. /**
  70859. * Gets a new Angle object from the given float in radians
  70860. * @param radians defines the angle value in radians
  70861. * @returns a new Angle
  70862. */
  70863. static FromRadians(radians: number): Angle;
  70864. /**
  70865. * Gets a new Angle object from the given float in degrees
  70866. * @param degrees defines the angle value in degrees
  70867. * @returns a new Angle
  70868. */
  70869. static FromDegrees(degrees: number): Angle;
  70870. }
  70871. /**
  70872. * This represents an arc in a 2d space.
  70873. */
  70874. export class Arc2 {
  70875. /** Defines the start point of the arc */
  70876. startPoint: Vector2;
  70877. /** Defines the mid point of the arc */
  70878. midPoint: Vector2;
  70879. /** Defines the end point of the arc */
  70880. endPoint: Vector2;
  70881. /**
  70882. * Defines the center point of the arc.
  70883. */
  70884. centerPoint: Vector2;
  70885. /**
  70886. * Defines the radius of the arc.
  70887. */
  70888. radius: number;
  70889. /**
  70890. * Defines the angle of the arc (from mid point to end point).
  70891. */
  70892. angle: Angle;
  70893. /**
  70894. * Defines the start angle of the arc (from start point to middle point).
  70895. */
  70896. startAngle: Angle;
  70897. /**
  70898. * Defines the orientation of the arc (clock wise/counter clock wise).
  70899. */
  70900. orientation: Orientation;
  70901. /**
  70902. * Creates an Arc object from the three given points : start, middle and end.
  70903. * @param startPoint Defines the start point of the arc
  70904. * @param midPoint Defines the midlle point of the arc
  70905. * @param endPoint Defines the end point of the arc
  70906. */
  70907. constructor(
  70908. /** Defines the start point of the arc */
  70909. startPoint: Vector2,
  70910. /** Defines the mid point of the arc */
  70911. midPoint: Vector2,
  70912. /** Defines the end point of the arc */
  70913. endPoint: Vector2);
  70914. }
  70915. /**
  70916. * Represents a 2D path made up of multiple 2D points
  70917. */
  70918. export class Path2 {
  70919. private _points;
  70920. private _length;
  70921. /**
  70922. * If the path start and end point are the same
  70923. */
  70924. closed: boolean;
  70925. /**
  70926. * Creates a Path2 object from the starting 2D coordinates x and y.
  70927. * @param x the starting points x value
  70928. * @param y the starting points y value
  70929. */
  70930. constructor(x: number, y: number);
  70931. /**
  70932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70933. * @param x the added points x value
  70934. * @param y the added points y value
  70935. * @returns the updated Path2.
  70936. */
  70937. addLineTo(x: number, y: number): Path2;
  70938. /**
  70939. * 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.
  70940. * @param midX middle point x value
  70941. * @param midY middle point y value
  70942. * @param endX end point x value
  70943. * @param endY end point y value
  70944. * @param numberOfSegments (default: 36)
  70945. * @returns the updated Path2.
  70946. */
  70947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70948. /**
  70949. * Closes the Path2.
  70950. * @returns the Path2.
  70951. */
  70952. close(): Path2;
  70953. /**
  70954. * Gets the sum of the distance between each sequential point in the path
  70955. * @returns the Path2 total length (float).
  70956. */
  70957. length(): number;
  70958. /**
  70959. * Gets the points which construct the path
  70960. * @returns the Path2 internal array of points.
  70961. */
  70962. getPoints(): Vector2[];
  70963. /**
  70964. * Retreives the point at the distance aways from the starting point
  70965. * @param normalizedLengthPosition the length along the path to retreive the point from
  70966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70967. */
  70968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70969. /**
  70970. * Creates a new path starting from an x and y position
  70971. * @param x starting x value
  70972. * @param y starting y value
  70973. * @returns a new Path2 starting at the coordinates (x, y).
  70974. */
  70975. static StartingAt(x: number, y: number): Path2;
  70976. }
  70977. /**
  70978. * Represents a 3D path made up of multiple 3D points
  70979. */
  70980. export class Path3D {
  70981. /**
  70982. * an array of Vector3, the curve axis of the Path3D
  70983. */
  70984. path: Vector3[];
  70985. private _curve;
  70986. private _distances;
  70987. private _tangents;
  70988. private _normals;
  70989. private _binormals;
  70990. private _raw;
  70991. /**
  70992. * new Path3D(path, normal, raw)
  70993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70995. * @param path an array of Vector3, the curve axis of the Path3D
  70996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70998. */
  70999. constructor(
  71000. /**
  71001. * an array of Vector3, the curve axis of the Path3D
  71002. */
  71003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71004. /**
  71005. * Returns the Path3D array of successive Vector3 designing its curve.
  71006. * @returns the Path3D array of successive Vector3 designing its curve.
  71007. */
  71008. getCurve(): Vector3[];
  71009. /**
  71010. * Returns an array populated with tangent vectors on each Path3D curve point.
  71011. * @returns an array populated with tangent vectors on each Path3D curve point.
  71012. */
  71013. getTangents(): Vector3[];
  71014. /**
  71015. * Returns an array populated with normal vectors on each Path3D curve point.
  71016. * @returns an array populated with normal vectors on each Path3D curve point.
  71017. */
  71018. getNormals(): Vector3[];
  71019. /**
  71020. * Returns an array populated with binormal vectors on each Path3D curve point.
  71021. * @returns an array populated with binormal vectors on each Path3D curve point.
  71022. */
  71023. getBinormals(): Vector3[];
  71024. /**
  71025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71027. */
  71028. getDistances(): number[];
  71029. /**
  71030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71031. * @param path path which all values are copied into the curves points
  71032. * @param firstNormal which should be projected onto the curve
  71033. * @returns the same object updated.
  71034. */
  71035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71036. private _compute;
  71037. private _getFirstNonNullVector;
  71038. private _getLastNonNullVector;
  71039. private _normalVector;
  71040. }
  71041. /**
  71042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71043. * A Curve3 is designed from a series of successive Vector3.
  71044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71045. */
  71046. export class Curve3 {
  71047. private _points;
  71048. private _length;
  71049. /**
  71050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71052. * @param v1 (Vector3) the control point
  71053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71054. * @param nbPoints (integer) the wanted number of points in the curve
  71055. * @returns the created Curve3
  71056. */
  71057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71058. /**
  71059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71061. * @param v1 (Vector3) the first control point
  71062. * @param v2 (Vector3) the second control point
  71063. * @param v3 (Vector3) the end point of the Cubic Bezier
  71064. * @param nbPoints (integer) the wanted number of points in the curve
  71065. * @returns the created Curve3
  71066. */
  71067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71068. /**
  71069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71070. * @param p1 (Vector3) the origin point of the Hermite Spline
  71071. * @param t1 (Vector3) the tangent vector at the origin point
  71072. * @param p2 (Vector3) the end point of the Hermite Spline
  71073. * @param t2 (Vector3) the tangent vector at the end point
  71074. * @param nbPoints (integer) the wanted number of points in the curve
  71075. * @returns the created Curve3
  71076. */
  71077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71078. /**
  71079. * Returns a Curve3 object along a CatmullRom Spline curve :
  71080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71081. * @param nbPoints (integer) the wanted number of points between each curve control points
  71082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71083. * @returns the created Curve3
  71084. */
  71085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71086. /**
  71087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71088. * A Curve3 is designed from a series of successive Vector3.
  71089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71090. * @param points points which make up the curve
  71091. */
  71092. constructor(points: Vector3[]);
  71093. /**
  71094. * @returns the Curve3 stored array of successive Vector3
  71095. */
  71096. getPoints(): Vector3[];
  71097. /**
  71098. * @returns the computed length (float) of the curve.
  71099. */
  71100. length(): number;
  71101. /**
  71102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71104. * curveA and curveB keep unchanged.
  71105. * @param curve the curve to continue from this curve
  71106. * @returns the newly constructed curve
  71107. */
  71108. continue(curve: DeepImmutable<Curve3>): Curve3;
  71109. private _computeLength;
  71110. }
  71111. }
  71112. declare module BABYLON {
  71113. /**
  71114. * This represents the main contract an easing function should follow.
  71115. * Easing functions are used throughout the animation system.
  71116. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71117. */
  71118. export interface IEasingFunction {
  71119. /**
  71120. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71121. * of the easing function.
  71122. * The link below provides some of the most common examples of easing functions.
  71123. * @see https://easings.net/
  71124. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71125. * @returns the corresponding value on the curve defined by the easing function
  71126. */
  71127. ease(gradient: number): number;
  71128. }
  71129. /**
  71130. * Base class used for every default easing function.
  71131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71132. */
  71133. export class EasingFunction implements IEasingFunction {
  71134. /**
  71135. * Interpolation follows the mathematical formula associated with the easing function.
  71136. */
  71137. static readonly EASINGMODE_EASEIN: number;
  71138. /**
  71139. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71140. */
  71141. static readonly EASINGMODE_EASEOUT: number;
  71142. /**
  71143. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71144. */
  71145. static readonly EASINGMODE_EASEINOUT: number;
  71146. private _easingMode;
  71147. /**
  71148. * Sets the easing mode of the current function.
  71149. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71150. */
  71151. setEasingMode(easingMode: number): void;
  71152. /**
  71153. * Gets the current easing mode.
  71154. * @returns the easing mode
  71155. */
  71156. getEasingMode(): number;
  71157. /**
  71158. * @hidden
  71159. */
  71160. easeInCore(gradient: number): number;
  71161. /**
  71162. * Given an input gradient between 0 and 1, this returns the corresponding value
  71163. * of the easing function.
  71164. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71165. * @returns the corresponding value on the curve defined by the easing function
  71166. */
  71167. ease(gradient: number): number;
  71168. }
  71169. /**
  71170. * Easing function with a circle shape (see link below).
  71171. * @see https://easings.net/#easeInCirc
  71172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71173. */
  71174. export class CircleEase extends EasingFunction implements IEasingFunction {
  71175. /** @hidden */
  71176. easeInCore(gradient: number): number;
  71177. }
  71178. /**
  71179. * Easing function with a ease back shape (see link below).
  71180. * @see https://easings.net/#easeInBack
  71181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71182. */
  71183. export class BackEase extends EasingFunction implements IEasingFunction {
  71184. /** Defines the amplitude of the function */
  71185. amplitude: number;
  71186. /**
  71187. * Instantiates a back ease easing
  71188. * @see https://easings.net/#easeInBack
  71189. * @param amplitude Defines the amplitude of the function
  71190. */
  71191. constructor(
  71192. /** Defines the amplitude of the function */
  71193. amplitude?: number);
  71194. /** @hidden */
  71195. easeInCore(gradient: number): number;
  71196. }
  71197. /**
  71198. * Easing function with a bouncing shape (see link below).
  71199. * @see https://easings.net/#easeInBounce
  71200. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71201. */
  71202. export class BounceEase extends EasingFunction implements IEasingFunction {
  71203. /** Defines the number of bounces */
  71204. bounces: number;
  71205. /** Defines the amplitude of the bounce */
  71206. bounciness: number;
  71207. /**
  71208. * Instantiates a bounce easing
  71209. * @see https://easings.net/#easeInBounce
  71210. * @param bounces Defines the number of bounces
  71211. * @param bounciness Defines the amplitude of the bounce
  71212. */
  71213. constructor(
  71214. /** Defines the number of bounces */
  71215. bounces?: number,
  71216. /** Defines the amplitude of the bounce */
  71217. bounciness?: number);
  71218. /** @hidden */
  71219. easeInCore(gradient: number): number;
  71220. }
  71221. /**
  71222. * Easing function with a power of 3 shape (see link below).
  71223. * @see https://easings.net/#easeInCubic
  71224. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71225. */
  71226. export class CubicEase extends EasingFunction implements IEasingFunction {
  71227. /** @hidden */
  71228. easeInCore(gradient: number): number;
  71229. }
  71230. /**
  71231. * Easing function with an elastic shape (see link below).
  71232. * @see https://easings.net/#easeInElastic
  71233. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71234. */
  71235. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71236. /** Defines the number of oscillations*/
  71237. oscillations: number;
  71238. /** Defines the amplitude of the oscillations*/
  71239. springiness: number;
  71240. /**
  71241. * Instantiates an elastic easing function
  71242. * @see https://easings.net/#easeInElastic
  71243. * @param oscillations Defines the number of oscillations
  71244. * @param springiness Defines the amplitude of the oscillations
  71245. */
  71246. constructor(
  71247. /** Defines the number of oscillations*/
  71248. oscillations?: number,
  71249. /** Defines the amplitude of the oscillations*/
  71250. springiness?: number);
  71251. /** @hidden */
  71252. easeInCore(gradient: number): number;
  71253. }
  71254. /**
  71255. * Easing function with an exponential shape (see link below).
  71256. * @see https://easings.net/#easeInExpo
  71257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71258. */
  71259. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71260. /** Defines the exponent of the function */
  71261. exponent: number;
  71262. /**
  71263. * Instantiates an exponential easing function
  71264. * @see https://easings.net/#easeInExpo
  71265. * @param exponent Defines the exponent of the function
  71266. */
  71267. constructor(
  71268. /** Defines the exponent of the function */
  71269. exponent?: number);
  71270. /** @hidden */
  71271. easeInCore(gradient: number): number;
  71272. }
  71273. /**
  71274. * Easing function with a power shape (see link below).
  71275. * @see https://easings.net/#easeInQuad
  71276. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71277. */
  71278. export class PowerEase extends EasingFunction implements IEasingFunction {
  71279. /** Defines the power of the function */
  71280. power: number;
  71281. /**
  71282. * Instantiates an power base easing function
  71283. * @see https://easings.net/#easeInQuad
  71284. * @param power Defines the power of the function
  71285. */
  71286. constructor(
  71287. /** Defines the power of the function */
  71288. power?: number);
  71289. /** @hidden */
  71290. easeInCore(gradient: number): number;
  71291. }
  71292. /**
  71293. * Easing function with a power of 2 shape (see link below).
  71294. * @see https://easings.net/#easeInQuad
  71295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71296. */
  71297. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71298. /** @hidden */
  71299. easeInCore(gradient: number): number;
  71300. }
  71301. /**
  71302. * Easing function with a power of 4 shape (see link below).
  71303. * @see https://easings.net/#easeInQuart
  71304. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71305. */
  71306. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71307. /** @hidden */
  71308. easeInCore(gradient: number): number;
  71309. }
  71310. /**
  71311. * Easing function with a power of 5 shape (see link below).
  71312. * @see https://easings.net/#easeInQuint
  71313. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71314. */
  71315. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71316. /** @hidden */
  71317. easeInCore(gradient: number): number;
  71318. }
  71319. /**
  71320. * Easing function with a sin shape (see link below).
  71321. * @see https://easings.net/#easeInSine
  71322. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71323. */
  71324. export class SineEase extends EasingFunction implements IEasingFunction {
  71325. /** @hidden */
  71326. easeInCore(gradient: number): number;
  71327. }
  71328. /**
  71329. * Easing function with a bezier shape (see link below).
  71330. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71331. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71332. */
  71333. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71334. /** Defines the x component of the start tangent in the bezier curve */
  71335. x1: number;
  71336. /** Defines the y component of the start tangent in the bezier curve */
  71337. y1: number;
  71338. /** Defines the x component of the end tangent in the bezier curve */
  71339. x2: number;
  71340. /** Defines the y component of the end tangent in the bezier curve */
  71341. y2: number;
  71342. /**
  71343. * Instantiates a bezier function
  71344. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71345. * @param x1 Defines the x component of the start tangent in the bezier curve
  71346. * @param y1 Defines the y component of the start tangent in the bezier curve
  71347. * @param x2 Defines the x component of the end tangent in the bezier curve
  71348. * @param y2 Defines the y component of the end tangent in the bezier curve
  71349. */
  71350. constructor(
  71351. /** Defines the x component of the start tangent in the bezier curve */
  71352. x1?: number,
  71353. /** Defines the y component of the start tangent in the bezier curve */
  71354. y1?: number,
  71355. /** Defines the x component of the end tangent in the bezier curve */
  71356. x2?: number,
  71357. /** Defines the y component of the end tangent in the bezier curve */
  71358. y2?: number);
  71359. /** @hidden */
  71360. easeInCore(gradient: number): number;
  71361. }
  71362. }
  71363. declare module BABYLON {
  71364. /**
  71365. * Defines an interface which represents an animation key frame
  71366. */
  71367. export interface IAnimationKey {
  71368. /**
  71369. * Frame of the key frame
  71370. */
  71371. frame: number;
  71372. /**
  71373. * Value at the specifies key frame
  71374. */
  71375. value: any;
  71376. /**
  71377. * The input tangent for the cubic hermite spline
  71378. */
  71379. inTangent?: any;
  71380. /**
  71381. * The output tangent for the cubic hermite spline
  71382. */
  71383. outTangent?: any;
  71384. /**
  71385. * The animation interpolation type
  71386. */
  71387. interpolation?: AnimationKeyInterpolation;
  71388. }
  71389. /**
  71390. * Enum for the animation key frame interpolation type
  71391. */
  71392. export enum AnimationKeyInterpolation {
  71393. /**
  71394. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71395. */
  71396. STEP = 1
  71397. }
  71398. }
  71399. declare module BABYLON {
  71400. /**
  71401. * Represents the range of an animation
  71402. */
  71403. export class AnimationRange {
  71404. /**The name of the animation range**/
  71405. name: string;
  71406. /**The starting frame of the animation */
  71407. from: number;
  71408. /**The ending frame of the animation*/
  71409. to: number;
  71410. /**
  71411. * Initializes the range of an animation
  71412. * @param name The name of the animation range
  71413. * @param from The starting frame of the animation
  71414. * @param to The ending frame of the animation
  71415. */
  71416. constructor(
  71417. /**The name of the animation range**/
  71418. name: string,
  71419. /**The starting frame of the animation */
  71420. from: number,
  71421. /**The ending frame of the animation*/
  71422. to: number);
  71423. /**
  71424. * Makes a copy of the animation range
  71425. * @returns A copy of the animation range
  71426. */
  71427. clone(): AnimationRange;
  71428. }
  71429. }
  71430. declare module BABYLON {
  71431. /**
  71432. * Composed of a frame, and an action function
  71433. */
  71434. export class AnimationEvent {
  71435. /** The frame for which the event is triggered **/
  71436. frame: number;
  71437. /** The event to perform when triggered **/
  71438. action: (currentFrame: number) => void;
  71439. /** Specifies if the event should be triggered only once**/
  71440. onlyOnce?: boolean | undefined;
  71441. /**
  71442. * Specifies if the animation event is done
  71443. */
  71444. isDone: boolean;
  71445. /**
  71446. * Initializes the animation event
  71447. * @param frame The frame for which the event is triggered
  71448. * @param action The event to perform when triggered
  71449. * @param onlyOnce Specifies if the event should be triggered only once
  71450. */
  71451. constructor(
  71452. /** The frame for which the event is triggered **/
  71453. frame: number,
  71454. /** The event to perform when triggered **/
  71455. action: (currentFrame: number) => void,
  71456. /** Specifies if the event should be triggered only once**/
  71457. onlyOnce?: boolean | undefined);
  71458. /** @hidden */
  71459. _clone(): AnimationEvent;
  71460. }
  71461. }
  71462. declare module BABYLON {
  71463. /**
  71464. * Interface used to define a behavior
  71465. */
  71466. export interface Behavior<T> {
  71467. /** gets or sets behavior's name */
  71468. name: string;
  71469. /**
  71470. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71471. */
  71472. init(): void;
  71473. /**
  71474. * Called when the behavior is attached to a target
  71475. * @param target defines the target where the behavior is attached to
  71476. */
  71477. attach(target: T): void;
  71478. /**
  71479. * Called when the behavior is detached from its target
  71480. */
  71481. detach(): void;
  71482. }
  71483. /**
  71484. * Interface implemented by classes supporting behaviors
  71485. */
  71486. export interface IBehaviorAware<T> {
  71487. /**
  71488. * Attach a behavior
  71489. * @param behavior defines the behavior to attach
  71490. * @returns the current host
  71491. */
  71492. addBehavior(behavior: Behavior<T>): T;
  71493. /**
  71494. * Remove a behavior from the current object
  71495. * @param behavior defines the behavior to detach
  71496. * @returns the current host
  71497. */
  71498. removeBehavior(behavior: Behavior<T>): T;
  71499. /**
  71500. * Gets a behavior using its name to search
  71501. * @param name defines the name to search
  71502. * @returns the behavior or null if not found
  71503. */
  71504. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71505. }
  71506. }
  71507. declare module BABYLON {
  71508. /**
  71509. * Defines an array and its length.
  71510. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71511. */
  71512. export interface ISmartArrayLike<T> {
  71513. /**
  71514. * The data of the array.
  71515. */
  71516. data: Array<T>;
  71517. /**
  71518. * The active length of the array.
  71519. */
  71520. length: number;
  71521. }
  71522. /**
  71523. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71524. */
  71525. export class SmartArray<T> implements ISmartArrayLike<T> {
  71526. /**
  71527. * The full set of data from the array.
  71528. */
  71529. data: Array<T>;
  71530. /**
  71531. * The active length of the array.
  71532. */
  71533. length: number;
  71534. protected _id: number;
  71535. /**
  71536. * Instantiates a Smart Array.
  71537. * @param capacity defines the default capacity of the array.
  71538. */
  71539. constructor(capacity: number);
  71540. /**
  71541. * Pushes a value at the end of the active data.
  71542. * @param value defines the object to push in the array.
  71543. */
  71544. push(value: T): void;
  71545. /**
  71546. * Iterates over the active data and apply the lambda to them.
  71547. * @param func defines the action to apply on each value.
  71548. */
  71549. forEach(func: (content: T) => void): void;
  71550. /**
  71551. * Sorts the full sets of data.
  71552. * @param compareFn defines the comparison function to apply.
  71553. */
  71554. sort(compareFn: (a: T, b: T) => number): void;
  71555. /**
  71556. * Resets the active data to an empty array.
  71557. */
  71558. reset(): void;
  71559. /**
  71560. * Releases all the data from the array as well as the array.
  71561. */
  71562. dispose(): void;
  71563. /**
  71564. * Concats the active data with a given array.
  71565. * @param array defines the data to concatenate with.
  71566. */
  71567. concat(array: any): void;
  71568. /**
  71569. * Returns the position of a value in the active data.
  71570. * @param value defines the value to find the index for
  71571. * @returns the index if found in the active data otherwise -1
  71572. */
  71573. indexOf(value: T): number;
  71574. /**
  71575. * Returns whether an element is part of the active data.
  71576. * @param value defines the value to look for
  71577. * @returns true if found in the active data otherwise false
  71578. */
  71579. contains(value: T): boolean;
  71580. private static _GlobalId;
  71581. }
  71582. /**
  71583. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71584. * The data in this array can only be present once
  71585. */
  71586. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71587. private _duplicateId;
  71588. /**
  71589. * Pushes a value at the end of the active data.
  71590. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71591. * @param value defines the object to push in the array.
  71592. */
  71593. push(value: T): void;
  71594. /**
  71595. * Pushes a value at the end of the active data.
  71596. * If the data is already present, it won t be added again
  71597. * @param value defines the object to push in the array.
  71598. * @returns true if added false if it was already present
  71599. */
  71600. pushNoDuplicate(value: T): boolean;
  71601. /**
  71602. * Resets the active data to an empty array.
  71603. */
  71604. reset(): void;
  71605. /**
  71606. * Concats the active data with a given array.
  71607. * This ensures no dupplicate will be present in the result.
  71608. * @param array defines the data to concatenate with.
  71609. */
  71610. concatWithNoDuplicate(array: any): void;
  71611. }
  71612. }
  71613. declare module BABYLON {
  71614. /**
  71615. * @ignore
  71616. * This is a list of all the different input types that are available in the application.
  71617. * Fo instance: ArcRotateCameraGamepadInput...
  71618. */
  71619. export var CameraInputTypes: {};
  71620. /**
  71621. * This is the contract to implement in order to create a new input class.
  71622. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71623. */
  71624. export interface ICameraInput<TCamera extends Camera> {
  71625. /**
  71626. * Defines the camera the input is attached to.
  71627. */
  71628. camera: Nullable<TCamera>;
  71629. /**
  71630. * Gets the class name of the current intput.
  71631. * @returns the class name
  71632. */
  71633. getClassName(): string;
  71634. /**
  71635. * Get the friendly name associated with the input class.
  71636. * @returns the input friendly name
  71637. */
  71638. getSimpleName(): string;
  71639. /**
  71640. * Attach the input controls to a specific dom element to get the input from.
  71641. * @param element Defines the element the controls should be listened from
  71642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71643. */
  71644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71645. /**
  71646. * Detach the current controls from the specified dom element.
  71647. * @param element Defines the element to stop listening the inputs from
  71648. */
  71649. detachControl(element: Nullable<HTMLElement>): void;
  71650. /**
  71651. * Update the current camera state depending on the inputs that have been used this frame.
  71652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71653. */
  71654. checkInputs?: () => void;
  71655. }
  71656. /**
  71657. * Represents a map of input types to input instance or input index to input instance.
  71658. */
  71659. export interface CameraInputsMap<TCamera extends Camera> {
  71660. /**
  71661. * Accessor to the input by input type.
  71662. */
  71663. [name: string]: ICameraInput<TCamera>;
  71664. /**
  71665. * Accessor to the input by input index.
  71666. */
  71667. [idx: number]: ICameraInput<TCamera>;
  71668. }
  71669. /**
  71670. * This represents the input manager used within a camera.
  71671. * It helps dealing with all the different kind of input attached to a camera.
  71672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71673. */
  71674. export class CameraInputsManager<TCamera extends Camera> {
  71675. /**
  71676. * Defines the list of inputs attahed to the camera.
  71677. */
  71678. attached: CameraInputsMap<TCamera>;
  71679. /**
  71680. * Defines the dom element the camera is collecting inputs from.
  71681. * This is null if the controls have not been attached.
  71682. */
  71683. attachedElement: Nullable<HTMLElement>;
  71684. /**
  71685. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71686. */
  71687. noPreventDefault: boolean;
  71688. /**
  71689. * Defined the camera the input manager belongs to.
  71690. */
  71691. camera: TCamera;
  71692. /**
  71693. * Update the current camera state depending on the inputs that have been used this frame.
  71694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71695. */
  71696. checkInputs: () => void;
  71697. /**
  71698. * Instantiate a new Camera Input Manager.
  71699. * @param camera Defines the camera the input manager blongs to
  71700. */
  71701. constructor(camera: TCamera);
  71702. /**
  71703. * Add an input method to a camera
  71704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71705. * @param input camera input method
  71706. */
  71707. add(input: ICameraInput<TCamera>): void;
  71708. /**
  71709. * Remove a specific input method from a camera
  71710. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71711. * @param inputToRemove camera input method
  71712. */
  71713. remove(inputToRemove: ICameraInput<TCamera>): void;
  71714. /**
  71715. * Remove a specific input type from a camera
  71716. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71717. * @param inputType the type of the input to remove
  71718. */
  71719. removeByType(inputType: string): void;
  71720. private _addCheckInputs;
  71721. /**
  71722. * Attach the input controls to the currently attached dom element to listen the events from.
  71723. * @param input Defines the input to attach
  71724. */
  71725. attachInput(input: ICameraInput<TCamera>): void;
  71726. /**
  71727. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71728. * @param element Defines the dom element to collect the events from
  71729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71730. */
  71731. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71732. /**
  71733. * Detach the current manager inputs controls from a specific dom element.
  71734. * @param element Defines the dom element to collect the events from
  71735. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71736. */
  71737. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71738. /**
  71739. * Rebuild the dynamic inputCheck function from the current list of
  71740. * defined inputs in the manager.
  71741. */
  71742. rebuildInputCheck(): void;
  71743. /**
  71744. * Remove all attached input methods from a camera
  71745. */
  71746. clear(): void;
  71747. /**
  71748. * Serialize the current input manager attached to a camera.
  71749. * This ensures than once parsed,
  71750. * the input associated to the camera will be identical to the current ones
  71751. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71752. */
  71753. serialize(serializedCamera: any): void;
  71754. /**
  71755. * Parses an input manager serialized JSON to restore the previous list of inputs
  71756. * and states associated to a camera.
  71757. * @param parsedCamera Defines the JSON to parse
  71758. */
  71759. parse(parsedCamera: any): void;
  71760. }
  71761. }
  71762. declare module BABYLON {
  71763. /**
  71764. * @hidden
  71765. */
  71766. export class IntersectionInfo {
  71767. bu: Nullable<number>;
  71768. bv: Nullable<number>;
  71769. distance: number;
  71770. faceId: number;
  71771. subMeshId: number;
  71772. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71773. }
  71774. }
  71775. declare module BABYLON {
  71776. /**
  71777. * Represens a plane by the equation ax + by + cz + d = 0
  71778. */
  71779. export class Plane {
  71780. private static _TmpMatrix;
  71781. /**
  71782. * Normal of the plane (a,b,c)
  71783. */
  71784. normal: Vector3;
  71785. /**
  71786. * d component of the plane
  71787. */
  71788. d: number;
  71789. /**
  71790. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71791. * @param a a component of the plane
  71792. * @param b b component of the plane
  71793. * @param c c component of the plane
  71794. * @param d d component of the plane
  71795. */
  71796. constructor(a: number, b: number, c: number, d: number);
  71797. /**
  71798. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71799. */
  71800. asArray(): number[];
  71801. /**
  71802. * @returns a new plane copied from the current Plane.
  71803. */
  71804. clone(): Plane;
  71805. /**
  71806. * @returns the string "Plane".
  71807. */
  71808. getClassName(): string;
  71809. /**
  71810. * @returns the Plane hash code.
  71811. */
  71812. getHashCode(): number;
  71813. /**
  71814. * Normalize the current Plane in place.
  71815. * @returns the updated Plane.
  71816. */
  71817. normalize(): Plane;
  71818. /**
  71819. * Applies a transformation the plane and returns the result
  71820. * @param transformation the transformation matrix to be applied to the plane
  71821. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71822. */
  71823. transform(transformation: DeepImmutable<Matrix>): Plane;
  71824. /**
  71825. * Calcualtte the dot product between the point and the plane normal
  71826. * @param point point to calculate the dot product with
  71827. * @returns the dot product (float) of the point coordinates and the plane normal.
  71828. */
  71829. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71830. /**
  71831. * Updates the current Plane from the plane defined by the three given points.
  71832. * @param point1 one of the points used to contruct the plane
  71833. * @param point2 one of the points used to contruct the plane
  71834. * @param point3 one of the points used to contruct the plane
  71835. * @returns the updated Plane.
  71836. */
  71837. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71838. /**
  71839. * Checks if the plane is facing a given direction
  71840. * @param direction the direction to check if the plane is facing
  71841. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71842. * @returns True is the vector "direction" is the same side than the plane normal.
  71843. */
  71844. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71845. /**
  71846. * Calculates the distance to a point
  71847. * @param point point to calculate distance to
  71848. * @returns the signed distance (float) from the given point to the Plane.
  71849. */
  71850. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71851. /**
  71852. * Creates a plane from an array
  71853. * @param array the array to create a plane from
  71854. * @returns a new Plane from the given array.
  71855. */
  71856. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71857. /**
  71858. * Creates a plane from three points
  71859. * @param point1 point used to create the plane
  71860. * @param point2 point used to create the plane
  71861. * @param point3 point used to create the plane
  71862. * @returns a new Plane defined by the three given points.
  71863. */
  71864. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71865. /**
  71866. * Creates a plane from an origin point and a normal
  71867. * @param origin origin of the plane to be constructed
  71868. * @param normal normal of the plane to be constructed
  71869. * @returns a new Plane the normal vector to this plane at the given origin point.
  71870. * Note : the vector "normal" is updated because normalized.
  71871. */
  71872. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71873. /**
  71874. * Calculates the distance from a plane and a point
  71875. * @param origin origin of the plane to be constructed
  71876. * @param normal normal of the plane to be constructed
  71877. * @param point point to calculate distance to
  71878. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71879. */
  71880. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71881. }
  71882. }
  71883. declare module BABYLON {
  71884. /**
  71885. * Class used to store bounding sphere information
  71886. */
  71887. export class BoundingSphere {
  71888. /**
  71889. * Gets the center of the bounding sphere in local space
  71890. */
  71891. readonly center: Vector3;
  71892. /**
  71893. * Radius of the bounding sphere in local space
  71894. */
  71895. radius: number;
  71896. /**
  71897. * Gets the center of the bounding sphere in world space
  71898. */
  71899. readonly centerWorld: Vector3;
  71900. /**
  71901. * Radius of the bounding sphere in world space
  71902. */
  71903. radiusWorld: number;
  71904. /**
  71905. * Gets the minimum vector in local space
  71906. */
  71907. readonly minimum: Vector3;
  71908. /**
  71909. * Gets the maximum vector in local space
  71910. */
  71911. readonly maximum: Vector3;
  71912. private _worldMatrix;
  71913. private static readonly TmpVector3;
  71914. /**
  71915. * Creates a new bounding sphere
  71916. * @param min defines the minimum vector (in local space)
  71917. * @param max defines the maximum vector (in local space)
  71918. * @param worldMatrix defines the new world matrix
  71919. */
  71920. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71921. /**
  71922. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71923. * @param min defines the new minimum vector (in local space)
  71924. * @param max defines the new maximum vector (in local space)
  71925. * @param worldMatrix defines the new world matrix
  71926. */
  71927. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71928. /**
  71929. * Scale the current bounding sphere by applying a scale factor
  71930. * @param factor defines the scale factor to apply
  71931. * @returns the current bounding box
  71932. */
  71933. scale(factor: number): BoundingSphere;
  71934. /**
  71935. * Gets the world matrix of the bounding box
  71936. * @returns a matrix
  71937. */
  71938. getWorldMatrix(): DeepImmutable<Matrix>;
  71939. /** @hidden */
  71940. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71941. /**
  71942. * Tests if the bounding sphere is intersecting the frustum planes
  71943. * @param frustumPlanes defines the frustum planes to test
  71944. * @returns true if there is an intersection
  71945. */
  71946. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71947. /**
  71948. * Tests if the bounding sphere center is in between the frustum planes.
  71949. * Used for optimistic fast inclusion.
  71950. * @param frustumPlanes defines the frustum planes to test
  71951. * @returns true if the sphere center is in between the frustum planes
  71952. */
  71953. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71954. /**
  71955. * Tests if a point is inside the bounding sphere
  71956. * @param point defines the point to test
  71957. * @returns true if the point is inside the bounding sphere
  71958. */
  71959. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71960. /**
  71961. * Checks if two sphere intersct
  71962. * @param sphere0 sphere 0
  71963. * @param sphere1 sphere 1
  71964. * @returns true if the speres intersect
  71965. */
  71966. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71967. }
  71968. }
  71969. declare module BABYLON {
  71970. /**
  71971. * Class used to store bounding box information
  71972. */
  71973. export class BoundingBox implements ICullable {
  71974. /**
  71975. * Gets the 8 vectors representing the bounding box in local space
  71976. */
  71977. readonly vectors: Vector3[];
  71978. /**
  71979. * Gets the center of the bounding box in local space
  71980. */
  71981. readonly center: Vector3;
  71982. /**
  71983. * Gets the center of the bounding box in world space
  71984. */
  71985. readonly centerWorld: Vector3;
  71986. /**
  71987. * Gets the extend size in local space
  71988. */
  71989. readonly extendSize: Vector3;
  71990. /**
  71991. * Gets the extend size in world space
  71992. */
  71993. readonly extendSizeWorld: Vector3;
  71994. /**
  71995. * Gets the OBB (object bounding box) directions
  71996. */
  71997. readonly directions: Vector3[];
  71998. /**
  71999. * Gets the 8 vectors representing the bounding box in world space
  72000. */
  72001. readonly vectorsWorld: Vector3[];
  72002. /**
  72003. * Gets the minimum vector in world space
  72004. */
  72005. readonly minimumWorld: Vector3;
  72006. /**
  72007. * Gets the maximum vector in world space
  72008. */
  72009. readonly maximumWorld: Vector3;
  72010. /**
  72011. * Gets the minimum vector in local space
  72012. */
  72013. readonly minimum: Vector3;
  72014. /**
  72015. * Gets the maximum vector in local space
  72016. */
  72017. readonly maximum: Vector3;
  72018. private _worldMatrix;
  72019. private static readonly TmpVector3;
  72020. /**
  72021. * @hidden
  72022. */
  72023. _tag: number;
  72024. /**
  72025. * Creates a new bounding box
  72026. * @param min defines the minimum vector (in local space)
  72027. * @param max defines the maximum vector (in local space)
  72028. * @param worldMatrix defines the new world matrix
  72029. */
  72030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72031. /**
  72032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72033. * @param min defines the new minimum vector (in local space)
  72034. * @param max defines the new maximum vector (in local space)
  72035. * @param worldMatrix defines the new world matrix
  72036. */
  72037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72038. /**
  72039. * Scale the current bounding box by applying a scale factor
  72040. * @param factor defines the scale factor to apply
  72041. * @returns the current bounding box
  72042. */
  72043. scale(factor: number): BoundingBox;
  72044. /**
  72045. * Gets the world matrix of the bounding box
  72046. * @returns a matrix
  72047. */
  72048. getWorldMatrix(): DeepImmutable<Matrix>;
  72049. /** @hidden */
  72050. _update(world: DeepImmutable<Matrix>): void;
  72051. /**
  72052. * Tests if the bounding box is intersecting the frustum planes
  72053. * @param frustumPlanes defines the frustum planes to test
  72054. * @returns true if there is an intersection
  72055. */
  72056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72057. /**
  72058. * Tests if the bounding box is entirely inside the frustum planes
  72059. * @param frustumPlanes defines the frustum planes to test
  72060. * @returns true if there is an inclusion
  72061. */
  72062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72063. /**
  72064. * Tests if a point is inside the bounding box
  72065. * @param point defines the point to test
  72066. * @returns true if the point is inside the bounding box
  72067. */
  72068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72069. /**
  72070. * Tests if the bounding box intersects with a bounding sphere
  72071. * @param sphere defines the sphere to test
  72072. * @returns true if there is an intersection
  72073. */
  72074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72075. /**
  72076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72077. * @param min defines the min vector to use
  72078. * @param max defines the max vector to use
  72079. * @returns true if there is an intersection
  72080. */
  72081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72082. /**
  72083. * Tests if two bounding boxes are intersections
  72084. * @param box0 defines the first box to test
  72085. * @param box1 defines the second box to test
  72086. * @returns true if there is an intersection
  72087. */
  72088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72089. /**
  72090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72091. * @param minPoint defines the minimum vector of the bounding box
  72092. * @param maxPoint defines the maximum vector of the bounding box
  72093. * @param sphereCenter defines the sphere center
  72094. * @param sphereRadius defines the sphere radius
  72095. * @returns true if there is an intersection
  72096. */
  72097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72098. /**
  72099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72101. * @param frustumPlanes defines the frustum planes to test
  72102. * @return true if there is an inclusion
  72103. */
  72104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72105. /**
  72106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72108. * @param frustumPlanes defines the frustum planes to test
  72109. * @return true if there is an intersection
  72110. */
  72111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72112. }
  72113. }
  72114. declare module BABYLON {
  72115. /** @hidden */
  72116. export class Collider {
  72117. /** Define if a collision was found */
  72118. collisionFound: boolean;
  72119. /**
  72120. * Define last intersection point in local space
  72121. */
  72122. intersectionPoint: Vector3;
  72123. /**
  72124. * Define last collided mesh
  72125. */
  72126. collidedMesh: Nullable<AbstractMesh>;
  72127. private _collisionPoint;
  72128. private _planeIntersectionPoint;
  72129. private _tempVector;
  72130. private _tempVector2;
  72131. private _tempVector3;
  72132. private _tempVector4;
  72133. private _edge;
  72134. private _baseToVertex;
  72135. private _destinationPoint;
  72136. private _slidePlaneNormal;
  72137. private _displacementVector;
  72138. /** @hidden */
  72139. _radius: Vector3;
  72140. /** @hidden */
  72141. _retry: number;
  72142. private _velocity;
  72143. private _basePoint;
  72144. private _epsilon;
  72145. /** @hidden */
  72146. _velocityWorldLength: number;
  72147. /** @hidden */
  72148. _basePointWorld: Vector3;
  72149. private _velocityWorld;
  72150. private _normalizedVelocity;
  72151. /** @hidden */
  72152. _initialVelocity: Vector3;
  72153. /** @hidden */
  72154. _initialPosition: Vector3;
  72155. private _nearestDistance;
  72156. private _collisionMask;
  72157. collisionMask: number;
  72158. /**
  72159. * Gets the plane normal used to compute the sliding response (in local space)
  72160. */
  72161. readonly slidePlaneNormal: Vector3;
  72162. /** @hidden */
  72163. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72164. /** @hidden */
  72165. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72166. /** @hidden */
  72167. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72168. /** @hidden */
  72169. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72170. /** @hidden */
  72171. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72172. /** @hidden */
  72173. _getResponse(pos: Vector3, vel: Vector3): void;
  72174. }
  72175. }
  72176. declare module BABYLON {
  72177. /**
  72178. * Interface for cullable objects
  72179. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72180. */
  72181. export interface ICullable {
  72182. /**
  72183. * Checks if the object or part of the object is in the frustum
  72184. * @param frustumPlanes Camera near/planes
  72185. * @returns true if the object is in frustum otherwise false
  72186. */
  72187. isInFrustum(frustumPlanes: Plane[]): boolean;
  72188. /**
  72189. * Checks if a cullable object (mesh...) is in the camera frustum
  72190. * Unlike isInFrustum this cheks the full bounding box
  72191. * @param frustumPlanes Camera near/planes
  72192. * @returns true if the object is in frustum otherwise false
  72193. */
  72194. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72195. }
  72196. /**
  72197. * Info for a bounding data of a mesh
  72198. */
  72199. export class BoundingInfo implements ICullable {
  72200. /**
  72201. * Bounding box for the mesh
  72202. */
  72203. readonly boundingBox: BoundingBox;
  72204. /**
  72205. * Bounding sphere for the mesh
  72206. */
  72207. readonly boundingSphere: BoundingSphere;
  72208. private _isLocked;
  72209. private static readonly TmpVector3;
  72210. /**
  72211. * Constructs bounding info
  72212. * @param minimum min vector of the bounding box/sphere
  72213. * @param maximum max vector of the bounding box/sphere
  72214. * @param worldMatrix defines the new world matrix
  72215. */
  72216. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72217. /**
  72218. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72219. * @param min defines the new minimum vector (in local space)
  72220. * @param max defines the new maximum vector (in local space)
  72221. * @param worldMatrix defines the new world matrix
  72222. */
  72223. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72224. /**
  72225. * min vector of the bounding box/sphere
  72226. */
  72227. readonly minimum: Vector3;
  72228. /**
  72229. * max vector of the bounding box/sphere
  72230. */
  72231. readonly maximum: Vector3;
  72232. /**
  72233. * If the info is locked and won't be updated to avoid perf overhead
  72234. */
  72235. isLocked: boolean;
  72236. /**
  72237. * Updates the bounding sphere and box
  72238. * @param world world matrix to be used to update
  72239. */
  72240. update(world: DeepImmutable<Matrix>): void;
  72241. /**
  72242. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72243. * @param center New center of the bounding info
  72244. * @param extend New extend of the bounding info
  72245. * @returns the current bounding info
  72246. */
  72247. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72248. /**
  72249. * Scale the current bounding info by applying a scale factor
  72250. * @param factor defines the scale factor to apply
  72251. * @returns the current bounding info
  72252. */
  72253. scale(factor: number): BoundingInfo;
  72254. /**
  72255. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72256. * @param frustumPlanes defines the frustum to test
  72257. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72258. * @returns true if the bounding info is in the frustum planes
  72259. */
  72260. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72261. /**
  72262. * Gets the world distance between the min and max points of the bounding box
  72263. */
  72264. readonly diagonalLength: number;
  72265. /**
  72266. * Checks if a cullable object (mesh...) is in the camera frustum
  72267. * Unlike isInFrustum this cheks the full bounding box
  72268. * @param frustumPlanes Camera near/planes
  72269. * @returns true if the object is in frustum otherwise false
  72270. */
  72271. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72272. /** @hidden */
  72273. _checkCollision(collider: Collider): boolean;
  72274. /**
  72275. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72276. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72277. * @param point the point to check intersection with
  72278. * @returns if the point intersects
  72279. */
  72280. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72281. /**
  72282. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72284. * @param boundingInfo the bounding info to check intersection with
  72285. * @param precise if the intersection should be done using OBB
  72286. * @returns if the bounding info intersects
  72287. */
  72288. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72289. }
  72290. }
  72291. declare module BABYLON {
  72292. /**
  72293. * Extracts minimum and maximum values from a list of indexed positions
  72294. * @param positions defines the positions to use
  72295. * @param indices defines the indices to the positions
  72296. * @param indexStart defines the start index
  72297. * @param indexCount defines the end index
  72298. * @param bias defines bias value to add to the result
  72299. * @return minimum and maximum values
  72300. */
  72301. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72302. minimum: Vector3;
  72303. maximum: Vector3;
  72304. };
  72305. /**
  72306. * Extracts minimum and maximum values from a list of positions
  72307. * @param positions defines the positions to use
  72308. * @param start defines the start index in the positions array
  72309. * @param count defines the number of positions to handle
  72310. * @param bias defines bias value to add to the result
  72311. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72312. * @return minimum and maximum values
  72313. */
  72314. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72315. minimum: Vector3;
  72316. maximum: Vector3;
  72317. };
  72318. }
  72319. declare module BABYLON {
  72320. /**
  72321. * Enum that determines the text-wrapping mode to use.
  72322. */
  72323. export enum InspectableType {
  72324. /**
  72325. * Checkbox for booleans
  72326. */
  72327. Checkbox = 0,
  72328. /**
  72329. * Sliders for numbers
  72330. */
  72331. Slider = 1,
  72332. /**
  72333. * Vector3
  72334. */
  72335. Vector3 = 2,
  72336. /**
  72337. * Quaternions
  72338. */
  72339. Quaternion = 3,
  72340. /**
  72341. * Color3
  72342. */
  72343. Color3 = 4,
  72344. /**
  72345. * String
  72346. */
  72347. String = 5
  72348. }
  72349. /**
  72350. * Interface used to define custom inspectable properties.
  72351. * This interface is used by the inspector to display custom property grids
  72352. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72353. */
  72354. export interface IInspectable {
  72355. /**
  72356. * Gets the label to display
  72357. */
  72358. label: string;
  72359. /**
  72360. * Gets the name of the property to edit
  72361. */
  72362. propertyName: string;
  72363. /**
  72364. * Gets the type of the editor to use
  72365. */
  72366. type: InspectableType;
  72367. /**
  72368. * Gets the minimum value of the property when using in "slider" mode
  72369. */
  72370. min?: number;
  72371. /**
  72372. * Gets the maximum value of the property when using in "slider" mode
  72373. */
  72374. max?: number;
  72375. /**
  72376. * Gets the setp to use when using in "slider" mode
  72377. */
  72378. step?: number;
  72379. }
  72380. }
  72381. declare module BABYLON {
  72382. /**
  72383. * Class used to provide helper for timing
  72384. */
  72385. export class TimingTools {
  72386. /**
  72387. * Polyfill for setImmediate
  72388. * @param action defines the action to execute after the current execution block
  72389. */
  72390. static SetImmediate(action: () => void): void;
  72391. }
  72392. }
  72393. declare module BABYLON {
  72394. /**
  72395. * Class used to enable instatition of objects by class name
  72396. */
  72397. export class InstantiationTools {
  72398. /**
  72399. * Use this object to register external classes like custom textures or material
  72400. * to allow the laoders to instantiate them
  72401. */
  72402. static RegisteredExternalClasses: {
  72403. [key: string]: Object;
  72404. };
  72405. /**
  72406. * Tries to instantiate a new object from a given class name
  72407. * @param className defines the class name to instantiate
  72408. * @returns the new object or null if the system was not able to do the instantiation
  72409. */
  72410. static Instantiate(className: string): any;
  72411. }
  72412. }
  72413. declare module BABYLON {
  72414. /**
  72415. * This represents the required contract to create a new type of texture loader.
  72416. */
  72417. export interface IInternalTextureLoader {
  72418. /**
  72419. * Defines wether the loader supports cascade loading the different faces.
  72420. */
  72421. supportCascades: boolean;
  72422. /**
  72423. * This returns if the loader support the current file information.
  72424. * @param extension defines the file extension of the file being loaded
  72425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72426. * @param fallback defines the fallback internal texture if any
  72427. * @param isBase64 defines whether the texture is encoded as a base64
  72428. * @param isBuffer defines whether the texture data are stored as a buffer
  72429. * @returns true if the loader can load the specified file
  72430. */
  72431. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72432. /**
  72433. * Transform the url before loading if required.
  72434. * @param rootUrl the url of the texture
  72435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72436. * @returns the transformed texture
  72437. */
  72438. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72439. /**
  72440. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72441. * @param rootUrl the url of the texture
  72442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72443. * @returns the fallback texture
  72444. */
  72445. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72446. /**
  72447. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72448. * @param data contains the texture data
  72449. * @param texture defines the BabylonJS internal texture
  72450. * @param createPolynomials will be true if polynomials have been requested
  72451. * @param onLoad defines the callback to trigger once the texture is ready
  72452. * @param onError defines the callback to trigger in case of error
  72453. */
  72454. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72455. /**
  72456. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72457. * @param data contains the texture data
  72458. * @param texture defines the BabylonJS internal texture
  72459. * @param callback defines the method to call once ready to upload
  72460. */
  72461. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72462. }
  72463. }
  72464. declare module BABYLON {
  72465. interface Engine {
  72466. /**
  72467. * Creates a depth stencil cube texture.
  72468. * This is only available in WebGL 2.
  72469. * @param size The size of face edge in the cube texture.
  72470. * @param options The options defining the cube texture.
  72471. * @returns The cube texture
  72472. */
  72473. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72474. /**
  72475. * Creates a cube texture
  72476. * @param rootUrl defines the url where the files to load is located
  72477. * @param scene defines the current scene
  72478. * @param files defines the list of files to load (1 per face)
  72479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72480. * @param onLoad defines an optional callback raised when the texture is loaded
  72481. * @param onError defines an optional callback raised if there is an issue to load the texture
  72482. * @param format defines the format of the data
  72483. * @param forcedExtension defines the extension to use to pick the right loader
  72484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72487. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72488. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72489. * @returns the cube texture as an InternalTexture
  72490. */
  72491. 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;
  72492. /**
  72493. * Creates a cube texture
  72494. * @param rootUrl defines the url where the files to load is located
  72495. * @param scene defines the current scene
  72496. * @param files defines the list of files to load (1 per face)
  72497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72498. * @param onLoad defines an optional callback raised when the texture is loaded
  72499. * @param onError defines an optional callback raised if there is an issue to load the texture
  72500. * @param format defines the format of the data
  72501. * @param forcedExtension defines the extension to use to pick the right loader
  72502. * @returns the cube texture as an InternalTexture
  72503. */
  72504. 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;
  72505. /**
  72506. * Creates a cube texture
  72507. * @param rootUrl defines the url where the files to load is located
  72508. * @param scene defines the current scene
  72509. * @param files defines the list of files to load (1 per face)
  72510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72511. * @param onLoad defines an optional callback raised when the texture is loaded
  72512. * @param onError defines an optional callback raised if there is an issue to load the texture
  72513. * @param format defines the format of the data
  72514. * @param forcedExtension defines the extension to use to pick the right loader
  72515. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72516. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72517. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72518. * @returns the cube texture as an InternalTexture
  72519. */
  72520. 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;
  72521. /** @hidden */
  72522. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72523. /** @hidden */
  72524. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72525. /** @hidden */
  72526. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72527. /** @hidden */
  72528. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72529. }
  72530. }
  72531. declare module BABYLON {
  72532. /**
  72533. * Class for creating a cube texture
  72534. */
  72535. export class CubeTexture extends BaseTexture {
  72536. private _delayedOnLoad;
  72537. /**
  72538. * The url of the texture
  72539. */
  72540. url: string;
  72541. /**
  72542. * Gets or sets the center of the bounding box associated with the cube texture.
  72543. * It must define where the camera used to render the texture was set
  72544. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72545. */
  72546. boundingBoxPosition: Vector3;
  72547. private _boundingBoxSize;
  72548. /**
  72549. * Gets or sets the size of the bounding box associated with the cube texture
  72550. * When defined, the cubemap will switch to local mode
  72551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72552. * @example https://www.babylonjs-playground.com/#RNASML
  72553. */
  72554. /**
  72555. * Returns the bounding box size
  72556. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72557. */
  72558. boundingBoxSize: Vector3;
  72559. protected _rotationY: number;
  72560. /**
  72561. * Sets texture matrix rotation angle around Y axis in radians.
  72562. */
  72563. /**
  72564. * Gets texture matrix rotation angle around Y axis radians.
  72565. */
  72566. rotationY: number;
  72567. /**
  72568. * Are mip maps generated for this texture or not.
  72569. */
  72570. readonly noMipmap: boolean;
  72571. private _noMipmap;
  72572. private _files;
  72573. private _extensions;
  72574. private _textureMatrix;
  72575. private _format;
  72576. private _createPolynomials;
  72577. /** @hidden */
  72578. _prefiltered: boolean;
  72579. /**
  72580. * Creates a cube texture from an array of image urls
  72581. * @param files defines an array of image urls
  72582. * @param scene defines the hosting scene
  72583. * @param noMipmap specifies if mip maps are not used
  72584. * @returns a cube texture
  72585. */
  72586. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72587. /**
  72588. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72589. * @param url defines the url of the prefiltered texture
  72590. * @param scene defines the scene the texture is attached to
  72591. * @param forcedExtension defines the extension of the file if different from the url
  72592. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72593. * @return the prefiltered texture
  72594. */
  72595. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72596. /**
  72597. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72598. * as prefiltered data.
  72599. * @param rootUrl defines the url of the texture or the root name of the six images
  72600. * @param scene defines the scene the texture is attached to
  72601. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72602. * @param noMipmap defines if mipmaps should be created or not
  72603. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72604. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72605. * @param onError defines a callback triggered in case of error during load
  72606. * @param format defines the internal format to use for the texture once loaded
  72607. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72608. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72610. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72611. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72612. * @return the cube texture
  72613. */
  72614. 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);
  72615. /**
  72616. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72617. */
  72618. readonly isPrefiltered: boolean;
  72619. /**
  72620. * Get the current class name of the texture useful for serialization or dynamic coding.
  72621. * @returns "CubeTexture"
  72622. */
  72623. getClassName(): string;
  72624. /**
  72625. * Update the url (and optional buffer) of this texture if url was null during construction.
  72626. * @param url the url of the texture
  72627. * @param forcedExtension defines the extension to use
  72628. * @param onLoad callback called when the texture is loaded (defaults to null)
  72629. */
  72630. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72631. /**
  72632. * Delays loading of the cube texture
  72633. * @param forcedExtension defines the extension to use
  72634. */
  72635. delayLoad(forcedExtension?: string): void;
  72636. /**
  72637. * Returns the reflection texture matrix
  72638. * @returns the reflection texture matrix
  72639. */
  72640. getReflectionTextureMatrix(): Matrix;
  72641. /**
  72642. * Sets the reflection texture matrix
  72643. * @param value Reflection texture matrix
  72644. */
  72645. setReflectionTextureMatrix(value: Matrix): void;
  72646. /**
  72647. * Parses text to create a cube texture
  72648. * @param parsedTexture define the serialized text to read from
  72649. * @param scene defines the hosting scene
  72650. * @param rootUrl defines the root url of the cube texture
  72651. * @returns a cube texture
  72652. */
  72653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72654. /**
  72655. * Makes a clone, or deep copy, of the cube texture
  72656. * @returns a new cube texture
  72657. */
  72658. clone(): CubeTexture;
  72659. }
  72660. }
  72661. declare module BABYLON {
  72662. /**
  72663. * Manages the defines for the Material
  72664. */
  72665. export class MaterialDefines {
  72666. /** @hidden */
  72667. protected _keys: string[];
  72668. private _isDirty;
  72669. /** @hidden */
  72670. _renderId: number;
  72671. /** @hidden */
  72672. _areLightsDirty: boolean;
  72673. /** @hidden */
  72674. _areLightsDisposed: boolean;
  72675. /** @hidden */
  72676. _areAttributesDirty: boolean;
  72677. /** @hidden */
  72678. _areTexturesDirty: boolean;
  72679. /** @hidden */
  72680. _areFresnelDirty: boolean;
  72681. /** @hidden */
  72682. _areMiscDirty: boolean;
  72683. /** @hidden */
  72684. _areImageProcessingDirty: boolean;
  72685. /** @hidden */
  72686. _normals: boolean;
  72687. /** @hidden */
  72688. _uvs: boolean;
  72689. /** @hidden */
  72690. _needNormals: boolean;
  72691. /** @hidden */
  72692. _needUVs: boolean;
  72693. [id: string]: any;
  72694. /**
  72695. * Specifies if the material needs to be re-calculated
  72696. */
  72697. readonly isDirty: boolean;
  72698. /**
  72699. * Marks the material to indicate that it has been re-calculated
  72700. */
  72701. markAsProcessed(): void;
  72702. /**
  72703. * Marks the material to indicate that it needs to be re-calculated
  72704. */
  72705. markAsUnprocessed(): void;
  72706. /**
  72707. * Marks the material to indicate all of its defines need to be re-calculated
  72708. */
  72709. markAllAsDirty(): void;
  72710. /**
  72711. * Marks the material to indicate that image processing needs to be re-calculated
  72712. */
  72713. markAsImageProcessingDirty(): void;
  72714. /**
  72715. * Marks the material to indicate the lights need to be re-calculated
  72716. * @param disposed Defines whether the light is dirty due to dispose or not
  72717. */
  72718. markAsLightDirty(disposed?: boolean): void;
  72719. /**
  72720. * Marks the attribute state as changed
  72721. */
  72722. markAsAttributesDirty(): void;
  72723. /**
  72724. * Marks the texture state as changed
  72725. */
  72726. markAsTexturesDirty(): void;
  72727. /**
  72728. * Marks the fresnel state as changed
  72729. */
  72730. markAsFresnelDirty(): void;
  72731. /**
  72732. * Marks the misc state as changed
  72733. */
  72734. markAsMiscDirty(): void;
  72735. /**
  72736. * Rebuilds the material defines
  72737. */
  72738. rebuild(): void;
  72739. /**
  72740. * Specifies if two material defines are equal
  72741. * @param other - A material define instance to compare to
  72742. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72743. */
  72744. isEqual(other: MaterialDefines): boolean;
  72745. /**
  72746. * Clones this instance's defines to another instance
  72747. * @param other - material defines to clone values to
  72748. */
  72749. cloneTo(other: MaterialDefines): void;
  72750. /**
  72751. * Resets the material define values
  72752. */
  72753. reset(): void;
  72754. /**
  72755. * Converts the material define values to a string
  72756. * @returns - String of material define information
  72757. */
  72758. toString(): string;
  72759. }
  72760. }
  72761. declare module BABYLON {
  72762. /**
  72763. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72764. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72765. * 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;
  72766. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72767. */
  72768. export class ColorCurves {
  72769. private _dirty;
  72770. private _tempColor;
  72771. private _globalCurve;
  72772. private _highlightsCurve;
  72773. private _midtonesCurve;
  72774. private _shadowsCurve;
  72775. private _positiveCurve;
  72776. private _negativeCurve;
  72777. private _globalHue;
  72778. private _globalDensity;
  72779. private _globalSaturation;
  72780. private _globalExposure;
  72781. /**
  72782. * Gets the global Hue value.
  72783. * 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).
  72784. */
  72785. /**
  72786. * Sets the global Hue value.
  72787. * 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).
  72788. */
  72789. globalHue: number;
  72790. /**
  72791. * Gets the global Density value.
  72792. * 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.
  72793. * Values less than zero provide a filter of opposite hue.
  72794. */
  72795. /**
  72796. * Sets the global Density value.
  72797. * 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.
  72798. * Values less than zero provide a filter of opposite hue.
  72799. */
  72800. globalDensity: number;
  72801. /**
  72802. * Gets the global Saturation value.
  72803. * 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.
  72804. */
  72805. /**
  72806. * Sets the global Saturation value.
  72807. * 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.
  72808. */
  72809. globalSaturation: number;
  72810. /**
  72811. * Gets the global Exposure value.
  72812. * 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.
  72813. */
  72814. /**
  72815. * Sets the global Exposure value.
  72816. * 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.
  72817. */
  72818. globalExposure: number;
  72819. private _highlightsHue;
  72820. private _highlightsDensity;
  72821. private _highlightsSaturation;
  72822. private _highlightsExposure;
  72823. /**
  72824. * Gets the highlights Hue value.
  72825. * 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).
  72826. */
  72827. /**
  72828. * Sets the highlights Hue value.
  72829. * 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).
  72830. */
  72831. highlightsHue: number;
  72832. /**
  72833. * Gets the highlights Density value.
  72834. * 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.
  72835. * Values less than zero provide a filter of opposite hue.
  72836. */
  72837. /**
  72838. * Sets the highlights Density value.
  72839. * 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.
  72840. * Values less than zero provide a filter of opposite hue.
  72841. */
  72842. highlightsDensity: number;
  72843. /**
  72844. * Gets the highlights Saturation value.
  72845. * 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.
  72846. */
  72847. /**
  72848. * Sets the highlights Saturation value.
  72849. * 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.
  72850. */
  72851. highlightsSaturation: number;
  72852. /**
  72853. * Gets the highlights Exposure value.
  72854. * 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.
  72855. */
  72856. /**
  72857. * Sets the highlights Exposure value.
  72858. * 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.
  72859. */
  72860. highlightsExposure: number;
  72861. private _midtonesHue;
  72862. private _midtonesDensity;
  72863. private _midtonesSaturation;
  72864. private _midtonesExposure;
  72865. /**
  72866. * Gets the midtones Hue value.
  72867. * 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).
  72868. */
  72869. /**
  72870. * Sets the midtones Hue value.
  72871. * 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).
  72872. */
  72873. midtonesHue: number;
  72874. /**
  72875. * Gets the midtones Density value.
  72876. * 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.
  72877. * Values less than zero provide a filter of opposite hue.
  72878. */
  72879. /**
  72880. * Sets the midtones Density value.
  72881. * 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.
  72882. * Values less than zero provide a filter of opposite hue.
  72883. */
  72884. midtonesDensity: number;
  72885. /**
  72886. * Gets the midtones Saturation value.
  72887. * 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.
  72888. */
  72889. /**
  72890. * Sets the midtones Saturation value.
  72891. * 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.
  72892. */
  72893. midtonesSaturation: number;
  72894. /**
  72895. * Gets the midtones Exposure value.
  72896. * 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.
  72897. */
  72898. /**
  72899. * Sets the midtones Exposure value.
  72900. * 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.
  72901. */
  72902. midtonesExposure: number;
  72903. private _shadowsHue;
  72904. private _shadowsDensity;
  72905. private _shadowsSaturation;
  72906. private _shadowsExposure;
  72907. /**
  72908. * Gets the shadows Hue value.
  72909. * 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).
  72910. */
  72911. /**
  72912. * Sets the shadows Hue value.
  72913. * 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).
  72914. */
  72915. shadowsHue: number;
  72916. /**
  72917. * Gets the shadows Density value.
  72918. * 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.
  72919. * Values less than zero provide a filter of opposite hue.
  72920. */
  72921. /**
  72922. * Sets the shadows Density value.
  72923. * 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.
  72924. * Values less than zero provide a filter of opposite hue.
  72925. */
  72926. shadowsDensity: number;
  72927. /**
  72928. * Gets the shadows Saturation value.
  72929. * 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.
  72930. */
  72931. /**
  72932. * Sets the shadows Saturation value.
  72933. * 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.
  72934. */
  72935. shadowsSaturation: number;
  72936. /**
  72937. * Gets the shadows Exposure value.
  72938. * 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.
  72939. */
  72940. /**
  72941. * Sets the shadows Exposure value.
  72942. * 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.
  72943. */
  72944. shadowsExposure: number;
  72945. /**
  72946. * Returns the class name
  72947. * @returns The class name
  72948. */
  72949. getClassName(): string;
  72950. /**
  72951. * Binds the color curves to the shader.
  72952. * @param colorCurves The color curve to bind
  72953. * @param effect The effect to bind to
  72954. * @param positiveUniform The positive uniform shader parameter
  72955. * @param neutralUniform The neutral uniform shader parameter
  72956. * @param negativeUniform The negative uniform shader parameter
  72957. */
  72958. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72959. /**
  72960. * Prepare the list of uniforms associated with the ColorCurves effects.
  72961. * @param uniformsList The list of uniforms used in the effect
  72962. */
  72963. static PrepareUniforms(uniformsList: string[]): void;
  72964. /**
  72965. * Returns color grading data based on a hue, density, saturation and exposure value.
  72966. * @param filterHue The hue of the color filter.
  72967. * @param filterDensity The density of the color filter.
  72968. * @param saturation The saturation.
  72969. * @param exposure The exposure.
  72970. * @param result The result data container.
  72971. */
  72972. private getColorGradingDataToRef;
  72973. /**
  72974. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72975. * @param value The input slider value in range [-100,100].
  72976. * @returns Adjusted value.
  72977. */
  72978. private static applyColorGradingSliderNonlinear;
  72979. /**
  72980. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72981. * @param hue The hue (H) input.
  72982. * @param saturation The saturation (S) input.
  72983. * @param brightness The brightness (B) input.
  72984. * @result An RGBA color represented as Vector4.
  72985. */
  72986. private static fromHSBToRef;
  72987. /**
  72988. * Returns a value clamped between min and max
  72989. * @param value The value to clamp
  72990. * @param min The minimum of value
  72991. * @param max The maximum of value
  72992. * @returns The clamped value.
  72993. */
  72994. private static clamp;
  72995. /**
  72996. * Clones the current color curve instance.
  72997. * @return The cloned curves
  72998. */
  72999. clone(): ColorCurves;
  73000. /**
  73001. * Serializes the current color curve instance to a json representation.
  73002. * @return a JSON representation
  73003. */
  73004. serialize(): any;
  73005. /**
  73006. * Parses the color curve from a json representation.
  73007. * @param source the JSON source to parse
  73008. * @return The parsed curves
  73009. */
  73010. static Parse(source: any): ColorCurves;
  73011. }
  73012. }
  73013. declare module BABYLON {
  73014. /**
  73015. * Interface to follow in your material defines to integrate easily the
  73016. * Image proccessing functions.
  73017. * @hidden
  73018. */
  73019. export interface IImageProcessingConfigurationDefines {
  73020. IMAGEPROCESSING: boolean;
  73021. VIGNETTE: boolean;
  73022. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73023. VIGNETTEBLENDMODEOPAQUE: boolean;
  73024. TONEMAPPING: boolean;
  73025. TONEMAPPING_ACES: boolean;
  73026. CONTRAST: boolean;
  73027. EXPOSURE: boolean;
  73028. COLORCURVES: boolean;
  73029. COLORGRADING: boolean;
  73030. COLORGRADING3D: boolean;
  73031. SAMPLER3DGREENDEPTH: boolean;
  73032. SAMPLER3DBGRMAP: boolean;
  73033. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73034. }
  73035. /**
  73036. * @hidden
  73037. */
  73038. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73039. IMAGEPROCESSING: boolean;
  73040. VIGNETTE: boolean;
  73041. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73042. VIGNETTEBLENDMODEOPAQUE: boolean;
  73043. TONEMAPPING: boolean;
  73044. TONEMAPPING_ACES: boolean;
  73045. CONTRAST: boolean;
  73046. COLORCURVES: boolean;
  73047. COLORGRADING: boolean;
  73048. COLORGRADING3D: boolean;
  73049. SAMPLER3DGREENDEPTH: boolean;
  73050. SAMPLER3DBGRMAP: boolean;
  73051. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73052. EXPOSURE: boolean;
  73053. constructor();
  73054. }
  73055. /**
  73056. * This groups together the common properties used for image processing either in direct forward pass
  73057. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73058. * or not.
  73059. */
  73060. export class ImageProcessingConfiguration {
  73061. /**
  73062. * Default tone mapping applied in BabylonJS.
  73063. */
  73064. static readonly TONEMAPPING_STANDARD: number;
  73065. /**
  73066. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73067. * to other engines rendering to increase portability.
  73068. */
  73069. static readonly TONEMAPPING_ACES: number;
  73070. /**
  73071. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73072. */
  73073. colorCurves: Nullable<ColorCurves>;
  73074. private _colorCurvesEnabled;
  73075. /**
  73076. * Gets wether the color curves effect is enabled.
  73077. */
  73078. /**
  73079. * Sets wether the color curves effect is enabled.
  73080. */
  73081. colorCurvesEnabled: boolean;
  73082. private _colorGradingTexture;
  73083. /**
  73084. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73085. */
  73086. /**
  73087. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73088. */
  73089. colorGradingTexture: Nullable<BaseTexture>;
  73090. private _colorGradingEnabled;
  73091. /**
  73092. * Gets wether the color grading effect is enabled.
  73093. */
  73094. /**
  73095. * Sets wether the color grading effect is enabled.
  73096. */
  73097. colorGradingEnabled: boolean;
  73098. private _colorGradingWithGreenDepth;
  73099. /**
  73100. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73101. */
  73102. /**
  73103. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73104. */
  73105. colorGradingWithGreenDepth: boolean;
  73106. private _colorGradingBGR;
  73107. /**
  73108. * Gets wether the color grading texture contains BGR values.
  73109. */
  73110. /**
  73111. * Sets wether the color grading texture contains BGR values.
  73112. */
  73113. colorGradingBGR: boolean;
  73114. /** @hidden */
  73115. _exposure: number;
  73116. /**
  73117. * Gets the Exposure used in the effect.
  73118. */
  73119. /**
  73120. * Sets the Exposure used in the effect.
  73121. */
  73122. exposure: number;
  73123. private _toneMappingEnabled;
  73124. /**
  73125. * Gets wether the tone mapping effect is enabled.
  73126. */
  73127. /**
  73128. * Sets wether the tone mapping effect is enabled.
  73129. */
  73130. toneMappingEnabled: boolean;
  73131. private _toneMappingType;
  73132. /**
  73133. * Gets the type of tone mapping effect.
  73134. */
  73135. /**
  73136. * Sets the type of tone mapping effect used in BabylonJS.
  73137. */
  73138. toneMappingType: number;
  73139. protected _contrast: number;
  73140. /**
  73141. * Gets the contrast used in the effect.
  73142. */
  73143. /**
  73144. * Sets the contrast used in the effect.
  73145. */
  73146. contrast: number;
  73147. /**
  73148. * Vignette stretch size.
  73149. */
  73150. vignetteStretch: number;
  73151. /**
  73152. * Vignette centre X Offset.
  73153. */
  73154. vignetteCentreX: number;
  73155. /**
  73156. * Vignette centre Y Offset.
  73157. */
  73158. vignetteCentreY: number;
  73159. /**
  73160. * Vignette weight or intensity of the vignette effect.
  73161. */
  73162. vignetteWeight: number;
  73163. /**
  73164. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73165. * if vignetteEnabled is set to true.
  73166. */
  73167. vignetteColor: Color4;
  73168. /**
  73169. * Camera field of view used by the Vignette effect.
  73170. */
  73171. vignetteCameraFov: number;
  73172. private _vignetteBlendMode;
  73173. /**
  73174. * Gets the vignette blend mode allowing different kind of effect.
  73175. */
  73176. /**
  73177. * Sets the vignette blend mode allowing different kind of effect.
  73178. */
  73179. vignetteBlendMode: number;
  73180. private _vignetteEnabled;
  73181. /**
  73182. * Gets wether the vignette effect is enabled.
  73183. */
  73184. /**
  73185. * Sets wether the vignette effect is enabled.
  73186. */
  73187. vignetteEnabled: boolean;
  73188. private _applyByPostProcess;
  73189. /**
  73190. * Gets wether the image processing is applied through a post process or not.
  73191. */
  73192. /**
  73193. * Sets wether the image processing is applied through a post process or not.
  73194. */
  73195. applyByPostProcess: boolean;
  73196. private _isEnabled;
  73197. /**
  73198. * Gets wether the image processing is enabled or not.
  73199. */
  73200. /**
  73201. * Sets wether the image processing is enabled or not.
  73202. */
  73203. isEnabled: boolean;
  73204. /**
  73205. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73206. */
  73207. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73208. /**
  73209. * Method called each time the image processing information changes requires to recompile the effect.
  73210. */
  73211. protected _updateParameters(): void;
  73212. /**
  73213. * Gets the current class name.
  73214. * @return "ImageProcessingConfiguration"
  73215. */
  73216. getClassName(): string;
  73217. /**
  73218. * Prepare the list of uniforms associated with the Image Processing effects.
  73219. * @param uniforms The list of uniforms used in the effect
  73220. * @param defines the list of defines currently in use
  73221. */
  73222. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73223. /**
  73224. * Prepare the list of samplers associated with the Image Processing effects.
  73225. * @param samplersList The list of uniforms used in the effect
  73226. * @param defines the list of defines currently in use
  73227. */
  73228. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73229. /**
  73230. * Prepare the list of defines associated to the shader.
  73231. * @param defines the list of defines to complete
  73232. * @param forPostProcess Define if we are currently in post process mode or not
  73233. */
  73234. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73235. /**
  73236. * Returns true if all the image processing information are ready.
  73237. * @returns True if ready, otherwise, false
  73238. */
  73239. isReady(): boolean;
  73240. /**
  73241. * Binds the image processing to the shader.
  73242. * @param effect The effect to bind to
  73243. * @param aspectRatio Define the current aspect ratio of the effect
  73244. */
  73245. bind(effect: Effect, aspectRatio?: number): void;
  73246. /**
  73247. * Clones the current image processing instance.
  73248. * @return The cloned image processing
  73249. */
  73250. clone(): ImageProcessingConfiguration;
  73251. /**
  73252. * Serializes the current image processing instance to a json representation.
  73253. * @return a JSON representation
  73254. */
  73255. serialize(): any;
  73256. /**
  73257. * Parses the image processing from a json representation.
  73258. * @param source the JSON source to parse
  73259. * @return The parsed image processing
  73260. */
  73261. static Parse(source: any): ImageProcessingConfiguration;
  73262. private static _VIGNETTEMODE_MULTIPLY;
  73263. private static _VIGNETTEMODE_OPAQUE;
  73264. /**
  73265. * Used to apply the vignette as a mix with the pixel color.
  73266. */
  73267. static readonly VIGNETTEMODE_MULTIPLY: number;
  73268. /**
  73269. * Used to apply the vignette as a replacement of the pixel color.
  73270. */
  73271. static readonly VIGNETTEMODE_OPAQUE: number;
  73272. }
  73273. }
  73274. declare module BABYLON {
  73275. /** @hidden */
  73276. export var postprocessVertexShader: {
  73277. name: string;
  73278. shader: string;
  73279. };
  73280. }
  73281. declare module BABYLON {
  73282. /** Defines supported spaces */
  73283. export enum Space {
  73284. /** Local (object) space */
  73285. LOCAL = 0,
  73286. /** World space */
  73287. WORLD = 1,
  73288. /** Bone space */
  73289. BONE = 2
  73290. }
  73291. /** Defines the 3 main axes */
  73292. export class Axis {
  73293. /** X axis */
  73294. static X: Vector3;
  73295. /** Y axis */
  73296. static Y: Vector3;
  73297. /** Z axis */
  73298. static Z: Vector3;
  73299. }
  73300. }
  73301. declare module BABYLON {
  73302. /**
  73303. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73304. * This is the base of the follow, arc rotate cameras and Free camera
  73305. * @see http://doc.babylonjs.com/features/cameras
  73306. */
  73307. export class TargetCamera extends Camera {
  73308. private static _RigCamTransformMatrix;
  73309. private static _TargetTransformMatrix;
  73310. private static _TargetFocalPoint;
  73311. /**
  73312. * Define the current direction the camera is moving to
  73313. */
  73314. cameraDirection: Vector3;
  73315. /**
  73316. * Define the current rotation the camera is rotating to
  73317. */
  73318. cameraRotation: Vector2;
  73319. /**
  73320. * When set, the up vector of the camera will be updated by the rotation of the camera
  73321. */
  73322. updateUpVectorFromRotation: boolean;
  73323. private _tmpQuaternion;
  73324. /**
  73325. * Define the current rotation of the camera
  73326. */
  73327. rotation: Vector3;
  73328. /**
  73329. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73330. */
  73331. rotationQuaternion: Quaternion;
  73332. /**
  73333. * Define the current speed of the camera
  73334. */
  73335. speed: number;
  73336. /**
  73337. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73338. * around all axis.
  73339. */
  73340. noRotationConstraint: boolean;
  73341. /**
  73342. * Define the current target of the camera as an object or a position.
  73343. */
  73344. lockedTarget: any;
  73345. /** @hidden */
  73346. _currentTarget: Vector3;
  73347. /** @hidden */
  73348. _initialFocalDistance: number;
  73349. /** @hidden */
  73350. _viewMatrix: Matrix;
  73351. /** @hidden */
  73352. _camMatrix: Matrix;
  73353. /** @hidden */
  73354. _cameraTransformMatrix: Matrix;
  73355. /** @hidden */
  73356. _cameraRotationMatrix: Matrix;
  73357. /** @hidden */
  73358. _referencePoint: Vector3;
  73359. /** @hidden */
  73360. _transformedReferencePoint: Vector3;
  73361. protected _globalCurrentTarget: Vector3;
  73362. protected _globalCurrentUpVector: Vector3;
  73363. /** @hidden */
  73364. _reset: () => void;
  73365. private _defaultUp;
  73366. /**
  73367. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73368. * This is the base of the follow, arc rotate cameras and Free camera
  73369. * @see http://doc.babylonjs.com/features/cameras
  73370. * @param name Defines the name of the camera in the scene
  73371. * @param position Defines the start position of the camera in the scene
  73372. * @param scene Defines the scene the camera belongs to
  73373. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73374. */
  73375. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73376. /**
  73377. * Gets the position in front of the camera at a given distance.
  73378. * @param distance The distance from the camera we want the position to be
  73379. * @returns the position
  73380. */
  73381. getFrontPosition(distance: number): Vector3;
  73382. /** @hidden */
  73383. _getLockedTargetPosition(): Nullable<Vector3>;
  73384. private _storedPosition;
  73385. private _storedRotation;
  73386. private _storedRotationQuaternion;
  73387. /**
  73388. * Store current camera state of the camera (fov, position, rotation, etc..)
  73389. * @returns the camera
  73390. */
  73391. storeState(): Camera;
  73392. /**
  73393. * Restored camera state. You must call storeState() first
  73394. * @returns whether it was successful or not
  73395. * @hidden
  73396. */
  73397. _restoreStateValues(): boolean;
  73398. /** @hidden */
  73399. _initCache(): void;
  73400. /** @hidden */
  73401. _updateCache(ignoreParentClass?: boolean): void;
  73402. /** @hidden */
  73403. _isSynchronizedViewMatrix(): boolean;
  73404. /** @hidden */
  73405. _computeLocalCameraSpeed(): number;
  73406. /**
  73407. * Defines the target the camera should look at.
  73408. * @param target Defines the new target as a Vector or a mesh
  73409. */
  73410. setTarget(target: Vector3): void;
  73411. /**
  73412. * Return the current target position of the camera. This value is expressed in local space.
  73413. * @returns the target position
  73414. */
  73415. getTarget(): Vector3;
  73416. /** @hidden */
  73417. _decideIfNeedsToMove(): boolean;
  73418. /** @hidden */
  73419. _updatePosition(): void;
  73420. /** @hidden */
  73421. _checkInputs(): void;
  73422. protected _updateCameraRotationMatrix(): void;
  73423. /**
  73424. * 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)
  73425. * @returns the current camera
  73426. */
  73427. private _rotateUpVectorWithCameraRotationMatrix;
  73428. private _cachedRotationZ;
  73429. private _cachedQuaternionRotationZ;
  73430. /** @hidden */
  73431. _getViewMatrix(): Matrix;
  73432. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73433. /**
  73434. * @hidden
  73435. */
  73436. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73437. /**
  73438. * @hidden
  73439. */
  73440. _updateRigCameras(): void;
  73441. private _getRigCamPositionAndTarget;
  73442. /**
  73443. * Gets the current object class name.
  73444. * @return the class name
  73445. */
  73446. getClassName(): string;
  73447. }
  73448. }
  73449. declare module BABYLON {
  73450. /**
  73451. * Gather the list of keyboard event types as constants.
  73452. */
  73453. export class KeyboardEventTypes {
  73454. /**
  73455. * The keydown event is fired when a key becomes active (pressed).
  73456. */
  73457. static readonly KEYDOWN: number;
  73458. /**
  73459. * The keyup event is fired when a key has been released.
  73460. */
  73461. static readonly KEYUP: number;
  73462. }
  73463. /**
  73464. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73465. */
  73466. export class KeyboardInfo {
  73467. /**
  73468. * Defines the type of event (KeyboardEventTypes)
  73469. */
  73470. type: number;
  73471. /**
  73472. * Defines the related dom event
  73473. */
  73474. event: KeyboardEvent;
  73475. /**
  73476. * Instantiates a new keyboard info.
  73477. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73478. * @param type Defines the type of event (KeyboardEventTypes)
  73479. * @param event Defines the related dom event
  73480. */
  73481. constructor(
  73482. /**
  73483. * Defines the type of event (KeyboardEventTypes)
  73484. */
  73485. type: number,
  73486. /**
  73487. * Defines the related dom event
  73488. */
  73489. event: KeyboardEvent);
  73490. }
  73491. /**
  73492. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73493. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73494. */
  73495. export class KeyboardInfoPre extends KeyboardInfo {
  73496. /**
  73497. * Defines the type of event (KeyboardEventTypes)
  73498. */
  73499. type: number;
  73500. /**
  73501. * Defines the related dom event
  73502. */
  73503. event: KeyboardEvent;
  73504. /**
  73505. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73506. */
  73507. skipOnPointerObservable: boolean;
  73508. /**
  73509. * Instantiates a new keyboard pre info.
  73510. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73511. * @param type Defines the type of event (KeyboardEventTypes)
  73512. * @param event Defines the related dom event
  73513. */
  73514. constructor(
  73515. /**
  73516. * Defines the type of event (KeyboardEventTypes)
  73517. */
  73518. type: number,
  73519. /**
  73520. * Defines the related dom event
  73521. */
  73522. event: KeyboardEvent);
  73523. }
  73524. }
  73525. declare module BABYLON {
  73526. /**
  73527. * Manage the keyboard inputs to control the movement of a free camera.
  73528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73529. */
  73530. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73531. /**
  73532. * Defines the camera the input is attached to.
  73533. */
  73534. camera: FreeCamera;
  73535. /**
  73536. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73537. */
  73538. keysUp: number[];
  73539. /**
  73540. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73541. */
  73542. keysDown: number[];
  73543. /**
  73544. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73545. */
  73546. keysLeft: number[];
  73547. /**
  73548. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73549. */
  73550. keysRight: number[];
  73551. private _keys;
  73552. private _onCanvasBlurObserver;
  73553. private _onKeyboardObserver;
  73554. private _engine;
  73555. private _scene;
  73556. /**
  73557. * Attach the input controls to a specific dom element to get the input from.
  73558. * @param element Defines the element the controls should be listened from
  73559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73560. */
  73561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73562. /**
  73563. * Detach the current controls from the specified dom element.
  73564. * @param element Defines the element to stop listening the inputs from
  73565. */
  73566. detachControl(element: Nullable<HTMLElement>): void;
  73567. /**
  73568. * Update the current camera state depending on the inputs that have been used this frame.
  73569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73570. */
  73571. checkInputs(): void;
  73572. /**
  73573. * Gets the class name of the current intput.
  73574. * @returns the class name
  73575. */
  73576. getClassName(): string;
  73577. /** @hidden */
  73578. _onLostFocus(): void;
  73579. /**
  73580. * Get the friendly name associated with the input class.
  73581. * @returns the input friendly name
  73582. */
  73583. getSimpleName(): string;
  73584. }
  73585. }
  73586. declare module BABYLON {
  73587. /**
  73588. * Interface describing all the common properties and methods a shadow light needs to implement.
  73589. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73590. * as well as binding the different shadow properties to the effects.
  73591. */
  73592. export interface IShadowLight extends Light {
  73593. /**
  73594. * The light id in the scene (used in scene.findLighById for instance)
  73595. */
  73596. id: string;
  73597. /**
  73598. * The position the shdow will be casted from.
  73599. */
  73600. position: Vector3;
  73601. /**
  73602. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73603. */
  73604. direction: Vector3;
  73605. /**
  73606. * The transformed position. Position of the light in world space taking parenting in account.
  73607. */
  73608. transformedPosition: Vector3;
  73609. /**
  73610. * The transformed direction. Direction of the light in world space taking parenting in account.
  73611. */
  73612. transformedDirection: Vector3;
  73613. /**
  73614. * The friendly name of the light in the scene.
  73615. */
  73616. name: string;
  73617. /**
  73618. * Defines the shadow projection clipping minimum z value.
  73619. */
  73620. shadowMinZ: number;
  73621. /**
  73622. * Defines the shadow projection clipping maximum z value.
  73623. */
  73624. shadowMaxZ: number;
  73625. /**
  73626. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73627. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73628. */
  73629. computeTransformedInformation(): boolean;
  73630. /**
  73631. * Gets the scene the light belongs to.
  73632. * @returns The scene
  73633. */
  73634. getScene(): Scene;
  73635. /**
  73636. * Callback defining a custom Projection Matrix Builder.
  73637. * This can be used to override the default projection matrix computation.
  73638. */
  73639. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73640. /**
  73641. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73642. * @param matrix The materix to updated with the projection information
  73643. * @param viewMatrix The transform matrix of the light
  73644. * @param renderList The list of mesh to render in the map
  73645. * @returns The current light
  73646. */
  73647. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73648. /**
  73649. * Gets the current depth scale used in ESM.
  73650. * @returns The scale
  73651. */
  73652. getDepthScale(): number;
  73653. /**
  73654. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73655. * @returns true if a cube texture needs to be use
  73656. */
  73657. needCube(): boolean;
  73658. /**
  73659. * Detects if the projection matrix requires to be recomputed this frame.
  73660. * @returns true if it requires to be recomputed otherwise, false.
  73661. */
  73662. needProjectionMatrixCompute(): boolean;
  73663. /**
  73664. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73665. */
  73666. forceProjectionMatrixCompute(): void;
  73667. /**
  73668. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73669. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73670. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73671. */
  73672. getShadowDirection(faceIndex?: number): Vector3;
  73673. /**
  73674. * Gets the minZ used for shadow according to both the scene and the light.
  73675. * @param activeCamera The camera we are returning the min for
  73676. * @returns the depth min z
  73677. */
  73678. getDepthMinZ(activeCamera: Camera): number;
  73679. /**
  73680. * Gets the maxZ used for shadow according to both the scene and the light.
  73681. * @param activeCamera The camera we are returning the max for
  73682. * @returns the depth max z
  73683. */
  73684. getDepthMaxZ(activeCamera: Camera): number;
  73685. }
  73686. /**
  73687. * Base implementation IShadowLight
  73688. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73689. */
  73690. export abstract class ShadowLight extends Light implements IShadowLight {
  73691. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73692. protected _position: Vector3;
  73693. protected _setPosition(value: Vector3): void;
  73694. /**
  73695. * Sets the position the shadow will be casted from. Also use as the light position for both
  73696. * point and spot lights.
  73697. */
  73698. /**
  73699. * Sets the position the shadow will be casted from. Also use as the light position for both
  73700. * point and spot lights.
  73701. */
  73702. position: Vector3;
  73703. protected _direction: Vector3;
  73704. protected _setDirection(value: Vector3): void;
  73705. /**
  73706. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73707. * Also use as the light direction on spot and directional lights.
  73708. */
  73709. /**
  73710. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73711. * Also use as the light direction on spot and directional lights.
  73712. */
  73713. direction: Vector3;
  73714. private _shadowMinZ;
  73715. /**
  73716. * Gets the shadow projection clipping minimum z value.
  73717. */
  73718. /**
  73719. * Sets the shadow projection clipping minimum z value.
  73720. */
  73721. shadowMinZ: number;
  73722. private _shadowMaxZ;
  73723. /**
  73724. * Sets the shadow projection clipping maximum z value.
  73725. */
  73726. /**
  73727. * Gets the shadow projection clipping maximum z value.
  73728. */
  73729. shadowMaxZ: number;
  73730. /**
  73731. * Callback defining a custom Projection Matrix Builder.
  73732. * This can be used to override the default projection matrix computation.
  73733. */
  73734. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73735. /**
  73736. * The transformed position. Position of the light in world space taking parenting in account.
  73737. */
  73738. transformedPosition: Vector3;
  73739. /**
  73740. * The transformed direction. Direction of the light in world space taking parenting in account.
  73741. */
  73742. transformedDirection: Vector3;
  73743. private _needProjectionMatrixCompute;
  73744. /**
  73745. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73746. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73747. */
  73748. computeTransformedInformation(): boolean;
  73749. /**
  73750. * Return the depth scale used for the shadow map.
  73751. * @returns the depth scale.
  73752. */
  73753. getDepthScale(): number;
  73754. /**
  73755. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73756. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73757. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73758. */
  73759. getShadowDirection(faceIndex?: number): Vector3;
  73760. /**
  73761. * Returns the ShadowLight absolute position in the World.
  73762. * @returns the position vector in world space
  73763. */
  73764. getAbsolutePosition(): Vector3;
  73765. /**
  73766. * Sets the ShadowLight direction toward the passed target.
  73767. * @param target The point to target in local space
  73768. * @returns the updated ShadowLight direction
  73769. */
  73770. setDirectionToTarget(target: Vector3): Vector3;
  73771. /**
  73772. * Returns the light rotation in euler definition.
  73773. * @returns the x y z rotation in local space.
  73774. */
  73775. getRotation(): Vector3;
  73776. /**
  73777. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73778. * @returns true if a cube texture needs to be use
  73779. */
  73780. needCube(): boolean;
  73781. /**
  73782. * Detects if the projection matrix requires to be recomputed this frame.
  73783. * @returns true if it requires to be recomputed otherwise, false.
  73784. */
  73785. needProjectionMatrixCompute(): boolean;
  73786. /**
  73787. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73788. */
  73789. forceProjectionMatrixCompute(): void;
  73790. /** @hidden */
  73791. _initCache(): void;
  73792. /** @hidden */
  73793. _isSynchronized(): boolean;
  73794. /**
  73795. * Computes the world matrix of the node
  73796. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73797. * @returns the world matrix
  73798. */
  73799. computeWorldMatrix(force?: boolean): Matrix;
  73800. /**
  73801. * Gets the minZ used for shadow according to both the scene and the light.
  73802. * @param activeCamera The camera we are returning the min for
  73803. * @returns the depth min z
  73804. */
  73805. getDepthMinZ(activeCamera: Camera): number;
  73806. /**
  73807. * Gets the maxZ used for shadow according to both the scene and the light.
  73808. * @param activeCamera The camera we are returning the max for
  73809. * @returns the depth max z
  73810. */
  73811. getDepthMaxZ(activeCamera: Camera): number;
  73812. /**
  73813. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73814. * @param matrix The materix to updated with the projection information
  73815. * @param viewMatrix The transform matrix of the light
  73816. * @param renderList The list of mesh to render in the map
  73817. * @returns The current light
  73818. */
  73819. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73820. }
  73821. }
  73822. declare module BABYLON {
  73823. /**
  73824. * "Static Class" containing the most commonly used helper while dealing with material for
  73825. * rendering purpose.
  73826. *
  73827. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73828. *
  73829. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73830. */
  73831. export class MaterialHelper {
  73832. /**
  73833. * Bind the current view position to an effect.
  73834. * @param effect The effect to be bound
  73835. * @param scene The scene the eyes position is used from
  73836. */
  73837. static BindEyePosition(effect: Effect, scene: Scene): void;
  73838. /**
  73839. * Helps preparing the defines values about the UVs in used in the effect.
  73840. * UVs are shared as much as we can accross channels in the shaders.
  73841. * @param texture The texture we are preparing the UVs for
  73842. * @param defines The defines to update
  73843. * @param key The channel key "diffuse", "specular"... used in the shader
  73844. */
  73845. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73846. /**
  73847. * Binds a texture matrix value to its corrsponding uniform
  73848. * @param texture The texture to bind the matrix for
  73849. * @param uniformBuffer The uniform buffer receivin the data
  73850. * @param key The channel key "diffuse", "specular"... used in the shader
  73851. */
  73852. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73853. /**
  73854. * Gets the current status of the fog (should it be enabled?)
  73855. * @param mesh defines the mesh to evaluate for fog support
  73856. * @param scene defines the hosting scene
  73857. * @returns true if fog must be enabled
  73858. */
  73859. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73860. /**
  73861. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73862. * @param mesh defines the current mesh
  73863. * @param scene defines the current scene
  73864. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73865. * @param pointsCloud defines if point cloud rendering has to be turned on
  73866. * @param fogEnabled defines if fog has to be turned on
  73867. * @param alphaTest defines if alpha testing has to be turned on
  73868. * @param defines defines the current list of defines
  73869. */
  73870. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73871. /**
  73872. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73873. * @param scene defines the current scene
  73874. * @param engine defines the current engine
  73875. * @param defines specifies the list of active defines
  73876. * @param useInstances defines if instances have to be turned on
  73877. * @param useClipPlane defines if clip plane have to be turned on
  73878. */
  73879. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73880. /**
  73881. * Prepares the defines for bones
  73882. * @param mesh The mesh containing the geometry data we will draw
  73883. * @param defines The defines to update
  73884. */
  73885. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73886. /**
  73887. * Prepares the defines for morph targets
  73888. * @param mesh The mesh containing the geometry data we will draw
  73889. * @param defines The defines to update
  73890. */
  73891. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73892. /**
  73893. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73894. * @param mesh The mesh containing the geometry data we will draw
  73895. * @param defines The defines to update
  73896. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73897. * @param useBones Precise whether bones should be used or not (override mesh info)
  73898. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73899. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73900. * @returns false if defines are considered not dirty and have not been checked
  73901. */
  73902. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73903. /**
  73904. * Prepares the defines related to multiview
  73905. * @param scene The scene we are intending to draw
  73906. * @param defines The defines to update
  73907. */
  73908. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73909. /**
  73910. * Prepares the defines related to the light information passed in parameter
  73911. * @param scene The scene we are intending to draw
  73912. * @param mesh The mesh the effect is compiling for
  73913. * @param light The light the effect is compiling for
  73914. * @param lightIndex The index of the light
  73915. * @param defines The defines to update
  73916. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73917. * @param state Defines the current state regarding what is needed (normals, etc...)
  73918. */
  73919. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73920. needNormals: boolean;
  73921. needRebuild: boolean;
  73922. shadowEnabled: boolean;
  73923. specularEnabled: boolean;
  73924. lightmapMode: boolean;
  73925. }): void;
  73926. /**
  73927. * Prepares the defines related to the light information passed in parameter
  73928. * @param scene The scene we are intending to draw
  73929. * @param mesh The mesh the effect is compiling for
  73930. * @param defines The defines to update
  73931. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73932. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73933. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73934. * @returns true if normals will be required for the rest of the effect
  73935. */
  73936. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73937. /**
  73938. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73939. * @param lightIndex defines the light index
  73940. * @param uniformsList The uniform list
  73941. * @param samplersList The sampler list
  73942. * @param projectedLightTexture defines if projected texture must be used
  73943. * @param uniformBuffersList defines an optional list of uniform buffers
  73944. */
  73945. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73946. /**
  73947. * Prepares the uniforms and samplers list to be used in the effect
  73948. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73949. * @param samplersList The sampler list
  73950. * @param defines The defines helping in the list generation
  73951. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73952. */
  73953. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73954. /**
  73955. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73956. * @param defines The defines to update while falling back
  73957. * @param fallbacks The authorized effect fallbacks
  73958. * @param maxSimultaneousLights The maximum number of lights allowed
  73959. * @param rank the current rank of the Effect
  73960. * @returns The newly affected rank
  73961. */
  73962. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73963. private static _TmpMorphInfluencers;
  73964. /**
  73965. * Prepares the list of attributes required for morph targets according to the effect defines.
  73966. * @param attribs The current list of supported attribs
  73967. * @param mesh The mesh to prepare the morph targets attributes for
  73968. * @param influencers The number of influencers
  73969. */
  73970. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73971. /**
  73972. * Prepares the list of attributes required for morph targets according to the effect defines.
  73973. * @param attribs The current list of supported attribs
  73974. * @param mesh The mesh to prepare the morph targets attributes for
  73975. * @param defines The current Defines of the effect
  73976. */
  73977. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73978. /**
  73979. * Prepares the list of attributes required for bones according to the effect defines.
  73980. * @param attribs The current list of supported attribs
  73981. * @param mesh The mesh to prepare the bones attributes for
  73982. * @param defines The current Defines of the effect
  73983. * @param fallbacks The current efffect fallback strategy
  73984. */
  73985. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73986. /**
  73987. * Check and prepare the list of attributes required for instances according to the effect defines.
  73988. * @param attribs The current list of supported attribs
  73989. * @param defines The current MaterialDefines of the effect
  73990. */
  73991. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73992. /**
  73993. * Add the list of attributes required for instances to the attribs array.
  73994. * @param attribs The current list of supported attribs
  73995. */
  73996. static PushAttributesForInstances(attribs: string[]): void;
  73997. /**
  73998. * Binds the light shadow information to the effect for the given mesh.
  73999. * @param light The light containing the generator
  74000. * @param scene The scene the lights belongs to
  74001. * @param mesh The mesh we are binding the information to render
  74002. * @param lightIndex The light index in the effect used to render the mesh
  74003. * @param effect The effect we are binding the data to
  74004. */
  74005. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74006. /**
  74007. * Binds the light information to the effect.
  74008. * @param light The light containing the generator
  74009. * @param effect The effect we are binding the data to
  74010. * @param lightIndex The light index in the effect used to render
  74011. */
  74012. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74013. /**
  74014. * Binds the lights information from the scene to the effect for the given mesh.
  74015. * @param light Light to bind
  74016. * @param lightIndex Light index
  74017. * @param scene The scene where the light belongs to
  74018. * @param mesh The mesh we are binding the information to render
  74019. * @param effect The effect we are binding the data to
  74020. * @param useSpecular Defines if specular is supported
  74021. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74022. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74023. */
  74024. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74025. /**
  74026. * Binds the lights information from the scene to the effect for the given mesh.
  74027. * @param scene The scene the lights belongs to
  74028. * @param mesh The mesh we are binding the information to render
  74029. * @param effect The effect we are binding the data to
  74030. * @param defines The generated defines for the effect
  74031. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74032. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74033. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74034. */
  74035. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74036. private static _tempFogColor;
  74037. /**
  74038. * Binds the fog information from the scene to the effect for the given mesh.
  74039. * @param scene The scene the lights belongs to
  74040. * @param mesh The mesh we are binding the information to render
  74041. * @param effect The effect we are binding the data to
  74042. * @param linearSpace Defines if the fog effect is applied in linear space
  74043. */
  74044. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74045. /**
  74046. * Binds the bones information from the mesh to the effect.
  74047. * @param mesh The mesh we are binding the information to render
  74048. * @param effect The effect we are binding the data to
  74049. */
  74050. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74051. /**
  74052. * Binds the morph targets information from the mesh to the effect.
  74053. * @param abstractMesh The mesh we are binding the information to render
  74054. * @param effect The effect we are binding the data to
  74055. */
  74056. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74057. /**
  74058. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74059. * @param defines The generated defines used in the effect
  74060. * @param effect The effect we are binding the data to
  74061. * @param scene The scene we are willing to render with logarithmic scale for
  74062. */
  74063. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74064. /**
  74065. * Binds the clip plane information from the scene to the effect.
  74066. * @param scene The scene the clip plane information are extracted from
  74067. * @param effect The effect we are binding the data to
  74068. */
  74069. static BindClipPlane(effect: Effect, scene: Scene): void;
  74070. }
  74071. }
  74072. declare module BABYLON {
  74073. /** @hidden */
  74074. export var packingFunctions: {
  74075. name: string;
  74076. shader: string;
  74077. };
  74078. }
  74079. declare module BABYLON {
  74080. /** @hidden */
  74081. export var shadowMapPixelShader: {
  74082. name: string;
  74083. shader: string;
  74084. };
  74085. }
  74086. declare module BABYLON {
  74087. /** @hidden */
  74088. export var bonesDeclaration: {
  74089. name: string;
  74090. shader: string;
  74091. };
  74092. }
  74093. declare module BABYLON {
  74094. /** @hidden */
  74095. export var morphTargetsVertexGlobalDeclaration: {
  74096. name: string;
  74097. shader: string;
  74098. };
  74099. }
  74100. declare module BABYLON {
  74101. /** @hidden */
  74102. export var morphTargetsVertexDeclaration: {
  74103. name: string;
  74104. shader: string;
  74105. };
  74106. }
  74107. declare module BABYLON {
  74108. /** @hidden */
  74109. export var instancesDeclaration: {
  74110. name: string;
  74111. shader: string;
  74112. };
  74113. }
  74114. declare module BABYLON {
  74115. /** @hidden */
  74116. export var helperFunctions: {
  74117. name: string;
  74118. shader: string;
  74119. };
  74120. }
  74121. declare module BABYLON {
  74122. /** @hidden */
  74123. export var morphTargetsVertex: {
  74124. name: string;
  74125. shader: string;
  74126. };
  74127. }
  74128. declare module BABYLON {
  74129. /** @hidden */
  74130. export var instancesVertex: {
  74131. name: string;
  74132. shader: string;
  74133. };
  74134. }
  74135. declare module BABYLON {
  74136. /** @hidden */
  74137. export var bonesVertex: {
  74138. name: string;
  74139. shader: string;
  74140. };
  74141. }
  74142. declare module BABYLON {
  74143. /** @hidden */
  74144. export var shadowMapVertexShader: {
  74145. name: string;
  74146. shader: string;
  74147. };
  74148. }
  74149. declare module BABYLON {
  74150. /** @hidden */
  74151. export var depthBoxBlurPixelShader: {
  74152. name: string;
  74153. shader: string;
  74154. };
  74155. }
  74156. declare module BABYLON {
  74157. /**
  74158. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74159. */
  74160. export interface ICustomShaderOptions {
  74161. /**
  74162. * Gets or sets the custom shader name to use
  74163. */
  74164. shaderName: string;
  74165. /**
  74166. * The list of attribute names used in the shader
  74167. */
  74168. attributes?: string[];
  74169. /**
  74170. * The list of unifrom names used in the shader
  74171. */
  74172. uniforms?: string[];
  74173. /**
  74174. * The list of sampler names used in the shader
  74175. */
  74176. samplers?: string[];
  74177. /**
  74178. * The list of defines used in the shader
  74179. */
  74180. defines?: string[];
  74181. }
  74182. /**
  74183. * Interface to implement to create a shadow generator compatible with BJS.
  74184. */
  74185. export interface IShadowGenerator {
  74186. /**
  74187. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74188. * @returns The render target texture if present otherwise, null
  74189. */
  74190. getShadowMap(): Nullable<RenderTargetTexture>;
  74191. /**
  74192. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74193. * @returns The render target texture if the shadow map is present otherwise, null
  74194. */
  74195. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74196. /**
  74197. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74198. * @param subMesh The submesh we want to render in the shadow map
  74199. * @param useInstances Defines wether will draw in the map using instances
  74200. * @returns true if ready otherwise, false
  74201. */
  74202. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74203. /**
  74204. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74205. * @param defines Defines of the material we want to update
  74206. * @param lightIndex Index of the light in the enabled light list of the material
  74207. */
  74208. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74209. /**
  74210. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74211. * defined in the generator but impacting the effect).
  74212. * It implies the unifroms available on the materials are the standard BJS ones.
  74213. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74214. * @param effect The effect we are binfing the information for
  74215. */
  74216. bindShadowLight(lightIndex: string, effect: Effect): void;
  74217. /**
  74218. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74219. * (eq to shadow prjection matrix * light transform matrix)
  74220. * @returns The transform matrix used to create the shadow map
  74221. */
  74222. getTransformMatrix(): Matrix;
  74223. /**
  74224. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74225. * Cube and 2D textures for instance.
  74226. */
  74227. recreateShadowMap(): void;
  74228. /**
  74229. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74230. * @param onCompiled Callback triggered at the and of the effects compilation
  74231. * @param options Sets of optional options forcing the compilation with different modes
  74232. */
  74233. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74234. useInstances: boolean;
  74235. }>): void;
  74236. /**
  74237. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74238. * @param options Sets of optional options forcing the compilation with different modes
  74239. * @returns A promise that resolves when the compilation completes
  74240. */
  74241. forceCompilationAsync(options?: Partial<{
  74242. useInstances: boolean;
  74243. }>): Promise<void>;
  74244. /**
  74245. * Serializes the shadow generator setup to a json object.
  74246. * @returns The serialized JSON object
  74247. */
  74248. serialize(): any;
  74249. /**
  74250. * Disposes the Shadow map and related Textures and effects.
  74251. */
  74252. dispose(): void;
  74253. }
  74254. /**
  74255. * Default implementation IShadowGenerator.
  74256. * This is the main object responsible of generating shadows in the framework.
  74257. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74258. */
  74259. export class ShadowGenerator implements IShadowGenerator {
  74260. /**
  74261. * Shadow generator mode None: no filtering applied.
  74262. */
  74263. static readonly FILTER_NONE: number;
  74264. /**
  74265. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74266. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74267. */
  74268. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74269. /**
  74270. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74271. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74272. */
  74273. static readonly FILTER_POISSONSAMPLING: number;
  74274. /**
  74275. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74276. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74277. */
  74278. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74279. /**
  74280. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74281. * edge artifacts on steep falloff.
  74282. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74283. */
  74284. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74285. /**
  74286. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74287. * edge artifacts on steep falloff.
  74288. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74289. */
  74290. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74291. /**
  74292. * Shadow generator mode PCF: Percentage Closer Filtering
  74293. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74294. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74295. */
  74296. static readonly FILTER_PCF: number;
  74297. /**
  74298. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74299. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74300. * Contact Hardening
  74301. */
  74302. static readonly FILTER_PCSS: number;
  74303. /**
  74304. * Reserved for PCF and PCSS
  74305. * Highest Quality.
  74306. *
  74307. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74308. *
  74309. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74310. */
  74311. static readonly QUALITY_HIGH: number;
  74312. /**
  74313. * Reserved for PCF and PCSS
  74314. * Good tradeoff for quality/perf cross devices
  74315. *
  74316. * Execute PCF on a 3*3 kernel.
  74317. *
  74318. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74319. */
  74320. static readonly QUALITY_MEDIUM: number;
  74321. /**
  74322. * Reserved for PCF and PCSS
  74323. * The lowest quality but the fastest.
  74324. *
  74325. * Execute PCF on a 1*1 kernel.
  74326. *
  74327. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74328. */
  74329. static readonly QUALITY_LOW: number;
  74330. /** Gets or sets the custom shader name to use */
  74331. customShaderOptions: ICustomShaderOptions;
  74332. /**
  74333. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74334. */
  74335. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74336. /**
  74337. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74338. */
  74339. onAfterShadowMapRenderObservable: Observable<Effect>;
  74340. /**
  74341. * Observable triggered before a mesh is rendered in the shadow map.
  74342. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74343. */
  74344. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74345. /**
  74346. * Observable triggered after a mesh is rendered in the shadow map.
  74347. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74348. */
  74349. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74350. private _bias;
  74351. /**
  74352. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74353. */
  74354. /**
  74355. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74356. */
  74357. bias: number;
  74358. private _normalBias;
  74359. /**
  74360. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74361. */
  74362. /**
  74363. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74364. */
  74365. normalBias: number;
  74366. private _blurBoxOffset;
  74367. /**
  74368. * Gets the blur box offset: offset applied during the blur pass.
  74369. * Only useful if useKernelBlur = false
  74370. */
  74371. /**
  74372. * Sets the blur box offset: offset applied during the blur pass.
  74373. * Only useful if useKernelBlur = false
  74374. */
  74375. blurBoxOffset: number;
  74376. private _blurScale;
  74377. /**
  74378. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74379. * 2 means half of the size.
  74380. */
  74381. /**
  74382. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74383. * 2 means half of the size.
  74384. */
  74385. blurScale: number;
  74386. private _blurKernel;
  74387. /**
  74388. * Gets the blur kernel: kernel size of the blur pass.
  74389. * Only useful if useKernelBlur = true
  74390. */
  74391. /**
  74392. * Sets the blur kernel: kernel size of the blur pass.
  74393. * Only useful if useKernelBlur = true
  74394. */
  74395. blurKernel: number;
  74396. private _useKernelBlur;
  74397. /**
  74398. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74399. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74400. */
  74401. /**
  74402. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74403. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74404. */
  74405. useKernelBlur: boolean;
  74406. private _depthScale;
  74407. /**
  74408. * Gets the depth scale used in ESM mode.
  74409. */
  74410. /**
  74411. * Sets the depth scale used in ESM mode.
  74412. * This can override the scale stored on the light.
  74413. */
  74414. depthScale: number;
  74415. private _filter;
  74416. /**
  74417. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74418. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74419. */
  74420. /**
  74421. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74422. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74423. */
  74424. filter: number;
  74425. /**
  74426. * Gets if the current filter is set to Poisson Sampling.
  74427. */
  74428. /**
  74429. * Sets the current filter to Poisson Sampling.
  74430. */
  74431. usePoissonSampling: boolean;
  74432. /**
  74433. * Gets if the current filter is set to ESM.
  74434. */
  74435. /**
  74436. * Sets the current filter is to ESM.
  74437. */
  74438. useExponentialShadowMap: boolean;
  74439. /**
  74440. * Gets if the current filter is set to filtered ESM.
  74441. */
  74442. /**
  74443. * Gets if the current filter is set to filtered ESM.
  74444. */
  74445. useBlurExponentialShadowMap: boolean;
  74446. /**
  74447. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74448. * exponential to prevent steep falloff artifacts).
  74449. */
  74450. /**
  74451. * Sets the current filter to "close ESM" (using the inverse of the
  74452. * exponential to prevent steep falloff artifacts).
  74453. */
  74454. useCloseExponentialShadowMap: boolean;
  74455. /**
  74456. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74457. * exponential to prevent steep falloff artifacts).
  74458. */
  74459. /**
  74460. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74461. * exponential to prevent steep falloff artifacts).
  74462. */
  74463. useBlurCloseExponentialShadowMap: boolean;
  74464. /**
  74465. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74466. */
  74467. /**
  74468. * Sets the current filter to "PCF" (percentage closer filtering).
  74469. */
  74470. usePercentageCloserFiltering: boolean;
  74471. private _filteringQuality;
  74472. /**
  74473. * Gets the PCF or PCSS Quality.
  74474. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74475. */
  74476. /**
  74477. * Sets the PCF or PCSS Quality.
  74478. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74479. */
  74480. filteringQuality: number;
  74481. /**
  74482. * Gets if the current filter is set to "PCSS" (contact hardening).
  74483. */
  74484. /**
  74485. * Sets the current filter to "PCSS" (contact hardening).
  74486. */
  74487. useContactHardeningShadow: boolean;
  74488. private _contactHardeningLightSizeUVRatio;
  74489. /**
  74490. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74491. * Using a ratio helps keeping shape stability independently of the map size.
  74492. *
  74493. * It does not account for the light projection as it was having too much
  74494. * instability during the light setup or during light position changes.
  74495. *
  74496. * Only valid if useContactHardeningShadow is true.
  74497. */
  74498. /**
  74499. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74500. * Using a ratio helps keeping shape stability independently of the map size.
  74501. *
  74502. * It does not account for the light projection as it was having too much
  74503. * instability during the light setup or during light position changes.
  74504. *
  74505. * Only valid if useContactHardeningShadow is true.
  74506. */
  74507. contactHardeningLightSizeUVRatio: number;
  74508. private _darkness;
  74509. /** Gets or sets the actual darkness of a shadow */
  74510. darkness: number;
  74511. /**
  74512. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74513. * 0 means strongest and 1 would means no shadow.
  74514. * @returns the darkness.
  74515. */
  74516. getDarkness(): number;
  74517. /**
  74518. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74519. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74520. * @returns the shadow generator allowing fluent coding.
  74521. */
  74522. setDarkness(darkness: number): ShadowGenerator;
  74523. private _transparencyShadow;
  74524. /** Gets or sets the ability to have transparent shadow */
  74525. transparencyShadow: boolean;
  74526. /**
  74527. * Sets the ability to have transparent shadow (boolean).
  74528. * @param transparent True if transparent else False
  74529. * @returns the shadow generator allowing fluent coding
  74530. */
  74531. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74532. private _shadowMap;
  74533. private _shadowMap2;
  74534. /**
  74535. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74536. * @returns The render target texture if present otherwise, null
  74537. */
  74538. getShadowMap(): Nullable<RenderTargetTexture>;
  74539. /**
  74540. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74541. * @returns The render target texture if the shadow map is present otherwise, null
  74542. */
  74543. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74544. /**
  74545. * Gets the class name of that object
  74546. * @returns "ShadowGenerator"
  74547. */
  74548. getClassName(): string;
  74549. /**
  74550. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74551. * @param mesh Mesh to add
  74552. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74553. * @returns the Shadow Generator itself
  74554. */
  74555. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74556. /**
  74557. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74558. * @param mesh Mesh to remove
  74559. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74560. * @returns the Shadow Generator itself
  74561. */
  74562. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74563. /**
  74564. * Controls the extent to which the shadows fade out at the edge of the frustum
  74565. * Used only by directionals and spots
  74566. */
  74567. frustumEdgeFalloff: number;
  74568. private _light;
  74569. /**
  74570. * Returns the associated light object.
  74571. * @returns the light generating the shadow
  74572. */
  74573. getLight(): IShadowLight;
  74574. /**
  74575. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74576. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74577. * It might on the other hand introduce peter panning.
  74578. */
  74579. forceBackFacesOnly: boolean;
  74580. private _scene;
  74581. private _lightDirection;
  74582. private _effect;
  74583. private _viewMatrix;
  74584. private _projectionMatrix;
  74585. private _transformMatrix;
  74586. private _cachedPosition;
  74587. private _cachedDirection;
  74588. private _cachedDefines;
  74589. private _currentRenderID;
  74590. private _boxBlurPostprocess;
  74591. private _kernelBlurXPostprocess;
  74592. private _kernelBlurYPostprocess;
  74593. private _blurPostProcesses;
  74594. private _mapSize;
  74595. private _currentFaceIndex;
  74596. private _currentFaceIndexCache;
  74597. private _textureType;
  74598. private _defaultTextureMatrix;
  74599. /** @hidden */
  74600. static _SceneComponentInitialization: (scene: Scene) => void;
  74601. /**
  74602. * Creates a ShadowGenerator object.
  74603. * A ShadowGenerator is the required tool to use the shadows.
  74604. * Each light casting shadows needs to use its own ShadowGenerator.
  74605. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74606. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74607. * @param light The light object generating the shadows.
  74608. * @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.
  74609. */
  74610. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74611. private _initializeGenerator;
  74612. private _initializeShadowMap;
  74613. private _initializeBlurRTTAndPostProcesses;
  74614. private _renderForShadowMap;
  74615. private _renderSubMeshForShadowMap;
  74616. private _applyFilterValues;
  74617. /**
  74618. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74619. * @param onCompiled Callback triggered at the and of the effects compilation
  74620. * @param options Sets of optional options forcing the compilation with different modes
  74621. */
  74622. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74623. useInstances: boolean;
  74624. }>): void;
  74625. /**
  74626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74627. * @param options Sets of optional options forcing the compilation with different modes
  74628. * @returns A promise that resolves when the compilation completes
  74629. */
  74630. forceCompilationAsync(options?: Partial<{
  74631. useInstances: boolean;
  74632. }>): Promise<void>;
  74633. /**
  74634. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74635. * @param subMesh The submesh we want to render in the shadow map
  74636. * @param useInstances Defines wether will draw in the map using instances
  74637. * @returns true if ready otherwise, false
  74638. */
  74639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74640. /**
  74641. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74642. * @param defines Defines of the material we want to update
  74643. * @param lightIndex Index of the light in the enabled light list of the material
  74644. */
  74645. prepareDefines(defines: any, lightIndex: number): void;
  74646. /**
  74647. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74648. * defined in the generator but impacting the effect).
  74649. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74650. * @param effect The effect we are binfing the information for
  74651. */
  74652. bindShadowLight(lightIndex: string, effect: Effect): void;
  74653. /**
  74654. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74655. * (eq to shadow prjection matrix * light transform matrix)
  74656. * @returns The transform matrix used to create the shadow map
  74657. */
  74658. getTransformMatrix(): Matrix;
  74659. /**
  74660. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74661. * Cube and 2D textures for instance.
  74662. */
  74663. recreateShadowMap(): void;
  74664. private _disposeBlurPostProcesses;
  74665. private _disposeRTTandPostProcesses;
  74666. /**
  74667. * Disposes the ShadowGenerator.
  74668. * Returns nothing.
  74669. */
  74670. dispose(): void;
  74671. /**
  74672. * Serializes the shadow generator setup to a json object.
  74673. * @returns The serialized JSON object
  74674. */
  74675. serialize(): any;
  74676. /**
  74677. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74678. * @param parsedShadowGenerator The JSON object to parse
  74679. * @param scene The scene to create the shadow map for
  74680. * @returns The parsed shadow generator
  74681. */
  74682. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74683. }
  74684. }
  74685. declare module BABYLON {
  74686. /**
  74687. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74688. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74689. * 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.
  74690. */
  74691. export abstract class Light extends Node {
  74692. /**
  74693. * Falloff Default: light is falling off following the material specification:
  74694. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74695. */
  74696. static readonly FALLOFF_DEFAULT: number;
  74697. /**
  74698. * Falloff Physical: light is falling off following the inverse squared distance law.
  74699. */
  74700. static readonly FALLOFF_PHYSICAL: number;
  74701. /**
  74702. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74703. * to enhance interoperability with other engines.
  74704. */
  74705. static readonly FALLOFF_GLTF: number;
  74706. /**
  74707. * Falloff Standard: light is falling off like in the standard material
  74708. * to enhance interoperability with other materials.
  74709. */
  74710. static readonly FALLOFF_STANDARD: number;
  74711. /**
  74712. * If every light affecting the material is in this lightmapMode,
  74713. * material.lightmapTexture adds or multiplies
  74714. * (depends on material.useLightmapAsShadowmap)
  74715. * after every other light calculations.
  74716. */
  74717. static readonly LIGHTMAP_DEFAULT: number;
  74718. /**
  74719. * material.lightmapTexture as only diffuse lighting from this light
  74720. * adds only specular lighting from this light
  74721. * adds dynamic shadows
  74722. */
  74723. static readonly LIGHTMAP_SPECULAR: number;
  74724. /**
  74725. * material.lightmapTexture as only lighting
  74726. * no light calculation from this light
  74727. * only adds dynamic shadows from this light
  74728. */
  74729. static readonly LIGHTMAP_SHADOWSONLY: number;
  74730. /**
  74731. * Each light type uses the default quantity according to its type:
  74732. * point/spot lights use luminous intensity
  74733. * directional lights use illuminance
  74734. */
  74735. static readonly INTENSITYMODE_AUTOMATIC: number;
  74736. /**
  74737. * lumen (lm)
  74738. */
  74739. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74740. /**
  74741. * candela (lm/sr)
  74742. */
  74743. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74744. /**
  74745. * lux (lm/m^2)
  74746. */
  74747. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74748. /**
  74749. * nit (cd/m^2)
  74750. */
  74751. static readonly INTENSITYMODE_LUMINANCE: number;
  74752. /**
  74753. * Light type const id of the point light.
  74754. */
  74755. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74756. /**
  74757. * Light type const id of the directional light.
  74758. */
  74759. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74760. /**
  74761. * Light type const id of the spot light.
  74762. */
  74763. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74764. /**
  74765. * Light type const id of the hemispheric light.
  74766. */
  74767. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74768. /**
  74769. * Diffuse gives the basic color to an object.
  74770. */
  74771. diffuse: Color3;
  74772. /**
  74773. * Specular produces a highlight color on an object.
  74774. * Note: This is note affecting PBR materials.
  74775. */
  74776. specular: Color3;
  74777. /**
  74778. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74779. * falling off base on range or angle.
  74780. * This can be set to any values in Light.FALLOFF_x.
  74781. *
  74782. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74783. * other types of materials.
  74784. */
  74785. falloffType: number;
  74786. /**
  74787. * Strength of the light.
  74788. * Note: By default it is define in the framework own unit.
  74789. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74790. */
  74791. intensity: number;
  74792. private _range;
  74793. protected _inverseSquaredRange: number;
  74794. /**
  74795. * Defines how far from the source the light is impacting in scene units.
  74796. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74797. */
  74798. /**
  74799. * Defines how far from the source the light is impacting in scene units.
  74800. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74801. */
  74802. range: number;
  74803. /**
  74804. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74805. * of light.
  74806. */
  74807. private _photometricScale;
  74808. private _intensityMode;
  74809. /**
  74810. * Gets the photometric scale used to interpret the intensity.
  74811. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74812. */
  74813. /**
  74814. * Sets the photometric scale used to interpret the intensity.
  74815. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74816. */
  74817. intensityMode: number;
  74818. private _radius;
  74819. /**
  74820. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74821. */
  74822. /**
  74823. * sets the light radius used by PBR Materials to simulate soft area lights.
  74824. */
  74825. radius: number;
  74826. private _renderPriority;
  74827. /**
  74828. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74829. * exceeding the number allowed of the materials.
  74830. */
  74831. renderPriority: number;
  74832. private _shadowEnabled;
  74833. /**
  74834. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74835. * the current shadow generator.
  74836. */
  74837. /**
  74838. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74839. * the current shadow generator.
  74840. */
  74841. shadowEnabled: boolean;
  74842. private _includedOnlyMeshes;
  74843. /**
  74844. * Gets the only meshes impacted by this light.
  74845. */
  74846. /**
  74847. * Sets the only meshes impacted by this light.
  74848. */
  74849. includedOnlyMeshes: AbstractMesh[];
  74850. private _excludedMeshes;
  74851. /**
  74852. * Gets the meshes not impacted by this light.
  74853. */
  74854. /**
  74855. * Sets the meshes not impacted by this light.
  74856. */
  74857. excludedMeshes: AbstractMesh[];
  74858. private _excludeWithLayerMask;
  74859. /**
  74860. * Gets the layer id use to find what meshes are not impacted by the light.
  74861. * Inactive if 0
  74862. */
  74863. /**
  74864. * Sets the layer id use to find what meshes are not impacted by the light.
  74865. * Inactive if 0
  74866. */
  74867. excludeWithLayerMask: number;
  74868. private _includeOnlyWithLayerMask;
  74869. /**
  74870. * Gets the layer id use to find what meshes are impacted by the light.
  74871. * Inactive if 0
  74872. */
  74873. /**
  74874. * Sets the layer id use to find what meshes are impacted by the light.
  74875. * Inactive if 0
  74876. */
  74877. includeOnlyWithLayerMask: number;
  74878. private _lightmapMode;
  74879. /**
  74880. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74881. */
  74882. /**
  74883. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74884. */
  74885. lightmapMode: number;
  74886. /**
  74887. * Shadow generator associted to the light.
  74888. * @hidden Internal use only.
  74889. */
  74890. _shadowGenerator: Nullable<IShadowGenerator>;
  74891. /**
  74892. * @hidden Internal use only.
  74893. */
  74894. _excludedMeshesIds: string[];
  74895. /**
  74896. * @hidden Internal use only.
  74897. */
  74898. _includedOnlyMeshesIds: string[];
  74899. /**
  74900. * The current light unifom buffer.
  74901. * @hidden Internal use only.
  74902. */
  74903. _uniformBuffer: UniformBuffer;
  74904. /**
  74905. * Creates a Light object in the scene.
  74906. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74907. * @param name The firendly name of the light
  74908. * @param scene The scene the light belongs too
  74909. */
  74910. constructor(name: string, scene: Scene);
  74911. protected abstract _buildUniformLayout(): void;
  74912. /**
  74913. * Sets the passed Effect "effect" with the Light information.
  74914. * @param effect The effect to update
  74915. * @param lightIndex The index of the light in the effect to update
  74916. * @returns The light
  74917. */
  74918. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74919. /**
  74920. * Sets the passed Effect "effect" with the Light information.
  74921. * @param effect The effect to update
  74922. * @param lightDataUniformName The uniform used to store light data (position or direction)
  74923. * @returns The light
  74924. */
  74925. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  74926. /**
  74927. * Returns the string "Light".
  74928. * @returns the class name
  74929. */
  74930. getClassName(): string;
  74931. /** @hidden */
  74932. readonly _isLight: boolean;
  74933. /**
  74934. * Converts the light information to a readable string for debug purpose.
  74935. * @param fullDetails Supports for multiple levels of logging within scene loading
  74936. * @returns the human readable light info
  74937. */
  74938. toString(fullDetails?: boolean): string;
  74939. /** @hidden */
  74940. protected _syncParentEnabledState(): void;
  74941. /**
  74942. * Set the enabled state of this node.
  74943. * @param value - the new enabled state
  74944. */
  74945. setEnabled(value: boolean): void;
  74946. /**
  74947. * Returns the Light associated shadow generator if any.
  74948. * @return the associated shadow generator.
  74949. */
  74950. getShadowGenerator(): Nullable<IShadowGenerator>;
  74951. /**
  74952. * Returns a Vector3, the absolute light position in the World.
  74953. * @returns the world space position of the light
  74954. */
  74955. getAbsolutePosition(): Vector3;
  74956. /**
  74957. * Specifies if the light will affect the passed mesh.
  74958. * @param mesh The mesh to test against the light
  74959. * @return true the mesh is affected otherwise, false.
  74960. */
  74961. canAffectMesh(mesh: AbstractMesh): boolean;
  74962. /**
  74963. * Sort function to order lights for rendering.
  74964. * @param a First Light object to compare to second.
  74965. * @param b Second Light object to compare first.
  74966. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74967. */
  74968. static CompareLightsPriority(a: Light, b: Light): number;
  74969. /**
  74970. * Releases resources associated with this node.
  74971. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74972. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74973. */
  74974. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74975. /**
  74976. * Returns the light type ID (integer).
  74977. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74978. */
  74979. getTypeID(): number;
  74980. /**
  74981. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74982. * @returns the scaled intensity in intensity mode unit
  74983. */
  74984. getScaledIntensity(): number;
  74985. /**
  74986. * Returns a new Light object, named "name", from the current one.
  74987. * @param name The name of the cloned light
  74988. * @returns the new created light
  74989. */
  74990. clone(name: string): Nullable<Light>;
  74991. /**
  74992. * Serializes the current light into a Serialization object.
  74993. * @returns the serialized object.
  74994. */
  74995. serialize(): any;
  74996. /**
  74997. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74998. * This new light is named "name" and added to the passed scene.
  74999. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75000. * @param name The friendly name of the light
  75001. * @param scene The scene the new light will belong to
  75002. * @returns the constructor function
  75003. */
  75004. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75005. /**
  75006. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75007. * @param parsedLight The JSON representation of the light
  75008. * @param scene The scene to create the parsed light in
  75009. * @returns the created light after parsing
  75010. */
  75011. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75012. private _hookArrayForExcluded;
  75013. private _hookArrayForIncludedOnly;
  75014. private _resyncMeshes;
  75015. /**
  75016. * Forces the meshes to update their light related information in their rendering used effects
  75017. * @hidden Internal Use Only
  75018. */
  75019. _markMeshesAsLightDirty(): void;
  75020. /**
  75021. * Recomputes the cached photometric scale if needed.
  75022. */
  75023. private _computePhotometricScale;
  75024. /**
  75025. * Returns the Photometric Scale according to the light type and intensity mode.
  75026. */
  75027. private _getPhotometricScale;
  75028. /**
  75029. * Reorder the light in the scene according to their defined priority.
  75030. * @hidden Internal Use Only
  75031. */
  75032. _reorderLightsInScene(): void;
  75033. /**
  75034. * Prepares the list of defines specific to the light type.
  75035. * @param defines the list of defines
  75036. * @param lightIndex defines the index of the light for the effect
  75037. */
  75038. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75039. }
  75040. }
  75041. declare module BABYLON {
  75042. /**
  75043. * Interface used to define Action
  75044. */
  75045. export interface IAction {
  75046. /**
  75047. * Trigger for the action
  75048. */
  75049. trigger: number;
  75050. /** Options of the trigger */
  75051. triggerOptions: any;
  75052. /**
  75053. * Gets the trigger parameters
  75054. * @returns the trigger parameters
  75055. */
  75056. getTriggerParameter(): any;
  75057. /**
  75058. * Internal only - executes current action event
  75059. * @hidden
  75060. */
  75061. _executeCurrent(evt?: ActionEvent): void;
  75062. /**
  75063. * Serialize placeholder for child classes
  75064. * @param parent of child
  75065. * @returns the serialized object
  75066. */
  75067. serialize(parent: any): any;
  75068. /**
  75069. * Internal only
  75070. * @hidden
  75071. */
  75072. _prepare(): void;
  75073. /**
  75074. * Internal only - manager for action
  75075. * @hidden
  75076. */
  75077. _actionManager: AbstractActionManager;
  75078. /**
  75079. * Adds action to chain of actions, may be a DoNothingAction
  75080. * @param action defines the next action to execute
  75081. * @returns The action passed in
  75082. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75083. */
  75084. then(action: IAction): IAction;
  75085. }
  75086. /**
  75087. * The action to be carried out following a trigger
  75088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75089. */
  75090. export class Action implements IAction {
  75091. /** the trigger, with or without parameters, for the action */
  75092. triggerOptions: any;
  75093. /**
  75094. * Trigger for the action
  75095. */
  75096. trigger: number;
  75097. /**
  75098. * Internal only - manager for action
  75099. * @hidden
  75100. */
  75101. _actionManager: ActionManager;
  75102. private _nextActiveAction;
  75103. private _child;
  75104. private _condition?;
  75105. private _triggerParameter;
  75106. /**
  75107. * An event triggered prior to action being executed.
  75108. */
  75109. onBeforeExecuteObservable: Observable<Action>;
  75110. /**
  75111. * Creates a new Action
  75112. * @param triggerOptions the trigger, with or without parameters, for the action
  75113. * @param condition an optional determinant of action
  75114. */
  75115. constructor(
  75116. /** the trigger, with or without parameters, for the action */
  75117. triggerOptions: any, condition?: Condition);
  75118. /**
  75119. * Internal only
  75120. * @hidden
  75121. */
  75122. _prepare(): void;
  75123. /**
  75124. * Gets the trigger parameters
  75125. * @returns the trigger parameters
  75126. */
  75127. getTriggerParameter(): any;
  75128. /**
  75129. * Internal only - executes current action event
  75130. * @hidden
  75131. */
  75132. _executeCurrent(evt?: ActionEvent): void;
  75133. /**
  75134. * Execute placeholder for child classes
  75135. * @param evt optional action event
  75136. */
  75137. execute(evt?: ActionEvent): void;
  75138. /**
  75139. * Skips to next active action
  75140. */
  75141. skipToNextActiveAction(): void;
  75142. /**
  75143. * Adds action to chain of actions, may be a DoNothingAction
  75144. * @param action defines the next action to execute
  75145. * @returns The action passed in
  75146. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75147. */
  75148. then(action: Action): Action;
  75149. /**
  75150. * Internal only
  75151. * @hidden
  75152. */
  75153. _getProperty(propertyPath: string): string;
  75154. /**
  75155. * Internal only
  75156. * @hidden
  75157. */
  75158. _getEffectiveTarget(target: any, propertyPath: string): any;
  75159. /**
  75160. * Serialize placeholder for child classes
  75161. * @param parent of child
  75162. * @returns the serialized object
  75163. */
  75164. serialize(parent: any): any;
  75165. /**
  75166. * Internal only called by serialize
  75167. * @hidden
  75168. */
  75169. protected _serialize(serializedAction: any, parent?: any): any;
  75170. /**
  75171. * Internal only
  75172. * @hidden
  75173. */
  75174. static _SerializeValueAsString: (value: any) => string;
  75175. /**
  75176. * Internal only
  75177. * @hidden
  75178. */
  75179. static _GetTargetProperty: (target: Node | Scene) => {
  75180. name: string;
  75181. targetType: string;
  75182. value: string;
  75183. };
  75184. }
  75185. }
  75186. declare module BABYLON {
  75187. /**
  75188. * A Condition applied to an Action
  75189. */
  75190. export class Condition {
  75191. /**
  75192. * Internal only - manager for action
  75193. * @hidden
  75194. */
  75195. _actionManager: ActionManager;
  75196. /**
  75197. * Internal only
  75198. * @hidden
  75199. */
  75200. _evaluationId: number;
  75201. /**
  75202. * Internal only
  75203. * @hidden
  75204. */
  75205. _currentResult: boolean;
  75206. /**
  75207. * Creates a new Condition
  75208. * @param actionManager the manager of the action the condition is applied to
  75209. */
  75210. constructor(actionManager: ActionManager);
  75211. /**
  75212. * Check if the current condition is valid
  75213. * @returns a boolean
  75214. */
  75215. isValid(): boolean;
  75216. /**
  75217. * Internal only
  75218. * @hidden
  75219. */
  75220. _getProperty(propertyPath: string): string;
  75221. /**
  75222. * Internal only
  75223. * @hidden
  75224. */
  75225. _getEffectiveTarget(target: any, propertyPath: string): any;
  75226. /**
  75227. * Serialize placeholder for child classes
  75228. * @returns the serialized object
  75229. */
  75230. serialize(): any;
  75231. /**
  75232. * Internal only
  75233. * @hidden
  75234. */
  75235. protected _serialize(serializedCondition: any): any;
  75236. }
  75237. /**
  75238. * Defines specific conditional operators as extensions of Condition
  75239. */
  75240. export class ValueCondition extends Condition {
  75241. /** path to specify the property of the target the conditional operator uses */
  75242. propertyPath: string;
  75243. /** the value compared by the conditional operator against the current value of the property */
  75244. value: any;
  75245. /** the conditional operator, default ValueCondition.IsEqual */
  75246. operator: number;
  75247. /**
  75248. * Internal only
  75249. * @hidden
  75250. */
  75251. private static _IsEqual;
  75252. /**
  75253. * Internal only
  75254. * @hidden
  75255. */
  75256. private static _IsDifferent;
  75257. /**
  75258. * Internal only
  75259. * @hidden
  75260. */
  75261. private static _IsGreater;
  75262. /**
  75263. * Internal only
  75264. * @hidden
  75265. */
  75266. private static _IsLesser;
  75267. /**
  75268. * returns the number for IsEqual
  75269. */
  75270. static readonly IsEqual: number;
  75271. /**
  75272. * Returns the number for IsDifferent
  75273. */
  75274. static readonly IsDifferent: number;
  75275. /**
  75276. * Returns the number for IsGreater
  75277. */
  75278. static readonly IsGreater: number;
  75279. /**
  75280. * Returns the number for IsLesser
  75281. */
  75282. static readonly IsLesser: number;
  75283. /**
  75284. * Internal only The action manager for the condition
  75285. * @hidden
  75286. */
  75287. _actionManager: ActionManager;
  75288. /**
  75289. * Internal only
  75290. * @hidden
  75291. */
  75292. private _target;
  75293. /**
  75294. * Internal only
  75295. * @hidden
  75296. */
  75297. private _effectiveTarget;
  75298. /**
  75299. * Internal only
  75300. * @hidden
  75301. */
  75302. private _property;
  75303. /**
  75304. * Creates a new ValueCondition
  75305. * @param actionManager manager for the action the condition applies to
  75306. * @param target for the action
  75307. * @param propertyPath path to specify the property of the target the conditional operator uses
  75308. * @param value the value compared by the conditional operator against the current value of the property
  75309. * @param operator the conditional operator, default ValueCondition.IsEqual
  75310. */
  75311. constructor(actionManager: ActionManager, target: any,
  75312. /** path to specify the property of the target the conditional operator uses */
  75313. propertyPath: string,
  75314. /** the value compared by the conditional operator against the current value of the property */
  75315. value: any,
  75316. /** the conditional operator, default ValueCondition.IsEqual */
  75317. operator?: number);
  75318. /**
  75319. * Compares the given value with the property value for the specified conditional operator
  75320. * @returns the result of the comparison
  75321. */
  75322. isValid(): boolean;
  75323. /**
  75324. * Serialize the ValueCondition into a JSON compatible object
  75325. * @returns serialization object
  75326. */
  75327. serialize(): any;
  75328. /**
  75329. * Gets the name of the conditional operator for the ValueCondition
  75330. * @param operator the conditional operator
  75331. * @returns the name
  75332. */
  75333. static GetOperatorName(operator: number): string;
  75334. }
  75335. /**
  75336. * Defines a predicate condition as an extension of Condition
  75337. */
  75338. export class PredicateCondition extends Condition {
  75339. /** defines the predicate function used to validate the condition */
  75340. predicate: () => boolean;
  75341. /**
  75342. * Internal only - manager for action
  75343. * @hidden
  75344. */
  75345. _actionManager: ActionManager;
  75346. /**
  75347. * Creates a new PredicateCondition
  75348. * @param actionManager manager for the action the condition applies to
  75349. * @param predicate defines the predicate function used to validate the condition
  75350. */
  75351. constructor(actionManager: ActionManager,
  75352. /** defines the predicate function used to validate the condition */
  75353. predicate: () => boolean);
  75354. /**
  75355. * @returns the validity of the predicate condition
  75356. */
  75357. isValid(): boolean;
  75358. }
  75359. /**
  75360. * Defines a state condition as an extension of Condition
  75361. */
  75362. export class StateCondition extends Condition {
  75363. /** Value to compare with target state */
  75364. value: string;
  75365. /**
  75366. * Internal only - manager for action
  75367. * @hidden
  75368. */
  75369. _actionManager: ActionManager;
  75370. /**
  75371. * Internal only
  75372. * @hidden
  75373. */
  75374. private _target;
  75375. /**
  75376. * Creates a new StateCondition
  75377. * @param actionManager manager for the action the condition applies to
  75378. * @param target of the condition
  75379. * @param value to compare with target state
  75380. */
  75381. constructor(actionManager: ActionManager, target: any,
  75382. /** Value to compare with target state */
  75383. value: string);
  75384. /**
  75385. * Gets a boolean indicating if the current condition is met
  75386. * @returns the validity of the state
  75387. */
  75388. isValid(): boolean;
  75389. /**
  75390. * Serialize the StateCondition into a JSON compatible object
  75391. * @returns serialization object
  75392. */
  75393. serialize(): any;
  75394. }
  75395. }
  75396. declare module BABYLON {
  75397. /**
  75398. * This defines an action responsible to toggle a boolean once triggered.
  75399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75400. */
  75401. export class SwitchBooleanAction extends Action {
  75402. /**
  75403. * The path to the boolean property in the target object
  75404. */
  75405. propertyPath: string;
  75406. private _target;
  75407. private _effectiveTarget;
  75408. private _property;
  75409. /**
  75410. * Instantiate the action
  75411. * @param triggerOptions defines the trigger options
  75412. * @param target defines the object containing the boolean
  75413. * @param propertyPath defines the path to the boolean property in the target object
  75414. * @param condition defines the trigger related conditions
  75415. */
  75416. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75417. /** @hidden */
  75418. _prepare(): void;
  75419. /**
  75420. * Execute the action toggle the boolean value.
  75421. */
  75422. execute(): void;
  75423. /**
  75424. * Serializes the actions and its related information.
  75425. * @param parent defines the object to serialize in
  75426. * @returns the serialized object
  75427. */
  75428. serialize(parent: any): any;
  75429. }
  75430. /**
  75431. * This defines an action responsible to set a the state field of the target
  75432. * to a desired value once triggered.
  75433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75434. */
  75435. export class SetStateAction extends Action {
  75436. /**
  75437. * The value to store in the state field.
  75438. */
  75439. value: string;
  75440. private _target;
  75441. /**
  75442. * Instantiate the action
  75443. * @param triggerOptions defines the trigger options
  75444. * @param target defines the object containing the state property
  75445. * @param value defines the value to store in the state field
  75446. * @param condition defines the trigger related conditions
  75447. */
  75448. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75449. /**
  75450. * Execute the action and store the value on the target state property.
  75451. */
  75452. execute(): void;
  75453. /**
  75454. * Serializes the actions and its related information.
  75455. * @param parent defines the object to serialize in
  75456. * @returns the serialized object
  75457. */
  75458. serialize(parent: any): any;
  75459. }
  75460. /**
  75461. * This defines an action responsible to set a property of the target
  75462. * to a desired value once triggered.
  75463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75464. */
  75465. export class SetValueAction extends Action {
  75466. /**
  75467. * The path of the property to set in the target.
  75468. */
  75469. propertyPath: string;
  75470. /**
  75471. * The value to set in the property
  75472. */
  75473. value: any;
  75474. private _target;
  75475. private _effectiveTarget;
  75476. private _property;
  75477. /**
  75478. * Instantiate the action
  75479. * @param triggerOptions defines the trigger options
  75480. * @param target defines the object containing the property
  75481. * @param propertyPath defines the path of the property to set in the target
  75482. * @param value defines the value to set in the property
  75483. * @param condition defines the trigger related conditions
  75484. */
  75485. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75486. /** @hidden */
  75487. _prepare(): void;
  75488. /**
  75489. * Execute the action and set the targetted property to the desired value.
  75490. */
  75491. execute(): void;
  75492. /**
  75493. * Serializes the actions and its related information.
  75494. * @param parent defines the object to serialize in
  75495. * @returns the serialized object
  75496. */
  75497. serialize(parent: any): any;
  75498. }
  75499. /**
  75500. * This defines an action responsible to increment the target value
  75501. * to a desired value once triggered.
  75502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75503. */
  75504. export class IncrementValueAction extends Action {
  75505. /**
  75506. * The path of the property to increment in the target.
  75507. */
  75508. propertyPath: string;
  75509. /**
  75510. * The value we should increment the property by.
  75511. */
  75512. value: any;
  75513. private _target;
  75514. private _effectiveTarget;
  75515. private _property;
  75516. /**
  75517. * Instantiate the action
  75518. * @param triggerOptions defines the trigger options
  75519. * @param target defines the object containing the property
  75520. * @param propertyPath defines the path of the property to increment in the target
  75521. * @param value defines the value value we should increment the property by
  75522. * @param condition defines the trigger related conditions
  75523. */
  75524. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75525. /** @hidden */
  75526. _prepare(): void;
  75527. /**
  75528. * Execute the action and increment the target of the value amount.
  75529. */
  75530. execute(): void;
  75531. /**
  75532. * Serializes the actions and its related information.
  75533. * @param parent defines the object to serialize in
  75534. * @returns the serialized object
  75535. */
  75536. serialize(parent: any): any;
  75537. }
  75538. /**
  75539. * This defines an action responsible to start an animation once triggered.
  75540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75541. */
  75542. export class PlayAnimationAction extends Action {
  75543. /**
  75544. * Where the animation should start (animation frame)
  75545. */
  75546. from: number;
  75547. /**
  75548. * Where the animation should stop (animation frame)
  75549. */
  75550. to: number;
  75551. /**
  75552. * Define if the animation should loop or stop after the first play.
  75553. */
  75554. loop?: boolean;
  75555. private _target;
  75556. /**
  75557. * Instantiate the action
  75558. * @param triggerOptions defines the trigger options
  75559. * @param target defines the target animation or animation name
  75560. * @param from defines from where the animation should start (animation frame)
  75561. * @param end defines where the animation should stop (animation frame)
  75562. * @param loop defines if the animation should loop or stop after the first play
  75563. * @param condition defines the trigger related conditions
  75564. */
  75565. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75566. /** @hidden */
  75567. _prepare(): void;
  75568. /**
  75569. * Execute the action and play the animation.
  75570. */
  75571. execute(): void;
  75572. /**
  75573. * Serializes the actions and its related information.
  75574. * @param parent defines the object to serialize in
  75575. * @returns the serialized object
  75576. */
  75577. serialize(parent: any): any;
  75578. }
  75579. /**
  75580. * This defines an action responsible to stop an animation once triggered.
  75581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75582. */
  75583. export class StopAnimationAction extends Action {
  75584. private _target;
  75585. /**
  75586. * Instantiate the action
  75587. * @param triggerOptions defines the trigger options
  75588. * @param target defines the target animation or animation name
  75589. * @param condition defines the trigger related conditions
  75590. */
  75591. constructor(triggerOptions: any, target: any, condition?: Condition);
  75592. /** @hidden */
  75593. _prepare(): void;
  75594. /**
  75595. * Execute the action and stop the animation.
  75596. */
  75597. execute(): void;
  75598. /**
  75599. * Serializes the actions and its related information.
  75600. * @param parent defines the object to serialize in
  75601. * @returns the serialized object
  75602. */
  75603. serialize(parent: any): any;
  75604. }
  75605. /**
  75606. * This defines an action responsible that does nothing once triggered.
  75607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75608. */
  75609. export class DoNothingAction extends Action {
  75610. /**
  75611. * Instantiate the action
  75612. * @param triggerOptions defines the trigger options
  75613. * @param condition defines the trigger related conditions
  75614. */
  75615. constructor(triggerOptions?: any, condition?: Condition);
  75616. /**
  75617. * Execute the action and do nothing.
  75618. */
  75619. execute(): void;
  75620. /**
  75621. * Serializes the actions and its related information.
  75622. * @param parent defines the object to serialize in
  75623. * @returns the serialized object
  75624. */
  75625. serialize(parent: any): any;
  75626. }
  75627. /**
  75628. * This defines an action responsible to trigger several actions once triggered.
  75629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75630. */
  75631. export class CombineAction extends Action {
  75632. /**
  75633. * The list of aggregated animations to run.
  75634. */
  75635. children: Action[];
  75636. /**
  75637. * Instantiate the action
  75638. * @param triggerOptions defines the trigger options
  75639. * @param children defines the list of aggregated animations to run
  75640. * @param condition defines the trigger related conditions
  75641. */
  75642. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75643. /** @hidden */
  75644. _prepare(): void;
  75645. /**
  75646. * Execute the action and executes all the aggregated actions.
  75647. */
  75648. execute(evt: ActionEvent): void;
  75649. /**
  75650. * Serializes the actions and its related information.
  75651. * @param parent defines the object to serialize in
  75652. * @returns the serialized object
  75653. */
  75654. serialize(parent: any): any;
  75655. }
  75656. /**
  75657. * This defines an action responsible to run code (external event) once triggered.
  75658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75659. */
  75660. export class ExecuteCodeAction extends Action {
  75661. /**
  75662. * The callback function to run.
  75663. */
  75664. func: (evt: ActionEvent) => void;
  75665. /**
  75666. * Instantiate the action
  75667. * @param triggerOptions defines the trigger options
  75668. * @param func defines the callback function to run
  75669. * @param condition defines the trigger related conditions
  75670. */
  75671. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75672. /**
  75673. * Execute the action and run the attached code.
  75674. */
  75675. execute(evt: ActionEvent): void;
  75676. }
  75677. /**
  75678. * This defines an action responsible to set the parent property of the target once triggered.
  75679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75680. */
  75681. export class SetParentAction extends Action {
  75682. private _parent;
  75683. private _target;
  75684. /**
  75685. * Instantiate the action
  75686. * @param triggerOptions defines the trigger options
  75687. * @param target defines the target containing the parent property
  75688. * @param parent defines from where the animation should start (animation frame)
  75689. * @param condition defines the trigger related conditions
  75690. */
  75691. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75692. /** @hidden */
  75693. _prepare(): void;
  75694. /**
  75695. * Execute the action and set the parent property.
  75696. */
  75697. execute(): void;
  75698. /**
  75699. * Serializes the actions and its related information.
  75700. * @param parent defines the object to serialize in
  75701. * @returns the serialized object
  75702. */
  75703. serialize(parent: any): any;
  75704. }
  75705. }
  75706. declare module BABYLON {
  75707. /**
  75708. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75709. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75711. */
  75712. export class ActionManager extends AbstractActionManager {
  75713. /**
  75714. * Nothing
  75715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75716. */
  75717. static readonly NothingTrigger: number;
  75718. /**
  75719. * On pick
  75720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75721. */
  75722. static readonly OnPickTrigger: number;
  75723. /**
  75724. * On left pick
  75725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75726. */
  75727. static readonly OnLeftPickTrigger: number;
  75728. /**
  75729. * On right pick
  75730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75731. */
  75732. static readonly OnRightPickTrigger: number;
  75733. /**
  75734. * On center pick
  75735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75736. */
  75737. static readonly OnCenterPickTrigger: number;
  75738. /**
  75739. * On pick down
  75740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75741. */
  75742. static readonly OnPickDownTrigger: number;
  75743. /**
  75744. * On double pick
  75745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75746. */
  75747. static readonly OnDoublePickTrigger: number;
  75748. /**
  75749. * On pick up
  75750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75751. */
  75752. static readonly OnPickUpTrigger: number;
  75753. /**
  75754. * On pick out.
  75755. * This trigger will only be raised if you also declared a OnPickDown
  75756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75757. */
  75758. static readonly OnPickOutTrigger: number;
  75759. /**
  75760. * On long press
  75761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75762. */
  75763. static readonly OnLongPressTrigger: number;
  75764. /**
  75765. * On pointer over
  75766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75767. */
  75768. static readonly OnPointerOverTrigger: number;
  75769. /**
  75770. * On pointer out
  75771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75772. */
  75773. static readonly OnPointerOutTrigger: number;
  75774. /**
  75775. * On every frame
  75776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75777. */
  75778. static readonly OnEveryFrameTrigger: number;
  75779. /**
  75780. * On intersection enter
  75781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75782. */
  75783. static readonly OnIntersectionEnterTrigger: number;
  75784. /**
  75785. * On intersection exit
  75786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75787. */
  75788. static readonly OnIntersectionExitTrigger: number;
  75789. /**
  75790. * On key down
  75791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75792. */
  75793. static readonly OnKeyDownTrigger: number;
  75794. /**
  75795. * On key up
  75796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75797. */
  75798. static readonly OnKeyUpTrigger: number;
  75799. private _scene;
  75800. /**
  75801. * Creates a new action manager
  75802. * @param scene defines the hosting scene
  75803. */
  75804. constructor(scene: Scene);
  75805. /**
  75806. * Releases all associated resources
  75807. */
  75808. dispose(): void;
  75809. /**
  75810. * Gets hosting scene
  75811. * @returns the hosting scene
  75812. */
  75813. getScene(): Scene;
  75814. /**
  75815. * Does this action manager handles actions of any of the given triggers
  75816. * @param triggers defines the triggers to be tested
  75817. * @return a boolean indicating whether one (or more) of the triggers is handled
  75818. */
  75819. hasSpecificTriggers(triggers: number[]): boolean;
  75820. /**
  75821. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75822. * speed.
  75823. * @param triggerA defines the trigger to be tested
  75824. * @param triggerB defines the trigger to be tested
  75825. * @return a boolean indicating whether one (or more) of the triggers is handled
  75826. */
  75827. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75828. /**
  75829. * Does this action manager handles actions of a given trigger
  75830. * @param trigger defines the trigger to be tested
  75831. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75832. * @return whether the trigger is handled
  75833. */
  75834. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75835. /**
  75836. * Does this action manager has pointer triggers
  75837. */
  75838. readonly hasPointerTriggers: boolean;
  75839. /**
  75840. * Does this action manager has pick triggers
  75841. */
  75842. readonly hasPickTriggers: boolean;
  75843. /**
  75844. * Registers an action to this action manager
  75845. * @param action defines the action to be registered
  75846. * @return the action amended (prepared) after registration
  75847. */
  75848. registerAction(action: IAction): Nullable<IAction>;
  75849. /**
  75850. * Unregisters an action to this action manager
  75851. * @param action defines the action to be unregistered
  75852. * @return a boolean indicating whether the action has been unregistered
  75853. */
  75854. unregisterAction(action: IAction): Boolean;
  75855. /**
  75856. * Process a specific trigger
  75857. * @param trigger defines the trigger to process
  75858. * @param evt defines the event details to be processed
  75859. */
  75860. processTrigger(trigger: number, evt?: IActionEvent): void;
  75861. /** @hidden */
  75862. _getEffectiveTarget(target: any, propertyPath: string): any;
  75863. /** @hidden */
  75864. _getProperty(propertyPath: string): string;
  75865. /**
  75866. * Serialize this manager to a JSON object
  75867. * @param name defines the property name to store this manager
  75868. * @returns a JSON representation of this manager
  75869. */
  75870. serialize(name: string): any;
  75871. /**
  75872. * Creates a new ActionManager from a JSON data
  75873. * @param parsedActions defines the JSON data to read from
  75874. * @param object defines the hosting mesh
  75875. * @param scene defines the hosting scene
  75876. */
  75877. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75878. /**
  75879. * Get a trigger name by index
  75880. * @param trigger defines the trigger index
  75881. * @returns a trigger name
  75882. */
  75883. static GetTriggerName(trigger: number): string;
  75884. }
  75885. }
  75886. declare module BABYLON {
  75887. /**
  75888. * Class representing a ray with position and direction
  75889. */
  75890. export class Ray {
  75891. /** origin point */
  75892. origin: Vector3;
  75893. /** direction */
  75894. direction: Vector3;
  75895. /** length of the ray */
  75896. length: number;
  75897. private static readonly TmpVector3;
  75898. private _tmpRay;
  75899. /**
  75900. * Creates a new ray
  75901. * @param origin origin point
  75902. * @param direction direction
  75903. * @param length length of the ray
  75904. */
  75905. constructor(
  75906. /** origin point */
  75907. origin: Vector3,
  75908. /** direction */
  75909. direction: Vector3,
  75910. /** length of the ray */
  75911. length?: number);
  75912. /**
  75913. * Checks if the ray intersects a box
  75914. * @param minimum bound of the box
  75915. * @param maximum bound of the box
  75916. * @param intersectionTreshold extra extend to be added to the box in all direction
  75917. * @returns if the box was hit
  75918. */
  75919. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75920. /**
  75921. * Checks if the ray intersects a box
  75922. * @param box the bounding box to check
  75923. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75924. * @returns if the box was hit
  75925. */
  75926. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75927. /**
  75928. * If the ray hits a sphere
  75929. * @param sphere the bounding sphere to check
  75930. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75931. * @returns true if it hits the sphere
  75932. */
  75933. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75934. /**
  75935. * If the ray hits a triange
  75936. * @param vertex0 triangle vertex
  75937. * @param vertex1 triangle vertex
  75938. * @param vertex2 triangle vertex
  75939. * @returns intersection information if hit
  75940. */
  75941. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75942. /**
  75943. * Checks if ray intersects a plane
  75944. * @param plane the plane to check
  75945. * @returns the distance away it was hit
  75946. */
  75947. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75948. /**
  75949. * Calculate the intercept of a ray on a given axis
  75950. * @param axis to check 'x' | 'y' | 'z'
  75951. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75952. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75953. */
  75954. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75955. /**
  75956. * Checks if ray intersects a mesh
  75957. * @param mesh the mesh to check
  75958. * @param fastCheck if only the bounding box should checked
  75959. * @returns picking info of the intersecton
  75960. */
  75961. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75962. /**
  75963. * Checks if ray intersects a mesh
  75964. * @param meshes the meshes to check
  75965. * @param fastCheck if only the bounding box should checked
  75966. * @param results array to store result in
  75967. * @returns Array of picking infos
  75968. */
  75969. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75970. private _comparePickingInfo;
  75971. private static smallnum;
  75972. private static rayl;
  75973. /**
  75974. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75975. * @param sega the first point of the segment to test the intersection against
  75976. * @param segb the second point of the segment to test the intersection against
  75977. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75978. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75979. */
  75980. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75981. /**
  75982. * Update the ray from viewport position
  75983. * @param x position
  75984. * @param y y position
  75985. * @param viewportWidth viewport width
  75986. * @param viewportHeight viewport height
  75987. * @param world world matrix
  75988. * @param view view matrix
  75989. * @param projection projection matrix
  75990. * @returns this ray updated
  75991. */
  75992. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75993. /**
  75994. * Creates a ray with origin and direction of 0,0,0
  75995. * @returns the new ray
  75996. */
  75997. static Zero(): Ray;
  75998. /**
  75999. * Creates a new ray from screen space and viewport
  76000. * @param x position
  76001. * @param y y position
  76002. * @param viewportWidth viewport width
  76003. * @param viewportHeight viewport height
  76004. * @param world world matrix
  76005. * @param view view matrix
  76006. * @param projection projection matrix
  76007. * @returns new ray
  76008. */
  76009. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76010. /**
  76011. * 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
  76012. * transformed to the given world matrix.
  76013. * @param origin The origin point
  76014. * @param end The end point
  76015. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76016. * @returns the new ray
  76017. */
  76018. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76019. /**
  76020. * Transforms a ray by a matrix
  76021. * @param ray ray to transform
  76022. * @param matrix matrix to apply
  76023. * @returns the resulting new ray
  76024. */
  76025. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76026. /**
  76027. * Transforms a ray by a matrix
  76028. * @param ray ray to transform
  76029. * @param matrix matrix to apply
  76030. * @param result ray to store result in
  76031. */
  76032. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76033. /**
  76034. * Unproject a ray from screen space to object space
  76035. * @param sourceX defines the screen space x coordinate to use
  76036. * @param sourceY defines the screen space y coordinate to use
  76037. * @param viewportWidth defines the current width of the viewport
  76038. * @param viewportHeight defines the current height of the viewport
  76039. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76040. * @param view defines the view matrix to use
  76041. * @param projection defines the projection matrix to use
  76042. */
  76043. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76044. }
  76045. /**
  76046. * Type used to define predicate used to select faces when a mesh intersection is detected
  76047. */
  76048. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76049. interface Scene {
  76050. /** @hidden */
  76051. _tempPickingRay: Nullable<Ray>;
  76052. /** @hidden */
  76053. _cachedRayForTransform: Ray;
  76054. /** @hidden */
  76055. _pickWithRayInverseMatrix: Matrix;
  76056. /** @hidden */
  76057. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76058. /** @hidden */
  76059. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76060. }
  76061. }
  76062. declare module BABYLON {
  76063. /**
  76064. * Groups all the scene component constants in one place to ease maintenance.
  76065. * @hidden
  76066. */
  76067. export class SceneComponentConstants {
  76068. static readonly NAME_EFFECTLAYER: string;
  76069. static readonly NAME_LAYER: string;
  76070. static readonly NAME_LENSFLARESYSTEM: string;
  76071. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76072. static readonly NAME_PARTICLESYSTEM: string;
  76073. static readonly NAME_GAMEPAD: string;
  76074. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76075. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76076. static readonly NAME_DEPTHRENDERER: string;
  76077. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76078. static readonly NAME_SPRITE: string;
  76079. static readonly NAME_OUTLINERENDERER: string;
  76080. static readonly NAME_PROCEDURALTEXTURE: string;
  76081. static readonly NAME_SHADOWGENERATOR: string;
  76082. static readonly NAME_OCTREE: string;
  76083. static readonly NAME_PHYSICSENGINE: string;
  76084. static readonly NAME_AUDIO: string;
  76085. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76086. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76087. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76088. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76089. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76090. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76091. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76092. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76093. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76094. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76095. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76096. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76097. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76098. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76099. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76100. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76101. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76102. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76103. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76104. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76105. static readonly STEP_AFTERRENDER_AUDIO: number;
  76106. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76107. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76108. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76109. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76110. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76111. static readonly STEP_POINTERMOVE_SPRITE: number;
  76112. static readonly STEP_POINTERDOWN_SPRITE: number;
  76113. static readonly STEP_POINTERUP_SPRITE: number;
  76114. }
  76115. /**
  76116. * This represents a scene component.
  76117. *
  76118. * This is used to decouple the dependency the scene is having on the different workloads like
  76119. * layers, post processes...
  76120. */
  76121. export interface ISceneComponent {
  76122. /**
  76123. * The name of the component. Each component must have a unique name.
  76124. */
  76125. name: string;
  76126. /**
  76127. * The scene the component belongs to.
  76128. */
  76129. scene: Scene;
  76130. /**
  76131. * Register the component to one instance of a scene.
  76132. */
  76133. register(): void;
  76134. /**
  76135. * Rebuilds the elements related to this component in case of
  76136. * context lost for instance.
  76137. */
  76138. rebuild(): void;
  76139. /**
  76140. * Disposes the component and the associated ressources.
  76141. */
  76142. dispose(): void;
  76143. }
  76144. /**
  76145. * This represents a SERIALIZABLE scene component.
  76146. *
  76147. * This extends Scene Component to add Serialization methods on top.
  76148. */
  76149. export interface ISceneSerializableComponent extends ISceneComponent {
  76150. /**
  76151. * Adds all the elements from the container to the scene
  76152. * @param container the container holding the elements
  76153. */
  76154. addFromContainer(container: AbstractScene): void;
  76155. /**
  76156. * Removes all the elements in the container from the scene
  76157. * @param container contains the elements to remove
  76158. * @param dispose if the removed element should be disposed (default: false)
  76159. */
  76160. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76161. /**
  76162. * Serializes the component data to the specified json object
  76163. * @param serializationObject The object to serialize to
  76164. */
  76165. serialize(serializationObject: any): void;
  76166. }
  76167. /**
  76168. * Strong typing of a Mesh related stage step action
  76169. */
  76170. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76171. /**
  76172. * Strong typing of a Evaluate Sub Mesh related stage step action
  76173. */
  76174. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76175. /**
  76176. * Strong typing of a Active Mesh related stage step action
  76177. */
  76178. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76179. /**
  76180. * Strong typing of a Camera related stage step action
  76181. */
  76182. export type CameraStageAction = (camera: Camera) => void;
  76183. /**
  76184. * Strong typing of a Camera Frame buffer related stage step action
  76185. */
  76186. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76187. /**
  76188. * Strong typing of a Render Target related stage step action
  76189. */
  76190. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76191. /**
  76192. * Strong typing of a RenderingGroup related stage step action
  76193. */
  76194. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76195. /**
  76196. * Strong typing of a Mesh Render related stage step action
  76197. */
  76198. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76199. /**
  76200. * Strong typing of a simple stage step action
  76201. */
  76202. export type SimpleStageAction = () => void;
  76203. /**
  76204. * Strong typing of a render target action.
  76205. */
  76206. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76207. /**
  76208. * Strong typing of a pointer move action.
  76209. */
  76210. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76211. /**
  76212. * Strong typing of a pointer up/down action.
  76213. */
  76214. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76215. /**
  76216. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76217. * @hidden
  76218. */
  76219. export class Stage<T extends Function> extends Array<{
  76220. index: number;
  76221. component: ISceneComponent;
  76222. action: T;
  76223. }> {
  76224. /**
  76225. * Hide ctor from the rest of the world.
  76226. * @param items The items to add.
  76227. */
  76228. private constructor();
  76229. /**
  76230. * Creates a new Stage.
  76231. * @returns A new instance of a Stage
  76232. */
  76233. static Create<T extends Function>(): Stage<T>;
  76234. /**
  76235. * Registers a step in an ordered way in the targeted stage.
  76236. * @param index Defines the position to register the step in
  76237. * @param component Defines the component attached to the step
  76238. * @param action Defines the action to launch during the step
  76239. */
  76240. registerStep(index: number, component: ISceneComponent, action: T): void;
  76241. /**
  76242. * Clears all the steps from the stage.
  76243. */
  76244. clear(): void;
  76245. }
  76246. }
  76247. declare module BABYLON {
  76248. interface Scene {
  76249. /** @hidden */
  76250. _pointerOverSprite: Nullable<Sprite>;
  76251. /** @hidden */
  76252. _pickedDownSprite: Nullable<Sprite>;
  76253. /** @hidden */
  76254. _tempSpritePickingRay: Nullable<Ray>;
  76255. /**
  76256. * All of the sprite managers added to this scene
  76257. * @see http://doc.babylonjs.com/babylon101/sprites
  76258. */
  76259. spriteManagers: Array<ISpriteManager>;
  76260. /**
  76261. * An event triggered when sprites rendering is about to start
  76262. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76263. */
  76264. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76265. /**
  76266. * An event triggered when sprites rendering is done
  76267. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76268. */
  76269. onAfterSpritesRenderingObservable: Observable<Scene>;
  76270. /** @hidden */
  76271. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76272. /** Launch a ray to try to pick a sprite in the scene
  76273. * @param x position on screen
  76274. * @param y position on screen
  76275. * @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
  76276. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76277. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76278. * @returns a PickingInfo
  76279. */
  76280. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76281. /** Use the given ray to pick a sprite in the scene
  76282. * @param ray The ray (in world space) to use to pick meshes
  76283. * @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
  76284. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76285. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76286. * @returns a PickingInfo
  76287. */
  76288. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76289. /** @hidden */
  76290. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76291. /** Launch a ray to try to pick sprites in the scene
  76292. * @param x position on screen
  76293. * @param y position on screen
  76294. * @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
  76295. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76296. * @returns a PickingInfo array
  76297. */
  76298. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76299. /** Use the given ray to pick sprites in the scene
  76300. * @param ray The ray (in world space) to use to pick meshes
  76301. * @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
  76302. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76303. * @returns a PickingInfo array
  76304. */
  76305. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76306. /**
  76307. * Force the sprite under the pointer
  76308. * @param sprite defines the sprite to use
  76309. */
  76310. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76311. /**
  76312. * Gets the sprite under the pointer
  76313. * @returns a Sprite or null if no sprite is under the pointer
  76314. */
  76315. getPointerOverSprite(): Nullable<Sprite>;
  76316. }
  76317. /**
  76318. * Defines the sprite scene component responsible to manage sprites
  76319. * in a given scene.
  76320. */
  76321. export class SpriteSceneComponent implements ISceneComponent {
  76322. /**
  76323. * The component name helpfull to identify the component in the list of scene components.
  76324. */
  76325. readonly name: string;
  76326. /**
  76327. * The scene the component belongs to.
  76328. */
  76329. scene: Scene;
  76330. /** @hidden */
  76331. private _spritePredicate;
  76332. /**
  76333. * Creates a new instance of the component for the given scene
  76334. * @param scene Defines the scene to register the component in
  76335. */
  76336. constructor(scene: Scene);
  76337. /**
  76338. * Registers the component in a given scene
  76339. */
  76340. register(): void;
  76341. /**
  76342. * Rebuilds the elements related to this component in case of
  76343. * context lost for instance.
  76344. */
  76345. rebuild(): void;
  76346. /**
  76347. * Disposes the component and the associated ressources.
  76348. */
  76349. dispose(): void;
  76350. private _pickSpriteButKeepRay;
  76351. private _pointerMove;
  76352. private _pointerDown;
  76353. private _pointerUp;
  76354. }
  76355. }
  76356. declare module BABYLON {
  76357. /** @hidden */
  76358. export var fogFragmentDeclaration: {
  76359. name: string;
  76360. shader: string;
  76361. };
  76362. }
  76363. declare module BABYLON {
  76364. /** @hidden */
  76365. export var fogFragment: {
  76366. name: string;
  76367. shader: string;
  76368. };
  76369. }
  76370. declare module BABYLON {
  76371. /** @hidden */
  76372. export var spritesPixelShader: {
  76373. name: string;
  76374. shader: string;
  76375. };
  76376. }
  76377. declare module BABYLON {
  76378. /** @hidden */
  76379. export var fogVertexDeclaration: {
  76380. name: string;
  76381. shader: string;
  76382. };
  76383. }
  76384. declare module BABYLON {
  76385. /** @hidden */
  76386. export var spritesVertexShader: {
  76387. name: string;
  76388. shader: string;
  76389. };
  76390. }
  76391. declare module BABYLON {
  76392. /**
  76393. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76394. */
  76395. export interface ISpriteManager extends IDisposable {
  76396. /**
  76397. * Restricts the camera to viewing objects with the same layerMask.
  76398. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76399. */
  76400. layerMask: number;
  76401. /**
  76402. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76403. */
  76404. isPickable: boolean;
  76405. /**
  76406. * Specifies the rendering group id for this mesh (0 by default)
  76407. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76408. */
  76409. renderingGroupId: number;
  76410. /**
  76411. * Defines the list of sprites managed by the manager.
  76412. */
  76413. sprites: Array<Sprite>;
  76414. /**
  76415. * Tests the intersection of a sprite with a specific ray.
  76416. * @param ray The ray we are sending to test the collision
  76417. * @param camera The camera space we are sending rays in
  76418. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76419. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76420. * @returns picking info or null.
  76421. */
  76422. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76423. /**
  76424. * Intersects the sprites with a ray
  76425. * @param ray defines the ray to intersect with
  76426. * @param camera defines the current active camera
  76427. * @param predicate defines a predicate used to select candidate sprites
  76428. * @returns null if no hit or a PickingInfo array
  76429. */
  76430. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76431. /**
  76432. * Renders the list of sprites on screen.
  76433. */
  76434. render(): void;
  76435. }
  76436. /**
  76437. * Class used to manage multiple sprites on the same spritesheet
  76438. * @see http://doc.babylonjs.com/babylon101/sprites
  76439. */
  76440. export class SpriteManager implements ISpriteManager {
  76441. /** defines the manager's name */
  76442. name: string;
  76443. /** Gets the list of sprites */
  76444. sprites: Sprite[];
  76445. /** Gets or sets the rendering group id (0 by default) */
  76446. renderingGroupId: number;
  76447. /** Gets or sets camera layer mask */
  76448. layerMask: number;
  76449. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76450. fogEnabled: boolean;
  76451. /** Gets or sets a boolean indicating if the sprites are pickable */
  76452. isPickable: boolean;
  76453. /** Defines the default width of a cell in the spritesheet */
  76454. cellWidth: number;
  76455. /** Defines the default height of a cell in the spritesheet */
  76456. cellHeight: number;
  76457. /** Associative array from JSON sprite data file */
  76458. private _cellData;
  76459. /** Array of sprite names from JSON sprite data file */
  76460. private _spriteMap;
  76461. /** True when packed cell data from JSON file is ready*/
  76462. private _packedAndReady;
  76463. /**
  76464. * An event triggered when the manager is disposed.
  76465. */
  76466. onDisposeObservable: Observable<SpriteManager>;
  76467. private _onDisposeObserver;
  76468. /**
  76469. * Callback called when the manager is disposed
  76470. */
  76471. onDispose: () => void;
  76472. private _capacity;
  76473. private _fromPacked;
  76474. private _spriteTexture;
  76475. private _epsilon;
  76476. private _scene;
  76477. private _vertexData;
  76478. private _buffer;
  76479. private _vertexBuffers;
  76480. private _indexBuffer;
  76481. private _effectBase;
  76482. private _effectFog;
  76483. /**
  76484. * Gets or sets the spritesheet texture
  76485. */
  76486. texture: Texture;
  76487. /**
  76488. * Creates a new sprite manager
  76489. * @param name defines the manager's name
  76490. * @param imgUrl defines the sprite sheet url
  76491. * @param capacity defines the maximum allowed number of sprites
  76492. * @param cellSize defines the size of a sprite cell
  76493. * @param scene defines the hosting scene
  76494. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76495. * @param samplingMode defines the smapling mode to use with spritesheet
  76496. * @param fromPacked set to false; do not alter
  76497. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76498. */
  76499. constructor(
  76500. /** defines the manager's name */
  76501. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76502. private _makePacked;
  76503. private _appendSpriteVertex;
  76504. /**
  76505. * Intersects the sprites with a ray
  76506. * @param ray defines the ray to intersect with
  76507. * @param camera defines the current active camera
  76508. * @param predicate defines a predicate used to select candidate sprites
  76509. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76510. * @returns null if no hit or a PickingInfo
  76511. */
  76512. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76513. /**
  76514. * Intersects the sprites with a ray
  76515. * @param ray defines the ray to intersect with
  76516. * @param camera defines the current active camera
  76517. * @param predicate defines a predicate used to select candidate sprites
  76518. * @returns null if no hit or a PickingInfo array
  76519. */
  76520. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76521. /**
  76522. * Render all child sprites
  76523. */
  76524. render(): void;
  76525. /**
  76526. * Release associated resources
  76527. */
  76528. dispose(): void;
  76529. }
  76530. }
  76531. declare module BABYLON {
  76532. /**
  76533. * Class used to represent a sprite
  76534. * @see http://doc.babylonjs.com/babylon101/sprites
  76535. */
  76536. export class Sprite {
  76537. /** defines the name */
  76538. name: string;
  76539. /** Gets or sets the current world position */
  76540. position: Vector3;
  76541. /** Gets or sets the main color */
  76542. color: Color4;
  76543. /** Gets or sets the width */
  76544. width: number;
  76545. /** Gets or sets the height */
  76546. height: number;
  76547. /** Gets or sets rotation angle */
  76548. angle: number;
  76549. /** Gets or sets the cell index in the sprite sheet */
  76550. cellIndex: number;
  76551. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76552. cellRef: string;
  76553. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76554. invertU: number;
  76555. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76556. invertV: number;
  76557. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76558. disposeWhenFinishedAnimating: boolean;
  76559. /** Gets the list of attached animations */
  76560. animations: Animation[];
  76561. /** Gets or sets a boolean indicating if the sprite can be picked */
  76562. isPickable: boolean;
  76563. /**
  76564. * Gets or sets the associated action manager
  76565. */
  76566. actionManager: Nullable<ActionManager>;
  76567. private _animationStarted;
  76568. private _loopAnimation;
  76569. private _fromIndex;
  76570. private _toIndex;
  76571. private _delay;
  76572. private _direction;
  76573. private _manager;
  76574. private _time;
  76575. private _onAnimationEnd;
  76576. /**
  76577. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76578. */
  76579. isVisible: boolean;
  76580. /**
  76581. * Gets or sets the sprite size
  76582. */
  76583. size: number;
  76584. /**
  76585. * Creates a new Sprite
  76586. * @param name defines the name
  76587. * @param manager defines the manager
  76588. */
  76589. constructor(
  76590. /** defines the name */
  76591. name: string, manager: ISpriteManager);
  76592. /**
  76593. * Starts an animation
  76594. * @param from defines the initial key
  76595. * @param to defines the end key
  76596. * @param loop defines if the animation must loop
  76597. * @param delay defines the start delay (in ms)
  76598. * @param onAnimationEnd defines a callback to call when animation ends
  76599. */
  76600. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76601. /** Stops current animation (if any) */
  76602. stopAnimation(): void;
  76603. /** @hidden */
  76604. _animate(deltaTime: number): void;
  76605. /** Release associated resources */
  76606. dispose(): void;
  76607. }
  76608. }
  76609. declare module BABYLON {
  76610. /**
  76611. * Information about the result of picking within a scene
  76612. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76613. */
  76614. export class PickingInfo {
  76615. /** @hidden */
  76616. _pickingUnavailable: boolean;
  76617. /**
  76618. * If the pick collided with an object
  76619. */
  76620. hit: boolean;
  76621. /**
  76622. * Distance away where the pick collided
  76623. */
  76624. distance: number;
  76625. /**
  76626. * The location of pick collision
  76627. */
  76628. pickedPoint: Nullable<Vector3>;
  76629. /**
  76630. * The mesh corresponding the the pick collision
  76631. */
  76632. pickedMesh: Nullable<AbstractMesh>;
  76633. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76634. bu: number;
  76635. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76636. bv: number;
  76637. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76638. faceId: number;
  76639. /** Id of the the submesh that was picked */
  76640. subMeshId: number;
  76641. /** If a sprite was picked, this will be the sprite the pick collided with */
  76642. pickedSprite: Nullable<Sprite>;
  76643. /**
  76644. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76645. */
  76646. originMesh: Nullable<AbstractMesh>;
  76647. /**
  76648. * The ray that was used to perform the picking.
  76649. */
  76650. ray: Nullable<Ray>;
  76651. /**
  76652. * Gets the normal correspodning to the face the pick collided with
  76653. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76654. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76655. * @returns The normal correspodning to the face the pick collided with
  76656. */
  76657. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76658. /**
  76659. * Gets the texture coordinates of where the pick occured
  76660. * @returns the vector containing the coordnates of the texture
  76661. */
  76662. getTextureCoordinates(): Nullable<Vector2>;
  76663. }
  76664. }
  76665. declare module BABYLON {
  76666. /**
  76667. * Gather the list of pointer event types as constants.
  76668. */
  76669. export class PointerEventTypes {
  76670. /**
  76671. * 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.
  76672. */
  76673. static readonly POINTERDOWN: number;
  76674. /**
  76675. * The pointerup event is fired when a pointer is no longer active.
  76676. */
  76677. static readonly POINTERUP: number;
  76678. /**
  76679. * The pointermove event is fired when a pointer changes coordinates.
  76680. */
  76681. static readonly POINTERMOVE: number;
  76682. /**
  76683. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76684. */
  76685. static readonly POINTERWHEEL: number;
  76686. /**
  76687. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76688. */
  76689. static readonly POINTERPICK: number;
  76690. /**
  76691. * The pointertap event is fired when a the object has been touched and released without drag.
  76692. */
  76693. static readonly POINTERTAP: number;
  76694. /**
  76695. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76696. */
  76697. static readonly POINTERDOUBLETAP: number;
  76698. }
  76699. /**
  76700. * Base class of pointer info types.
  76701. */
  76702. export class PointerInfoBase {
  76703. /**
  76704. * Defines the type of event (PointerEventTypes)
  76705. */
  76706. type: number;
  76707. /**
  76708. * Defines the related dom event
  76709. */
  76710. event: PointerEvent | MouseWheelEvent;
  76711. /**
  76712. * Instantiates the base class of pointers info.
  76713. * @param type Defines the type of event (PointerEventTypes)
  76714. * @param event Defines the related dom event
  76715. */
  76716. constructor(
  76717. /**
  76718. * Defines the type of event (PointerEventTypes)
  76719. */
  76720. type: number,
  76721. /**
  76722. * Defines the related dom event
  76723. */
  76724. event: PointerEvent | MouseWheelEvent);
  76725. }
  76726. /**
  76727. * This class is used to store pointer related info for the onPrePointerObservable event.
  76728. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76729. */
  76730. export class PointerInfoPre extends PointerInfoBase {
  76731. /**
  76732. * Ray from a pointer if availible (eg. 6dof controller)
  76733. */
  76734. ray: Nullable<Ray>;
  76735. /**
  76736. * Defines the local position of the pointer on the canvas.
  76737. */
  76738. localPosition: Vector2;
  76739. /**
  76740. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76741. */
  76742. skipOnPointerObservable: boolean;
  76743. /**
  76744. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76745. * @param type Defines the type of event (PointerEventTypes)
  76746. * @param event Defines the related dom event
  76747. * @param localX Defines the local x coordinates of the pointer when the event occured
  76748. * @param localY Defines the local y coordinates of the pointer when the event occured
  76749. */
  76750. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76751. }
  76752. /**
  76753. * This type contains all the data related to a pointer event in Babylon.js.
  76754. * 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.
  76755. */
  76756. export class PointerInfo extends PointerInfoBase {
  76757. /**
  76758. * Defines the picking info associated to the info (if any)\
  76759. */
  76760. pickInfo: Nullable<PickingInfo>;
  76761. /**
  76762. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76763. * @param type Defines the type of event (PointerEventTypes)
  76764. * @param event Defines the related dom event
  76765. * @param pickInfo Defines the picking info associated to the info (if any)\
  76766. */
  76767. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76768. /**
  76769. * Defines the picking info associated to the info (if any)\
  76770. */
  76771. pickInfo: Nullable<PickingInfo>);
  76772. }
  76773. /**
  76774. * Data relating to a touch event on the screen.
  76775. */
  76776. export interface PointerTouch {
  76777. /**
  76778. * X coordinate of touch.
  76779. */
  76780. x: number;
  76781. /**
  76782. * Y coordinate of touch.
  76783. */
  76784. y: number;
  76785. /**
  76786. * Id of touch. Unique for each finger.
  76787. */
  76788. pointerId: number;
  76789. /**
  76790. * Event type passed from DOM.
  76791. */
  76792. type: any;
  76793. }
  76794. }
  76795. declare module BABYLON {
  76796. /**
  76797. * Manage the mouse inputs to control the movement of a free camera.
  76798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76799. */
  76800. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76801. /**
  76802. * Define if touch is enabled in the mouse input
  76803. */
  76804. touchEnabled: boolean;
  76805. /**
  76806. * Defines the camera the input is attached to.
  76807. */
  76808. camera: FreeCamera;
  76809. /**
  76810. * Defines the buttons associated with the input to handle camera move.
  76811. */
  76812. buttons: number[];
  76813. /**
  76814. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76815. */
  76816. angularSensibility: number;
  76817. private _pointerInput;
  76818. private _onMouseMove;
  76819. private _observer;
  76820. private previousPosition;
  76821. /**
  76822. * Observable for when a pointer move event occurs containing the move offset
  76823. */
  76824. onPointerMovedObservable: Observable<{
  76825. offsetX: number;
  76826. offsetY: number;
  76827. }>;
  76828. /**
  76829. * @hidden
  76830. * If the camera should be rotated automatically based on pointer movement
  76831. */
  76832. _allowCameraRotation: boolean;
  76833. /**
  76834. * Manage the mouse inputs to control the movement of a free camera.
  76835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76836. * @param touchEnabled Defines if touch is enabled or not
  76837. */
  76838. constructor(
  76839. /**
  76840. * Define if touch is enabled in the mouse input
  76841. */
  76842. touchEnabled?: boolean);
  76843. /**
  76844. * Attach the input controls to a specific dom element to get the input from.
  76845. * @param element Defines the element the controls should be listened from
  76846. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76847. */
  76848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76849. /**
  76850. * Called on JS contextmenu event.
  76851. * Override this method to provide functionality.
  76852. */
  76853. protected onContextMenu(evt: PointerEvent): void;
  76854. /**
  76855. * Detach the current controls from the specified dom element.
  76856. * @param element Defines the element to stop listening the inputs from
  76857. */
  76858. detachControl(element: Nullable<HTMLElement>): void;
  76859. /**
  76860. * Gets the class name of the current intput.
  76861. * @returns the class name
  76862. */
  76863. getClassName(): string;
  76864. /**
  76865. * Get the friendly name associated with the input class.
  76866. * @returns the input friendly name
  76867. */
  76868. getSimpleName(): string;
  76869. }
  76870. }
  76871. declare module BABYLON {
  76872. /**
  76873. * Manage the touch inputs to control the movement of a free camera.
  76874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76875. */
  76876. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76877. /**
  76878. * Defines the camera the input is attached to.
  76879. */
  76880. camera: FreeCamera;
  76881. /**
  76882. * Defines the touch sensibility for rotation.
  76883. * The higher the faster.
  76884. */
  76885. touchAngularSensibility: number;
  76886. /**
  76887. * Defines the touch sensibility for move.
  76888. * The higher the faster.
  76889. */
  76890. touchMoveSensibility: number;
  76891. private _offsetX;
  76892. private _offsetY;
  76893. private _pointerPressed;
  76894. private _pointerInput;
  76895. private _observer;
  76896. private _onLostFocus;
  76897. /**
  76898. * Attach the input controls to a specific dom element to get the input from.
  76899. * @param element Defines the element the controls should be listened from
  76900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76901. */
  76902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76903. /**
  76904. * Detach the current controls from the specified dom element.
  76905. * @param element Defines the element to stop listening the inputs from
  76906. */
  76907. detachControl(element: Nullable<HTMLElement>): void;
  76908. /**
  76909. * Update the current camera state depending on the inputs that have been used this frame.
  76910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76911. */
  76912. checkInputs(): void;
  76913. /**
  76914. * Gets the class name of the current intput.
  76915. * @returns the class name
  76916. */
  76917. getClassName(): string;
  76918. /**
  76919. * Get the friendly name associated with the input class.
  76920. * @returns the input friendly name
  76921. */
  76922. getSimpleName(): string;
  76923. }
  76924. }
  76925. declare module BABYLON {
  76926. /**
  76927. * Default Inputs manager for the FreeCamera.
  76928. * It groups all the default supported inputs for ease of use.
  76929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76930. */
  76931. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76932. /**
  76933. * @hidden
  76934. */
  76935. _mouseInput: Nullable<FreeCameraMouseInput>;
  76936. /**
  76937. * Instantiates a new FreeCameraInputsManager.
  76938. * @param camera Defines the camera the inputs belong to
  76939. */
  76940. constructor(camera: FreeCamera);
  76941. /**
  76942. * Add keyboard input support to the input manager.
  76943. * @returns the current input manager
  76944. */
  76945. addKeyboard(): FreeCameraInputsManager;
  76946. /**
  76947. * Add mouse input support to the input manager.
  76948. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76949. * @returns the current input manager
  76950. */
  76951. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76952. /**
  76953. * Removes the mouse input support from the manager
  76954. * @returns the current input manager
  76955. */
  76956. removeMouse(): FreeCameraInputsManager;
  76957. /**
  76958. * Add touch input support to the input manager.
  76959. * @returns the current input manager
  76960. */
  76961. addTouch(): FreeCameraInputsManager;
  76962. /**
  76963. * Remove all attached input methods from a camera
  76964. */
  76965. clear(): void;
  76966. }
  76967. }
  76968. declare module BABYLON {
  76969. /**
  76970. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76971. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76973. */
  76974. export class FreeCamera extends TargetCamera {
  76975. /**
  76976. * Define the collision ellipsoid of the camera.
  76977. * This is helpful to simulate a camera body like the player body around the camera
  76978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76979. */
  76980. ellipsoid: Vector3;
  76981. /**
  76982. * Define an offset for the position of the ellipsoid around the camera.
  76983. * This can be helpful to determine the center of the body near the gravity center of the body
  76984. * instead of its head.
  76985. */
  76986. ellipsoidOffset: Vector3;
  76987. /**
  76988. * Enable or disable collisions of the camera with the rest of the scene objects.
  76989. */
  76990. checkCollisions: boolean;
  76991. /**
  76992. * Enable or disable gravity on the camera.
  76993. */
  76994. applyGravity: boolean;
  76995. /**
  76996. * Define the input manager associated to the camera.
  76997. */
  76998. inputs: FreeCameraInputsManager;
  76999. /**
  77000. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77001. * Higher values reduce sensitivity.
  77002. */
  77003. /**
  77004. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77005. * Higher values reduce sensitivity.
  77006. */
  77007. angularSensibility: number;
  77008. /**
  77009. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77010. */
  77011. keysUp: number[];
  77012. /**
  77013. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77014. */
  77015. keysDown: number[];
  77016. /**
  77017. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77018. */
  77019. keysLeft: number[];
  77020. /**
  77021. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77022. */
  77023. keysRight: number[];
  77024. /**
  77025. * Event raised when the camera collide with a mesh in the scene.
  77026. */
  77027. onCollide: (collidedMesh: AbstractMesh) => void;
  77028. private _collider;
  77029. private _needMoveForGravity;
  77030. private _oldPosition;
  77031. private _diffPosition;
  77032. private _newPosition;
  77033. /** @hidden */
  77034. _localDirection: Vector3;
  77035. /** @hidden */
  77036. _transformedDirection: Vector3;
  77037. /**
  77038. * Instantiates a Free Camera.
  77039. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77040. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77041. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77042. * @param name Define the name of the camera in the scene
  77043. * @param position Define the start position of the camera in the scene
  77044. * @param scene Define the scene the camera belongs to
  77045. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77046. */
  77047. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77048. /**
  77049. * Attached controls to the current camera.
  77050. * @param element Defines the element the controls should be listened from
  77051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77052. */
  77053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77054. /**
  77055. * Detach the current controls from the camera.
  77056. * The camera will stop reacting to inputs.
  77057. * @param element Defines the element to stop listening the inputs from
  77058. */
  77059. detachControl(element: HTMLElement): void;
  77060. private _collisionMask;
  77061. /**
  77062. * Define a collision mask to limit the list of object the camera can collide with
  77063. */
  77064. collisionMask: number;
  77065. /** @hidden */
  77066. _collideWithWorld(displacement: Vector3): void;
  77067. private _onCollisionPositionChange;
  77068. /** @hidden */
  77069. _checkInputs(): void;
  77070. /** @hidden */
  77071. _decideIfNeedsToMove(): boolean;
  77072. /** @hidden */
  77073. _updatePosition(): void;
  77074. /**
  77075. * Destroy the camera and release the current resources hold by it.
  77076. */
  77077. dispose(): void;
  77078. /**
  77079. * Gets the current object class name.
  77080. * @return the class name
  77081. */
  77082. getClassName(): string;
  77083. }
  77084. }
  77085. declare module BABYLON {
  77086. /**
  77087. * Represents a gamepad control stick position
  77088. */
  77089. export class StickValues {
  77090. /**
  77091. * The x component of the control stick
  77092. */
  77093. x: number;
  77094. /**
  77095. * The y component of the control stick
  77096. */
  77097. y: number;
  77098. /**
  77099. * Initializes the gamepad x and y control stick values
  77100. * @param x The x component of the gamepad control stick value
  77101. * @param y The y component of the gamepad control stick value
  77102. */
  77103. constructor(
  77104. /**
  77105. * The x component of the control stick
  77106. */
  77107. x: number,
  77108. /**
  77109. * The y component of the control stick
  77110. */
  77111. y: number);
  77112. }
  77113. /**
  77114. * An interface which manages callbacks for gamepad button changes
  77115. */
  77116. export interface GamepadButtonChanges {
  77117. /**
  77118. * Called when a gamepad has been changed
  77119. */
  77120. changed: boolean;
  77121. /**
  77122. * Called when a gamepad press event has been triggered
  77123. */
  77124. pressChanged: boolean;
  77125. /**
  77126. * Called when a touch event has been triggered
  77127. */
  77128. touchChanged: boolean;
  77129. /**
  77130. * Called when a value has changed
  77131. */
  77132. valueChanged: boolean;
  77133. }
  77134. /**
  77135. * Represents a gamepad
  77136. */
  77137. export class Gamepad {
  77138. /**
  77139. * The id of the gamepad
  77140. */
  77141. id: string;
  77142. /**
  77143. * The index of the gamepad
  77144. */
  77145. index: number;
  77146. /**
  77147. * The browser gamepad
  77148. */
  77149. browserGamepad: any;
  77150. /**
  77151. * Specifies what type of gamepad this represents
  77152. */
  77153. type: number;
  77154. private _leftStick;
  77155. private _rightStick;
  77156. /** @hidden */
  77157. _isConnected: boolean;
  77158. private _leftStickAxisX;
  77159. private _leftStickAxisY;
  77160. private _rightStickAxisX;
  77161. private _rightStickAxisY;
  77162. /**
  77163. * Triggered when the left control stick has been changed
  77164. */
  77165. private _onleftstickchanged;
  77166. /**
  77167. * Triggered when the right control stick has been changed
  77168. */
  77169. private _onrightstickchanged;
  77170. /**
  77171. * Represents a gamepad controller
  77172. */
  77173. static GAMEPAD: number;
  77174. /**
  77175. * Represents a generic controller
  77176. */
  77177. static GENERIC: number;
  77178. /**
  77179. * Represents an XBox controller
  77180. */
  77181. static XBOX: number;
  77182. /**
  77183. * Represents a pose-enabled controller
  77184. */
  77185. static POSE_ENABLED: number;
  77186. /**
  77187. * Represents an Dual Shock controller
  77188. */
  77189. static DUALSHOCK: number;
  77190. /**
  77191. * Specifies whether the left control stick should be Y-inverted
  77192. */
  77193. protected _invertLeftStickY: boolean;
  77194. /**
  77195. * Specifies if the gamepad has been connected
  77196. */
  77197. readonly isConnected: boolean;
  77198. /**
  77199. * Initializes the gamepad
  77200. * @param id The id of the gamepad
  77201. * @param index The index of the gamepad
  77202. * @param browserGamepad The browser gamepad
  77203. * @param leftStickX The x component of the left joystick
  77204. * @param leftStickY The y component of the left joystick
  77205. * @param rightStickX The x component of the right joystick
  77206. * @param rightStickY The y component of the right joystick
  77207. */
  77208. constructor(
  77209. /**
  77210. * The id of the gamepad
  77211. */
  77212. id: string,
  77213. /**
  77214. * The index of the gamepad
  77215. */
  77216. index: number,
  77217. /**
  77218. * The browser gamepad
  77219. */
  77220. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77221. /**
  77222. * Callback triggered when the left joystick has changed
  77223. * @param callback
  77224. */
  77225. onleftstickchanged(callback: (values: StickValues) => void): void;
  77226. /**
  77227. * Callback triggered when the right joystick has changed
  77228. * @param callback
  77229. */
  77230. onrightstickchanged(callback: (values: StickValues) => void): void;
  77231. /**
  77232. * Gets the left joystick
  77233. */
  77234. /**
  77235. * Sets the left joystick values
  77236. */
  77237. leftStick: StickValues;
  77238. /**
  77239. * Gets the right joystick
  77240. */
  77241. /**
  77242. * Sets the right joystick value
  77243. */
  77244. rightStick: StickValues;
  77245. /**
  77246. * Updates the gamepad joystick positions
  77247. */
  77248. update(): void;
  77249. /**
  77250. * Disposes the gamepad
  77251. */
  77252. dispose(): void;
  77253. }
  77254. /**
  77255. * Represents a generic gamepad
  77256. */
  77257. export class GenericPad extends Gamepad {
  77258. private _buttons;
  77259. private _onbuttondown;
  77260. private _onbuttonup;
  77261. /**
  77262. * Observable triggered when a button has been pressed
  77263. */
  77264. onButtonDownObservable: Observable<number>;
  77265. /**
  77266. * Observable triggered when a button has been released
  77267. */
  77268. onButtonUpObservable: Observable<number>;
  77269. /**
  77270. * Callback triggered when a button has been pressed
  77271. * @param callback Called when a button has been pressed
  77272. */
  77273. onbuttondown(callback: (buttonPressed: number) => void): void;
  77274. /**
  77275. * Callback triggered when a button has been released
  77276. * @param callback Called when a button has been released
  77277. */
  77278. onbuttonup(callback: (buttonReleased: number) => void): void;
  77279. /**
  77280. * Initializes the generic gamepad
  77281. * @param id The id of the generic gamepad
  77282. * @param index The index of the generic gamepad
  77283. * @param browserGamepad The browser gamepad
  77284. */
  77285. constructor(id: string, index: number, browserGamepad: any);
  77286. private _setButtonValue;
  77287. /**
  77288. * Updates the generic gamepad
  77289. */
  77290. update(): void;
  77291. /**
  77292. * Disposes the generic gamepad
  77293. */
  77294. dispose(): void;
  77295. }
  77296. }
  77297. declare module BABYLON {
  77298. interface Engine {
  77299. /**
  77300. * Creates a raw texture
  77301. * @param data defines the data to store in the texture
  77302. * @param width defines the width of the texture
  77303. * @param height defines the height of the texture
  77304. * @param format defines the format of the data
  77305. * @param generateMipMaps defines if the engine should generate the mip levels
  77306. * @param invertY defines if data must be stored with Y axis inverted
  77307. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77308. * @param compression defines the compression used (null by default)
  77309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77310. * @returns the raw texture inside an InternalTexture
  77311. */
  77312. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77313. /**
  77314. * Update a raw texture
  77315. * @param texture defines the texture to update
  77316. * @param data defines the data to store in the texture
  77317. * @param format defines the format of the data
  77318. * @param invertY defines if data must be stored with Y axis inverted
  77319. */
  77320. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77321. /**
  77322. * Update a raw texture
  77323. * @param texture defines the texture to update
  77324. * @param data defines the data to store in the texture
  77325. * @param format defines the format of the data
  77326. * @param invertY defines if data must be stored with Y axis inverted
  77327. * @param compression defines the compression used (null by default)
  77328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77329. */
  77330. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77331. /**
  77332. * Creates a new raw cube texture
  77333. * @param data defines the array of data to use to create each face
  77334. * @param size defines the size of the textures
  77335. * @param format defines the format of the data
  77336. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77337. * @param generateMipMaps defines if the engine should generate the mip levels
  77338. * @param invertY defines if data must be stored with Y axis inverted
  77339. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77340. * @param compression defines the compression used (null by default)
  77341. * @returns the cube texture as an InternalTexture
  77342. */
  77343. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77344. /**
  77345. * Update a raw cube texture
  77346. * @param texture defines the texture to udpdate
  77347. * @param data defines the data to store
  77348. * @param format defines the data format
  77349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77350. * @param invertY defines if data must be stored with Y axis inverted
  77351. */
  77352. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77353. /**
  77354. * Update a raw cube texture
  77355. * @param texture defines the texture to udpdate
  77356. * @param data defines the data to store
  77357. * @param format defines the data format
  77358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77359. * @param invertY defines if data must be stored with Y axis inverted
  77360. * @param compression defines the compression used (null by default)
  77361. */
  77362. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77363. /**
  77364. * Update a raw cube texture
  77365. * @param texture defines the texture to udpdate
  77366. * @param data defines the data to store
  77367. * @param format defines the data format
  77368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77369. * @param invertY defines if data must be stored with Y axis inverted
  77370. * @param compression defines the compression used (null by default)
  77371. * @param level defines which level of the texture to update
  77372. */
  77373. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77374. /**
  77375. * Creates a new raw cube texture from a specified url
  77376. * @param url defines the url where the data is located
  77377. * @param scene defines the current scene
  77378. * @param size defines the size of the textures
  77379. * @param format defines the format of the data
  77380. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77381. * @param noMipmap defines if the engine should avoid generating the mip levels
  77382. * @param callback defines a callback used to extract texture data from loaded data
  77383. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77384. * @param onLoad defines a callback called when texture is loaded
  77385. * @param onError defines a callback called if there is an error
  77386. * @returns the cube texture as an InternalTexture
  77387. */
  77388. 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;
  77389. /**
  77390. * Creates a new raw cube texture from a specified url
  77391. * @param url defines the url where the data is located
  77392. * @param scene defines the current scene
  77393. * @param size defines the size of the textures
  77394. * @param format defines the format of the data
  77395. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77396. * @param noMipmap defines if the engine should avoid generating the mip levels
  77397. * @param callback defines a callback used to extract texture data from loaded data
  77398. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77399. * @param onLoad defines a callback called when texture is loaded
  77400. * @param onError defines a callback called if there is an error
  77401. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77402. * @param invertY defines if data must be stored with Y axis inverted
  77403. * @returns the cube texture as an InternalTexture
  77404. */
  77405. 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;
  77406. /**
  77407. * Creates a new raw 3D texture
  77408. * @param data defines the data used to create the texture
  77409. * @param width defines the width of the texture
  77410. * @param height defines the height of the texture
  77411. * @param depth defines the depth of the texture
  77412. * @param format defines the format of the texture
  77413. * @param generateMipMaps defines if the engine must generate mip levels
  77414. * @param invertY defines if data must be stored with Y axis inverted
  77415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77416. * @param compression defines the compressed used (can be null)
  77417. * @param textureType defines the compressed used (can be null)
  77418. * @returns a new raw 3D texture (stored in an InternalTexture)
  77419. */
  77420. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77421. /**
  77422. * Update a raw 3D texture
  77423. * @param texture defines the texture to update
  77424. * @param data defines the data to store
  77425. * @param format defines the data format
  77426. * @param invertY defines if data must be stored with Y axis inverted
  77427. */
  77428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77429. /**
  77430. * Update a raw 3D texture
  77431. * @param texture defines the texture to update
  77432. * @param data defines the data to store
  77433. * @param format defines the data format
  77434. * @param invertY defines if data must be stored with Y axis inverted
  77435. * @param compression defines the used compression (can be null)
  77436. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77437. */
  77438. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77439. }
  77440. }
  77441. declare module BABYLON {
  77442. /**
  77443. * Raw texture can help creating a texture directly from an array of data.
  77444. * This can be super useful if you either get the data from an uncompressed source or
  77445. * if you wish to create your texture pixel by pixel.
  77446. */
  77447. export class RawTexture extends Texture {
  77448. /**
  77449. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77450. */
  77451. format: number;
  77452. private _engine;
  77453. /**
  77454. * Instantiates a new RawTexture.
  77455. * Raw texture can help creating a texture directly from an array of data.
  77456. * This can be super useful if you either get the data from an uncompressed source or
  77457. * if you wish to create your texture pixel by pixel.
  77458. * @param data define the array of data to use to create the texture
  77459. * @param width define the width of the texture
  77460. * @param height define the height of the texture
  77461. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77462. * @param scene define the scene the texture belongs to
  77463. * @param generateMipMaps define whether mip maps should be generated or not
  77464. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77465. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77466. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77467. */
  77468. constructor(data: ArrayBufferView, width: number, height: number,
  77469. /**
  77470. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77471. */
  77472. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77473. /**
  77474. * Updates the texture underlying data.
  77475. * @param data Define the new data of the texture
  77476. */
  77477. update(data: ArrayBufferView): void;
  77478. /**
  77479. * Creates a luminance texture from some data.
  77480. * @param data Define the texture data
  77481. * @param width Define the width of the texture
  77482. * @param height Define the height of the texture
  77483. * @param scene Define the scene the texture belongs to
  77484. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77485. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77486. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77487. * @returns the luminance texture
  77488. */
  77489. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77490. /**
  77491. * Creates a luminance alpha texture from some data.
  77492. * @param data Define the texture data
  77493. * @param width Define the width of the texture
  77494. * @param height Define the height of the texture
  77495. * @param scene Define the scene the texture belongs to
  77496. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77499. * @returns the luminance alpha texture
  77500. */
  77501. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77502. /**
  77503. * Creates an alpha texture from some data.
  77504. * @param data Define the texture data
  77505. * @param width Define the width of the texture
  77506. * @param height Define the height of the texture
  77507. * @param scene Define the scene the texture belongs to
  77508. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77509. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77510. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77511. * @returns the alpha texture
  77512. */
  77513. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77514. /**
  77515. * Creates a RGB texture from some data.
  77516. * @param data Define the texture data
  77517. * @param width Define the width of the texture
  77518. * @param height Define the height of the texture
  77519. * @param scene Define the scene the texture belongs to
  77520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77523. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77524. * @returns the RGB alpha texture
  77525. */
  77526. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77527. /**
  77528. * Creates a RGBA texture from some data.
  77529. * @param data Define the texture data
  77530. * @param width Define the width of the texture
  77531. * @param height Define the height of the texture
  77532. * @param scene Define the scene the texture belongs to
  77533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77536. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77537. * @returns the RGBA texture
  77538. */
  77539. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77540. /**
  77541. * Creates a R texture from some data.
  77542. * @param data Define the texture data
  77543. * @param width Define the width of the texture
  77544. * @param height Define the height of the texture
  77545. * @param scene Define the scene the texture belongs to
  77546. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77549. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77550. * @returns the R texture
  77551. */
  77552. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77553. }
  77554. }
  77555. declare module BABYLON {
  77556. /**
  77557. * Interface for the size containing width and height
  77558. */
  77559. export interface ISize {
  77560. /**
  77561. * Width
  77562. */
  77563. width: number;
  77564. /**
  77565. * Heighht
  77566. */
  77567. height: number;
  77568. }
  77569. /**
  77570. * Size containing widht and height
  77571. */
  77572. export class Size implements ISize {
  77573. /**
  77574. * Width
  77575. */
  77576. width: number;
  77577. /**
  77578. * Height
  77579. */
  77580. height: number;
  77581. /**
  77582. * Creates a Size object from the given width and height (floats).
  77583. * @param width width of the new size
  77584. * @param height height of the new size
  77585. */
  77586. constructor(width: number, height: number);
  77587. /**
  77588. * Returns a string with the Size width and height
  77589. * @returns a string with the Size width and height
  77590. */
  77591. toString(): string;
  77592. /**
  77593. * "Size"
  77594. * @returns the string "Size"
  77595. */
  77596. getClassName(): string;
  77597. /**
  77598. * Returns the Size hash code.
  77599. * @returns a hash code for a unique width and height
  77600. */
  77601. getHashCode(): number;
  77602. /**
  77603. * Updates the current size from the given one.
  77604. * @param src the given size
  77605. */
  77606. copyFrom(src: Size): void;
  77607. /**
  77608. * Updates in place the current Size from the given floats.
  77609. * @param width width of the new size
  77610. * @param height height of the new size
  77611. * @returns the updated Size.
  77612. */
  77613. copyFromFloats(width: number, height: number): Size;
  77614. /**
  77615. * Updates in place the current Size from the given floats.
  77616. * @param width width to set
  77617. * @param height height to set
  77618. * @returns the updated Size.
  77619. */
  77620. set(width: number, height: number): Size;
  77621. /**
  77622. * Multiplies the width and height by numbers
  77623. * @param w factor to multiple the width by
  77624. * @param h factor to multiple the height by
  77625. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77626. */
  77627. multiplyByFloats(w: number, h: number): Size;
  77628. /**
  77629. * Clones the size
  77630. * @returns a new Size copied from the given one.
  77631. */
  77632. clone(): Size;
  77633. /**
  77634. * True if the current Size and the given one width and height are strictly equal.
  77635. * @param other the other size to compare against
  77636. * @returns True if the current Size and the given one width and height are strictly equal.
  77637. */
  77638. equals(other: Size): boolean;
  77639. /**
  77640. * The surface of the Size : width * height (float).
  77641. */
  77642. readonly surface: number;
  77643. /**
  77644. * Create a new size of zero
  77645. * @returns a new Size set to (0.0, 0.0)
  77646. */
  77647. static Zero(): Size;
  77648. /**
  77649. * Sums the width and height of two sizes
  77650. * @param otherSize size to add to this size
  77651. * @returns a new Size set as the addition result of the current Size and the given one.
  77652. */
  77653. add(otherSize: Size): Size;
  77654. /**
  77655. * Subtracts the width and height of two
  77656. * @param otherSize size to subtract to this size
  77657. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77658. */
  77659. subtract(otherSize: Size): Size;
  77660. /**
  77661. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77662. * @param start starting size to lerp between
  77663. * @param end end size to lerp between
  77664. * @param amount amount to lerp between the start and end values
  77665. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77666. */
  77667. static Lerp(start: Size, end: Size, amount: number): Size;
  77668. }
  77669. }
  77670. declare module BABYLON {
  77671. /**
  77672. * Defines a runtime animation
  77673. */
  77674. export class RuntimeAnimation {
  77675. private _events;
  77676. /**
  77677. * The current frame of the runtime animation
  77678. */
  77679. private _currentFrame;
  77680. /**
  77681. * The animation used by the runtime animation
  77682. */
  77683. private _animation;
  77684. /**
  77685. * The target of the runtime animation
  77686. */
  77687. private _target;
  77688. /**
  77689. * The initiating animatable
  77690. */
  77691. private _host;
  77692. /**
  77693. * The original value of the runtime animation
  77694. */
  77695. private _originalValue;
  77696. /**
  77697. * The original blend value of the runtime animation
  77698. */
  77699. private _originalBlendValue;
  77700. /**
  77701. * The offsets cache of the runtime animation
  77702. */
  77703. private _offsetsCache;
  77704. /**
  77705. * The high limits cache of the runtime animation
  77706. */
  77707. private _highLimitsCache;
  77708. /**
  77709. * Specifies if the runtime animation has been stopped
  77710. */
  77711. private _stopped;
  77712. /**
  77713. * The blending factor of the runtime animation
  77714. */
  77715. private _blendingFactor;
  77716. /**
  77717. * The BabylonJS scene
  77718. */
  77719. private _scene;
  77720. /**
  77721. * The current value of the runtime animation
  77722. */
  77723. private _currentValue;
  77724. /** @hidden */
  77725. _animationState: _IAnimationState;
  77726. /**
  77727. * The active target of the runtime animation
  77728. */
  77729. private _activeTargets;
  77730. private _currentActiveTarget;
  77731. private _directTarget;
  77732. /**
  77733. * The target path of the runtime animation
  77734. */
  77735. private _targetPath;
  77736. /**
  77737. * The weight of the runtime animation
  77738. */
  77739. private _weight;
  77740. /**
  77741. * The ratio offset of the runtime animation
  77742. */
  77743. private _ratioOffset;
  77744. /**
  77745. * The previous delay of the runtime animation
  77746. */
  77747. private _previousDelay;
  77748. /**
  77749. * The previous ratio of the runtime animation
  77750. */
  77751. private _previousRatio;
  77752. private _enableBlending;
  77753. private _keys;
  77754. private _minFrame;
  77755. private _maxFrame;
  77756. private _minValue;
  77757. private _maxValue;
  77758. private _targetIsArray;
  77759. /**
  77760. * Gets the current frame of the runtime animation
  77761. */
  77762. readonly currentFrame: number;
  77763. /**
  77764. * Gets the weight of the runtime animation
  77765. */
  77766. readonly weight: number;
  77767. /**
  77768. * Gets the current value of the runtime animation
  77769. */
  77770. readonly currentValue: any;
  77771. /**
  77772. * Gets the target path of the runtime animation
  77773. */
  77774. readonly targetPath: string;
  77775. /**
  77776. * Gets the actual target of the runtime animation
  77777. */
  77778. readonly target: any;
  77779. /** @hidden */
  77780. _onLoop: () => void;
  77781. /**
  77782. * Create a new RuntimeAnimation object
  77783. * @param target defines the target of the animation
  77784. * @param animation defines the source animation object
  77785. * @param scene defines the hosting scene
  77786. * @param host defines the initiating Animatable
  77787. */
  77788. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77789. private _preparePath;
  77790. /**
  77791. * Gets the animation from the runtime animation
  77792. */
  77793. readonly animation: Animation;
  77794. /**
  77795. * Resets the runtime animation to the beginning
  77796. * @param restoreOriginal defines whether to restore the target property to the original value
  77797. */
  77798. reset(restoreOriginal?: boolean): void;
  77799. /**
  77800. * Specifies if the runtime animation is stopped
  77801. * @returns Boolean specifying if the runtime animation is stopped
  77802. */
  77803. isStopped(): boolean;
  77804. /**
  77805. * Disposes of the runtime animation
  77806. */
  77807. dispose(): void;
  77808. /**
  77809. * Apply the interpolated value to the target
  77810. * @param currentValue defines the value computed by the animation
  77811. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77812. */
  77813. setValue(currentValue: any, weight: number): void;
  77814. private _getOriginalValues;
  77815. private _setValue;
  77816. /**
  77817. * Gets the loop pmode of the runtime animation
  77818. * @returns Loop Mode
  77819. */
  77820. private _getCorrectLoopMode;
  77821. /**
  77822. * Move the current animation to a given frame
  77823. * @param frame defines the frame to move to
  77824. */
  77825. goToFrame(frame: number): void;
  77826. /**
  77827. * @hidden Internal use only
  77828. */
  77829. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77830. /**
  77831. * Execute the current animation
  77832. * @param delay defines the delay to add to the current frame
  77833. * @param from defines the lower bound of the animation range
  77834. * @param to defines the upper bound of the animation range
  77835. * @param loop defines if the current animation must loop
  77836. * @param speedRatio defines the current speed ratio
  77837. * @param weight defines the weight of the animation (default is -1 so no weight)
  77838. * @param onLoop optional callback called when animation loops
  77839. * @returns a boolean indicating if the animation is running
  77840. */
  77841. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77842. }
  77843. }
  77844. declare module BABYLON {
  77845. /**
  77846. * Class used to store an actual running animation
  77847. */
  77848. export class Animatable {
  77849. /** defines the target object */
  77850. target: any;
  77851. /** defines the starting frame number (default is 0) */
  77852. fromFrame: number;
  77853. /** defines the ending frame number (default is 100) */
  77854. toFrame: number;
  77855. /** defines if the animation must loop (default is false) */
  77856. loopAnimation: boolean;
  77857. /** defines a callback to call when animation ends if it is not looping */
  77858. onAnimationEnd?: (() => void) | null | undefined;
  77859. /** defines a callback to call when animation loops */
  77860. onAnimationLoop?: (() => void) | null | undefined;
  77861. private _localDelayOffset;
  77862. private _pausedDelay;
  77863. private _runtimeAnimations;
  77864. private _paused;
  77865. private _scene;
  77866. private _speedRatio;
  77867. private _weight;
  77868. private _syncRoot;
  77869. /**
  77870. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77871. * This will only apply for non looping animation (default is true)
  77872. */
  77873. disposeOnEnd: boolean;
  77874. /**
  77875. * Gets a boolean indicating if the animation has started
  77876. */
  77877. animationStarted: boolean;
  77878. /**
  77879. * Observer raised when the animation ends
  77880. */
  77881. onAnimationEndObservable: Observable<Animatable>;
  77882. /**
  77883. * Observer raised when the animation loops
  77884. */
  77885. onAnimationLoopObservable: Observable<Animatable>;
  77886. /**
  77887. * Gets the root Animatable used to synchronize and normalize animations
  77888. */
  77889. readonly syncRoot: Nullable<Animatable>;
  77890. /**
  77891. * Gets the current frame of the first RuntimeAnimation
  77892. * Used to synchronize Animatables
  77893. */
  77894. readonly masterFrame: number;
  77895. /**
  77896. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77897. */
  77898. weight: number;
  77899. /**
  77900. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77901. */
  77902. speedRatio: number;
  77903. /**
  77904. * Creates a new Animatable
  77905. * @param scene defines the hosting scene
  77906. * @param target defines the target object
  77907. * @param fromFrame defines the starting frame number (default is 0)
  77908. * @param toFrame defines the ending frame number (default is 100)
  77909. * @param loopAnimation defines if the animation must loop (default is false)
  77910. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77911. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77912. * @param animations defines a group of animation to add to the new Animatable
  77913. * @param onAnimationLoop defines a callback to call when animation loops
  77914. */
  77915. constructor(scene: Scene,
  77916. /** defines the target object */
  77917. target: any,
  77918. /** defines the starting frame number (default is 0) */
  77919. fromFrame?: number,
  77920. /** defines the ending frame number (default is 100) */
  77921. toFrame?: number,
  77922. /** defines if the animation must loop (default is false) */
  77923. loopAnimation?: boolean, speedRatio?: number,
  77924. /** defines a callback to call when animation ends if it is not looping */
  77925. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77926. /** defines a callback to call when animation loops */
  77927. onAnimationLoop?: (() => void) | null | undefined);
  77928. /**
  77929. * Synchronize and normalize current Animatable with a source Animatable
  77930. * This is useful when using animation weights and when animations are not of the same length
  77931. * @param root defines the root Animatable to synchronize with
  77932. * @returns the current Animatable
  77933. */
  77934. syncWith(root: Animatable): Animatable;
  77935. /**
  77936. * Gets the list of runtime animations
  77937. * @returns an array of RuntimeAnimation
  77938. */
  77939. getAnimations(): RuntimeAnimation[];
  77940. /**
  77941. * Adds more animations to the current animatable
  77942. * @param target defines the target of the animations
  77943. * @param animations defines the new animations to add
  77944. */
  77945. appendAnimations(target: any, animations: Animation[]): void;
  77946. /**
  77947. * Gets the source animation for a specific property
  77948. * @param property defines the propertyu to look for
  77949. * @returns null or the source animation for the given property
  77950. */
  77951. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77952. /**
  77953. * Gets the runtime animation for a specific property
  77954. * @param property defines the propertyu to look for
  77955. * @returns null or the runtime animation for the given property
  77956. */
  77957. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77958. /**
  77959. * Resets the animatable to its original state
  77960. */
  77961. reset(): void;
  77962. /**
  77963. * Allows the animatable to blend with current running animations
  77964. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77965. * @param blendingSpeed defines the blending speed to use
  77966. */
  77967. enableBlending(blendingSpeed: number): void;
  77968. /**
  77969. * Disable animation blending
  77970. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77971. */
  77972. disableBlending(): void;
  77973. /**
  77974. * Jump directly to a given frame
  77975. * @param frame defines the frame to jump to
  77976. */
  77977. goToFrame(frame: number): void;
  77978. /**
  77979. * Pause the animation
  77980. */
  77981. pause(): void;
  77982. /**
  77983. * Restart the animation
  77984. */
  77985. restart(): void;
  77986. private _raiseOnAnimationEnd;
  77987. /**
  77988. * Stop and delete the current animation
  77989. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77990. * @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)
  77991. */
  77992. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77993. /**
  77994. * Wait asynchronously for the animation to end
  77995. * @returns a promise which will be fullfilled when the animation ends
  77996. */
  77997. waitAsync(): Promise<Animatable>;
  77998. /** @hidden */
  77999. _animate(delay: number): boolean;
  78000. }
  78001. interface Scene {
  78002. /** @hidden */
  78003. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78004. /** @hidden */
  78005. _processLateAnimationBindingsForMatrices(holder: {
  78006. totalWeight: number;
  78007. animations: RuntimeAnimation[];
  78008. originalValue: Matrix;
  78009. }): any;
  78010. /** @hidden */
  78011. _processLateAnimationBindingsForQuaternions(holder: {
  78012. totalWeight: number;
  78013. animations: RuntimeAnimation[];
  78014. originalValue: Quaternion;
  78015. }, refQuaternion: Quaternion): Quaternion;
  78016. /** @hidden */
  78017. _processLateAnimationBindings(): void;
  78018. /**
  78019. * Will start the animation sequence of a given target
  78020. * @param target defines the target
  78021. * @param from defines from which frame should animation start
  78022. * @param to defines until which frame should animation run.
  78023. * @param weight defines the weight to apply to the animation (1.0 by default)
  78024. * @param loop defines if the animation loops
  78025. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78026. * @param onAnimationEnd defines the function to be executed when the animation ends
  78027. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78028. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78029. * @param onAnimationLoop defines the callback to call when an animation loops
  78030. * @returns the animatable object created for this animation
  78031. */
  78032. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78033. /**
  78034. * Will start the animation sequence of a given target
  78035. * @param target defines the target
  78036. * @param from defines from which frame should animation start
  78037. * @param to defines until which frame should animation run.
  78038. * @param loop defines if the animation loops
  78039. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78040. * @param onAnimationEnd defines the function to be executed when the animation ends
  78041. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78042. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78043. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78044. * @param onAnimationLoop defines the callback to call when an animation loops
  78045. * @returns the animatable object created for this animation
  78046. */
  78047. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78048. /**
  78049. * Will start the animation sequence of a given target and its hierarchy
  78050. * @param target defines the target
  78051. * @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.
  78052. * @param from defines from which frame should animation start
  78053. * @param to defines until which frame should animation run.
  78054. * @param loop defines if the animation loops
  78055. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78056. * @param onAnimationEnd defines the function to be executed when the animation ends
  78057. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78058. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78059. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78060. * @param onAnimationLoop defines the callback to call when an animation loops
  78061. * @returns the list of created animatables
  78062. */
  78063. 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[];
  78064. /**
  78065. * Begin a new animation on a given node
  78066. * @param target defines the target where the animation will take place
  78067. * @param animations defines the list of animations to start
  78068. * @param from defines the initial value
  78069. * @param to defines the final value
  78070. * @param loop defines if you want animation to loop (off by default)
  78071. * @param speedRatio defines the speed ratio to apply to all animations
  78072. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78073. * @param onAnimationLoop defines the callback to call when an animation loops
  78074. * @returns the list of created animatables
  78075. */
  78076. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78077. /**
  78078. * Begin a new animation on a given node and its hierarchy
  78079. * @param target defines the root node where the animation will take place
  78080. * @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.
  78081. * @param animations defines the list of animations to start
  78082. * @param from defines the initial value
  78083. * @param to defines the final value
  78084. * @param loop defines if you want animation to loop (off by default)
  78085. * @param speedRatio defines the speed ratio to apply to all animations
  78086. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78087. * @param onAnimationLoop defines the callback to call when an animation loops
  78088. * @returns the list of animatables created for all nodes
  78089. */
  78090. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78091. /**
  78092. * Gets the animatable associated with a specific target
  78093. * @param target defines the target of the animatable
  78094. * @returns the required animatable if found
  78095. */
  78096. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78097. /**
  78098. * Gets all animatables associated with a given target
  78099. * @param target defines the target to look animatables for
  78100. * @returns an array of Animatables
  78101. */
  78102. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78103. /**
  78104. * Stops and removes all animations that have been applied to the scene
  78105. */
  78106. stopAllAnimations(): void;
  78107. }
  78108. interface Bone {
  78109. /**
  78110. * Copy an animation range from another bone
  78111. * @param source defines the source bone
  78112. * @param rangeName defines the range name to copy
  78113. * @param frameOffset defines the frame offset
  78114. * @param rescaleAsRequired defines if rescaling must be applied if required
  78115. * @param skelDimensionsRatio defines the scaling ratio
  78116. * @returns true if operation was successful
  78117. */
  78118. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78119. }
  78120. }
  78121. declare module BABYLON {
  78122. /**
  78123. * Class used to override all child animations of a given target
  78124. */
  78125. export class AnimationPropertiesOverride {
  78126. /**
  78127. * Gets or sets a value indicating if animation blending must be used
  78128. */
  78129. enableBlending: boolean;
  78130. /**
  78131. * Gets or sets the blending speed to use when enableBlending is true
  78132. */
  78133. blendingSpeed: number;
  78134. /**
  78135. * Gets or sets the default loop mode to use
  78136. */
  78137. loopMode: number;
  78138. }
  78139. }
  78140. declare module BABYLON {
  78141. /**
  78142. * Class used to handle skinning animations
  78143. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78144. */
  78145. export class Skeleton implements IAnimatable {
  78146. /** defines the skeleton name */
  78147. name: string;
  78148. /** defines the skeleton Id */
  78149. id: string;
  78150. /**
  78151. * Defines the list of child bones
  78152. */
  78153. bones: Bone[];
  78154. /**
  78155. * Defines an estimate of the dimension of the skeleton at rest
  78156. */
  78157. dimensionsAtRest: Vector3;
  78158. /**
  78159. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78160. */
  78161. needInitialSkinMatrix: boolean;
  78162. /**
  78163. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78164. */
  78165. overrideMesh: Nullable<AbstractMesh>;
  78166. /**
  78167. * Gets the list of animations attached to this skeleton
  78168. */
  78169. animations: Array<Animation>;
  78170. private _scene;
  78171. private _isDirty;
  78172. private _transformMatrices;
  78173. private _transformMatrixTexture;
  78174. private _meshesWithPoseMatrix;
  78175. private _animatables;
  78176. private _identity;
  78177. private _synchronizedWithMesh;
  78178. private _ranges;
  78179. private _lastAbsoluteTransformsUpdateId;
  78180. private _canUseTextureForBones;
  78181. private _uniqueId;
  78182. /** @hidden */
  78183. _numBonesWithLinkedTransformNode: number;
  78184. /** @hidden */
  78185. _hasWaitingData: Nullable<boolean>;
  78186. /**
  78187. * Specifies if the skeleton should be serialized
  78188. */
  78189. doNotSerialize: boolean;
  78190. private _useTextureToStoreBoneMatrices;
  78191. /**
  78192. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78193. * Please note that this option is not available if the hardware does not support it
  78194. */
  78195. useTextureToStoreBoneMatrices: boolean;
  78196. private _animationPropertiesOverride;
  78197. /**
  78198. * Gets or sets the animation properties override
  78199. */
  78200. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78201. /**
  78202. * List of inspectable custom properties (used by the Inspector)
  78203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78204. */
  78205. inspectableCustomProperties: IInspectable[];
  78206. /**
  78207. * An observable triggered before computing the skeleton's matrices
  78208. */
  78209. onBeforeComputeObservable: Observable<Skeleton>;
  78210. /**
  78211. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78212. */
  78213. readonly isUsingTextureForMatrices: boolean;
  78214. /**
  78215. * Gets the unique ID of this skeleton
  78216. */
  78217. readonly uniqueId: number;
  78218. /**
  78219. * Creates a new skeleton
  78220. * @param name defines the skeleton name
  78221. * @param id defines the skeleton Id
  78222. * @param scene defines the hosting scene
  78223. */
  78224. constructor(
  78225. /** defines the skeleton name */
  78226. name: string,
  78227. /** defines the skeleton Id */
  78228. id: string, scene: Scene);
  78229. /**
  78230. * Gets the current object class name.
  78231. * @return the class name
  78232. */
  78233. getClassName(): string;
  78234. /**
  78235. * Returns an array containing the root bones
  78236. * @returns an array containing the root bones
  78237. */
  78238. getChildren(): Array<Bone>;
  78239. /**
  78240. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78241. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78242. * @returns a Float32Array containing matrices data
  78243. */
  78244. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78245. /**
  78246. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78247. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78248. * @returns a raw texture containing the data
  78249. */
  78250. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78251. /**
  78252. * Gets the current hosting scene
  78253. * @returns a scene object
  78254. */
  78255. getScene(): Scene;
  78256. /**
  78257. * Gets a string representing the current skeleton data
  78258. * @param fullDetails defines a boolean indicating if we want a verbose version
  78259. * @returns a string representing the current skeleton data
  78260. */
  78261. toString(fullDetails?: boolean): string;
  78262. /**
  78263. * Get bone's index searching by name
  78264. * @param name defines bone's name to search for
  78265. * @return the indice of the bone. Returns -1 if not found
  78266. */
  78267. getBoneIndexByName(name: string): number;
  78268. /**
  78269. * Creater a new animation range
  78270. * @param name defines the name of the range
  78271. * @param from defines the start key
  78272. * @param to defines the end key
  78273. */
  78274. createAnimationRange(name: string, from: number, to: number): void;
  78275. /**
  78276. * Delete a specific animation range
  78277. * @param name defines the name of the range
  78278. * @param deleteFrames defines if frames must be removed as well
  78279. */
  78280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78281. /**
  78282. * Gets a specific animation range
  78283. * @param name defines the name of the range to look for
  78284. * @returns the requested animation range or null if not found
  78285. */
  78286. getAnimationRange(name: string): Nullable<AnimationRange>;
  78287. /**
  78288. * Gets the list of all animation ranges defined on this skeleton
  78289. * @returns an array
  78290. */
  78291. getAnimationRanges(): Nullable<AnimationRange>[];
  78292. /**
  78293. * Copy animation range from a source skeleton.
  78294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78295. * @param source defines the source skeleton
  78296. * @param name defines the name of the range to copy
  78297. * @param rescaleAsRequired defines if rescaling must be applied if required
  78298. * @returns true if operation was successful
  78299. */
  78300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78301. /**
  78302. * Forces the skeleton to go to rest pose
  78303. */
  78304. returnToRest(): void;
  78305. private _getHighestAnimationFrame;
  78306. /**
  78307. * Begin a specific animation range
  78308. * @param name defines the name of the range to start
  78309. * @param loop defines if looping must be turned on (false by default)
  78310. * @param speedRatio defines the speed ratio to apply (1 by default)
  78311. * @param onAnimationEnd defines a callback which will be called when animation will end
  78312. * @returns a new animatable
  78313. */
  78314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78315. /** @hidden */
  78316. _markAsDirty(): void;
  78317. /** @hidden */
  78318. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78319. /** @hidden */
  78320. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78321. private _computeTransformMatrices;
  78322. /**
  78323. * Build all resources required to render a skeleton
  78324. */
  78325. prepare(): void;
  78326. /**
  78327. * Gets the list of animatables currently running for this skeleton
  78328. * @returns an array of animatables
  78329. */
  78330. getAnimatables(): IAnimatable[];
  78331. /**
  78332. * Clone the current skeleton
  78333. * @param name defines the name of the new skeleton
  78334. * @param id defines the id of the new skeleton
  78335. * @returns the new skeleton
  78336. */
  78337. clone(name: string, id: string): Skeleton;
  78338. /**
  78339. * Enable animation blending for this skeleton
  78340. * @param blendingSpeed defines the blending speed to apply
  78341. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78342. */
  78343. enableBlending(blendingSpeed?: number): void;
  78344. /**
  78345. * Releases all resources associated with the current skeleton
  78346. */
  78347. dispose(): void;
  78348. /**
  78349. * Serialize the skeleton in a JSON object
  78350. * @returns a JSON object
  78351. */
  78352. serialize(): any;
  78353. /**
  78354. * Creates a new skeleton from serialized data
  78355. * @param parsedSkeleton defines the serialized data
  78356. * @param scene defines the hosting scene
  78357. * @returns a new skeleton
  78358. */
  78359. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78360. /**
  78361. * Compute all node absolute transforms
  78362. * @param forceUpdate defines if computation must be done even if cache is up to date
  78363. */
  78364. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78365. /**
  78366. * Gets the root pose matrix
  78367. * @returns a matrix
  78368. */
  78369. getPoseMatrix(): Nullable<Matrix>;
  78370. /**
  78371. * Sorts bones per internal index
  78372. */
  78373. sortBones(): void;
  78374. private _sortBones;
  78375. }
  78376. }
  78377. declare module BABYLON {
  78378. /**
  78379. * Class used to store bone information
  78380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78381. */
  78382. export class Bone extends Node {
  78383. /**
  78384. * defines the bone name
  78385. */
  78386. name: string;
  78387. private static _tmpVecs;
  78388. private static _tmpQuat;
  78389. private static _tmpMats;
  78390. /**
  78391. * Gets the list of child bones
  78392. */
  78393. children: Bone[];
  78394. /** Gets the animations associated with this bone */
  78395. animations: Animation[];
  78396. /**
  78397. * Gets or sets bone length
  78398. */
  78399. length: number;
  78400. /**
  78401. * @hidden Internal only
  78402. * Set this value to map this bone to a different index in the transform matrices
  78403. * Set this value to -1 to exclude the bone from the transform matrices
  78404. */
  78405. _index: Nullable<number>;
  78406. private _skeleton;
  78407. private _localMatrix;
  78408. private _restPose;
  78409. private _baseMatrix;
  78410. private _absoluteTransform;
  78411. private _invertedAbsoluteTransform;
  78412. private _parent;
  78413. private _scalingDeterminant;
  78414. private _worldTransform;
  78415. private _localScaling;
  78416. private _localRotation;
  78417. private _localPosition;
  78418. private _needToDecompose;
  78419. private _needToCompose;
  78420. /** @hidden */
  78421. _linkedTransformNode: Nullable<TransformNode>;
  78422. /** @hidden */
  78423. _waitingTransformNodeId: Nullable<string>;
  78424. /** @hidden */
  78425. /** @hidden */
  78426. _matrix: Matrix;
  78427. /**
  78428. * Create a new bone
  78429. * @param name defines the bone name
  78430. * @param skeleton defines the parent skeleton
  78431. * @param parentBone defines the parent (can be null if the bone is the root)
  78432. * @param localMatrix defines the local matrix
  78433. * @param restPose defines the rest pose matrix
  78434. * @param baseMatrix defines the base matrix
  78435. * @param index defines index of the bone in the hiearchy
  78436. */
  78437. constructor(
  78438. /**
  78439. * defines the bone name
  78440. */
  78441. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78442. /**
  78443. * Gets the current object class name.
  78444. * @return the class name
  78445. */
  78446. getClassName(): string;
  78447. /**
  78448. * Gets the parent skeleton
  78449. * @returns a skeleton
  78450. */
  78451. getSkeleton(): Skeleton;
  78452. /**
  78453. * Gets parent bone
  78454. * @returns a bone or null if the bone is the root of the bone hierarchy
  78455. */
  78456. getParent(): Nullable<Bone>;
  78457. /**
  78458. * Returns an array containing the root bones
  78459. * @returns an array containing the root bones
  78460. */
  78461. getChildren(): Array<Bone>;
  78462. /**
  78463. * Sets the parent bone
  78464. * @param parent defines the parent (can be null if the bone is the root)
  78465. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78466. */
  78467. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78468. /**
  78469. * Gets the local matrix
  78470. * @returns a matrix
  78471. */
  78472. getLocalMatrix(): Matrix;
  78473. /**
  78474. * Gets the base matrix (initial matrix which remains unchanged)
  78475. * @returns a matrix
  78476. */
  78477. getBaseMatrix(): Matrix;
  78478. /**
  78479. * Gets the rest pose matrix
  78480. * @returns a matrix
  78481. */
  78482. getRestPose(): Matrix;
  78483. /**
  78484. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78485. */
  78486. getWorldMatrix(): Matrix;
  78487. /**
  78488. * Sets the local matrix to rest pose matrix
  78489. */
  78490. returnToRest(): void;
  78491. /**
  78492. * Gets the inverse of the absolute transform matrix.
  78493. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78494. * @returns a matrix
  78495. */
  78496. getInvertedAbsoluteTransform(): Matrix;
  78497. /**
  78498. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78499. * @returns a matrix
  78500. */
  78501. getAbsoluteTransform(): Matrix;
  78502. /**
  78503. * Links with the given transform node.
  78504. * The local matrix of this bone is copied from the transform node every frame.
  78505. * @param transformNode defines the transform node to link to
  78506. */
  78507. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78508. /**
  78509. * Gets the node used to drive the bone's transformation
  78510. * @returns a transform node or null
  78511. */
  78512. getTransformNode(): Nullable<TransformNode>;
  78513. /** Gets or sets current position (in local space) */
  78514. position: Vector3;
  78515. /** Gets or sets current rotation (in local space) */
  78516. rotation: Vector3;
  78517. /** Gets or sets current rotation quaternion (in local space) */
  78518. rotationQuaternion: Quaternion;
  78519. /** Gets or sets current scaling (in local space) */
  78520. scaling: Vector3;
  78521. /**
  78522. * Gets the animation properties override
  78523. */
  78524. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78525. private _decompose;
  78526. private _compose;
  78527. /**
  78528. * Update the base and local matrices
  78529. * @param matrix defines the new base or local matrix
  78530. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78531. * @param updateLocalMatrix defines if the local matrix should be updated
  78532. */
  78533. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78534. /** @hidden */
  78535. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78536. /**
  78537. * Flag the bone as dirty (Forcing it to update everything)
  78538. */
  78539. markAsDirty(): void;
  78540. /** @hidden */
  78541. _markAsDirtyAndCompose(): void;
  78542. private _markAsDirtyAndDecompose;
  78543. /**
  78544. * Translate the bone in local or world space
  78545. * @param vec The amount to translate the bone
  78546. * @param space The space that the translation is in
  78547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78548. */
  78549. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78550. /**
  78551. * Set the postion of the bone in local or world space
  78552. * @param position The position to set the bone
  78553. * @param space The space that the position is in
  78554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78555. */
  78556. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78557. /**
  78558. * Set the absolute position of the bone (world space)
  78559. * @param position The position to set the bone
  78560. * @param mesh The mesh that this bone is attached to
  78561. */
  78562. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78563. /**
  78564. * Scale the bone on the x, y and z axes (in local space)
  78565. * @param x The amount to scale the bone on the x axis
  78566. * @param y The amount to scale the bone on the y axis
  78567. * @param z The amount to scale the bone on the z axis
  78568. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  78569. */
  78570. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78571. /**
  78572. * Set the bone scaling in local space
  78573. * @param scale defines the scaling vector
  78574. */
  78575. setScale(scale: Vector3): void;
  78576. /**
  78577. * Gets the current scaling in local space
  78578. * @returns the current scaling vector
  78579. */
  78580. getScale(): Vector3;
  78581. /**
  78582. * Gets the current scaling in local space and stores it in a target vector
  78583. * @param result defines the target vector
  78584. */
  78585. getScaleToRef(result: Vector3): void;
  78586. /**
  78587. * Set the yaw, pitch, and roll of the bone in local or world space
  78588. * @param yaw The rotation of the bone on the y axis
  78589. * @param pitch The rotation of the bone on the x axis
  78590. * @param roll The rotation of the bone on the z axis
  78591. * @param space The space that the axes of rotation are in
  78592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78593. */
  78594. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78595. /**
  78596. * Add a rotation to the bone on an axis in local or world space
  78597. * @param axis The axis to rotate the bone on
  78598. * @param amount The amount to rotate the bone
  78599. * @param space The space that the axis is in
  78600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78601. */
  78602. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78603. /**
  78604. * Set the rotation of the bone to a particular axis angle in local or world space
  78605. * @param axis The axis to rotate the bone on
  78606. * @param angle The angle that the bone should be rotated to
  78607. * @param space The space that the axis is in
  78608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78609. */
  78610. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78611. /**
  78612. * Set the euler rotation of the bone in local of world space
  78613. * @param rotation The euler rotation that the bone should be set to
  78614. * @param space The space that the rotation is in
  78615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78616. */
  78617. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78618. /**
  78619. * Set the quaternion rotation of the bone in local of world space
  78620. * @param quat The quaternion rotation that the bone should be set to
  78621. * @param space The space that the rotation is in
  78622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78623. */
  78624. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78625. /**
  78626. * Set the rotation matrix of the bone in local of world space
  78627. * @param rotMat The rotation matrix that the bone should be set to
  78628. * @param space The space that the rotation is in
  78629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78630. */
  78631. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78632. private _rotateWithMatrix;
  78633. private _getNegativeRotationToRef;
  78634. /**
  78635. * Get the position of the bone in local or world space
  78636. * @param space The space that the returned position is in
  78637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78638. * @returns The position of the bone
  78639. */
  78640. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78641. /**
  78642. * Copy the position of the bone to a vector3 in local or world space
  78643. * @param space The space that the returned position is in
  78644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78645. * @param result The vector3 to copy the position to
  78646. */
  78647. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78648. /**
  78649. * Get the absolute position of the bone (world space)
  78650. * @param mesh The mesh that this bone is attached to
  78651. * @returns The absolute position of the bone
  78652. */
  78653. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78654. /**
  78655. * Copy the absolute position of the bone (world space) to the result param
  78656. * @param mesh The mesh that this bone is attached to
  78657. * @param result The vector3 to copy the absolute position to
  78658. */
  78659. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78660. /**
  78661. * Compute the absolute transforms of this bone and its children
  78662. */
  78663. computeAbsoluteTransforms(): void;
  78664. /**
  78665. * Get the world direction from an axis that is in the local space of the bone
  78666. * @param localAxis The local direction that is used to compute the world direction
  78667. * @param mesh The mesh that this bone is attached to
  78668. * @returns The world direction
  78669. */
  78670. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78671. /**
  78672. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78673. * @param localAxis The local direction that is used to compute the world direction
  78674. * @param mesh The mesh that this bone is attached to
  78675. * @param result The vector3 that the world direction will be copied to
  78676. */
  78677. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78678. /**
  78679. * Get the euler rotation of the bone in local or world space
  78680. * @param space The space that the rotation should be in
  78681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78682. * @returns The euler rotation
  78683. */
  78684. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78685. /**
  78686. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78687. * @param space The space that the rotation should be in
  78688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78689. * @param result The vector3 that the rotation should be copied to
  78690. */
  78691. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78692. /**
  78693. * Get the quaternion rotation of the bone in either local or world space
  78694. * @param space The space that the rotation should be in
  78695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78696. * @returns The quaternion rotation
  78697. */
  78698. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78699. /**
  78700. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78701. * @param space The space that the rotation should be in
  78702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78703. * @param result The quaternion that the rotation should be copied to
  78704. */
  78705. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78706. /**
  78707. * Get the rotation matrix of the bone in local or world space
  78708. * @param space The space that the rotation should be in
  78709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78710. * @returns The rotation matrix
  78711. */
  78712. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78713. /**
  78714. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78715. * @param space The space that the rotation should be in
  78716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78717. * @param result The quaternion that the rotation should be copied to
  78718. */
  78719. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78720. /**
  78721. * Get the world position of a point that is in the local space of the bone
  78722. * @param position The local position
  78723. * @param mesh The mesh that this bone is attached to
  78724. * @returns The world position
  78725. */
  78726. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78727. /**
  78728. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78729. * @param position The local position
  78730. * @param mesh The mesh that this bone is attached to
  78731. * @param result The vector3 that the world position should be copied to
  78732. */
  78733. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78734. /**
  78735. * Get the local position of a point that is in world space
  78736. * @param position The world position
  78737. * @param mesh The mesh that this bone is attached to
  78738. * @returns The local position
  78739. */
  78740. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78741. /**
  78742. * Get the local position of a point that is in world space and copy it to the result param
  78743. * @param position The world position
  78744. * @param mesh The mesh that this bone is attached to
  78745. * @param result The vector3 that the local position should be copied to
  78746. */
  78747. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78748. }
  78749. }
  78750. declare module BABYLON {
  78751. /**
  78752. * 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.
  78753. * @see https://doc.babylonjs.com/how_to/transformnode
  78754. */
  78755. export class TransformNode extends Node {
  78756. /**
  78757. * Object will not rotate to face the camera
  78758. */
  78759. static BILLBOARDMODE_NONE: number;
  78760. /**
  78761. * Object will rotate to face the camera but only on the x axis
  78762. */
  78763. static BILLBOARDMODE_X: number;
  78764. /**
  78765. * Object will rotate to face the camera but only on the y axis
  78766. */
  78767. static BILLBOARDMODE_Y: number;
  78768. /**
  78769. * Object will rotate to face the camera but only on the z axis
  78770. */
  78771. static BILLBOARDMODE_Z: number;
  78772. /**
  78773. * Object will rotate to face the camera
  78774. */
  78775. static BILLBOARDMODE_ALL: number;
  78776. /**
  78777. * Object will rotate to face the camera's position instead of orientation
  78778. */
  78779. static BILLBOARDMODE_USE_POSITION: number;
  78780. private _forward;
  78781. private _forwardInverted;
  78782. private _up;
  78783. private _right;
  78784. private _rightInverted;
  78785. private _position;
  78786. private _rotation;
  78787. private _rotationQuaternion;
  78788. protected _scaling: Vector3;
  78789. protected _isDirty: boolean;
  78790. private _transformToBoneReferal;
  78791. private _isAbsoluteSynced;
  78792. private _billboardMode;
  78793. /**
  78794. * Gets or sets the billboard mode. Default is 0.
  78795. *
  78796. * | Value | Type | Description |
  78797. * | --- | --- | --- |
  78798. * | 0 | BILLBOARDMODE_NONE | |
  78799. * | 1 | BILLBOARDMODE_X | |
  78800. * | 2 | BILLBOARDMODE_Y | |
  78801. * | 4 | BILLBOARDMODE_Z | |
  78802. * | 7 | BILLBOARDMODE_ALL | |
  78803. *
  78804. */
  78805. billboardMode: number;
  78806. private _preserveParentRotationForBillboard;
  78807. /**
  78808. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78809. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78810. */
  78811. preserveParentRotationForBillboard: boolean;
  78812. /**
  78813. * 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
  78814. */
  78815. scalingDeterminant: number;
  78816. private _infiniteDistance;
  78817. /**
  78818. * Gets or sets the distance of the object to max, often used by skybox
  78819. */
  78820. infiniteDistance: boolean;
  78821. /**
  78822. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78823. * By default the system will update normals to compensate
  78824. */
  78825. ignoreNonUniformScaling: boolean;
  78826. /**
  78827. * 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
  78828. */
  78829. reIntegrateRotationIntoRotationQuaternion: boolean;
  78830. /** @hidden */
  78831. _poseMatrix: Nullable<Matrix>;
  78832. /** @hidden */
  78833. _localMatrix: Matrix;
  78834. private _usePivotMatrix;
  78835. private _absolutePosition;
  78836. private _absoluteScaling;
  78837. private _absoluteRotationQuaternion;
  78838. private _pivotMatrix;
  78839. private _pivotMatrixInverse;
  78840. protected _postMultiplyPivotMatrix: boolean;
  78841. protected _isWorldMatrixFrozen: boolean;
  78842. /** @hidden */
  78843. _indexInSceneTransformNodesArray: number;
  78844. /**
  78845. * An event triggered after the world matrix is updated
  78846. */
  78847. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78848. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78849. /**
  78850. * Gets a string identifying the name of the class
  78851. * @returns "TransformNode" string
  78852. */
  78853. getClassName(): string;
  78854. /**
  78855. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78856. */
  78857. position: Vector3;
  78858. /**
  78859. * 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)).
  78860. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78861. */
  78862. rotation: Vector3;
  78863. /**
  78864. * 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)).
  78865. */
  78866. scaling: Vector3;
  78867. /**
  78868. * 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).
  78869. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78870. */
  78871. rotationQuaternion: Nullable<Quaternion>;
  78872. /**
  78873. * The forward direction of that transform in world space.
  78874. */
  78875. readonly forward: Vector3;
  78876. /**
  78877. * The up direction of that transform in world space.
  78878. */
  78879. readonly up: Vector3;
  78880. /**
  78881. * The right direction of that transform in world space.
  78882. */
  78883. readonly right: Vector3;
  78884. /**
  78885. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78886. * @param matrix the matrix to copy the pose from
  78887. * @returns this TransformNode.
  78888. */
  78889. updatePoseMatrix(matrix: Matrix): TransformNode;
  78890. /**
  78891. * Returns the mesh Pose matrix.
  78892. * @returns the pose matrix
  78893. */
  78894. getPoseMatrix(): Matrix;
  78895. /** @hidden */
  78896. _isSynchronized(): boolean;
  78897. /** @hidden */
  78898. _initCache(): void;
  78899. /**
  78900. * Flag the transform node as dirty (Forcing it to update everything)
  78901. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78902. * @returns this transform node
  78903. */
  78904. markAsDirty(property: string): TransformNode;
  78905. /**
  78906. * Returns the current mesh absolute position.
  78907. * Returns a Vector3.
  78908. */
  78909. readonly absolutePosition: Vector3;
  78910. /**
  78911. * Returns the current mesh absolute scaling.
  78912. * Returns a Vector3.
  78913. */
  78914. readonly absoluteScaling: Vector3;
  78915. /**
  78916. * Returns the current mesh absolute rotation.
  78917. * Returns a Quaternion.
  78918. */
  78919. readonly absoluteRotationQuaternion: Quaternion;
  78920. /**
  78921. * Sets a new matrix to apply before all other transformation
  78922. * @param matrix defines the transform matrix
  78923. * @returns the current TransformNode
  78924. */
  78925. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78926. /**
  78927. * Sets a new pivot matrix to the current node
  78928. * @param matrix defines the new pivot matrix to use
  78929. * @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
  78930. * @returns the current TransformNode
  78931. */
  78932. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78933. /**
  78934. * Returns the mesh pivot matrix.
  78935. * Default : Identity.
  78936. * @returns the matrix
  78937. */
  78938. getPivotMatrix(): Matrix;
  78939. /**
  78940. * Instantiate (when possible) or clone that node with its hierarchy
  78941. * @param newParent defines the new parent to use for the instance (or clone)
  78942. * @returns an instance (or a clone) of the current node with its hiearchy
  78943. */
  78944. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  78945. /**
  78946. * Prevents the World matrix to be computed any longer
  78947. * @param newWorldMatrix defines an optional matrix to use as world matrix
  78948. * @returns the TransformNode.
  78949. */
  78950. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  78951. /**
  78952. * Allows back the World matrix computation.
  78953. * @returns the TransformNode.
  78954. */
  78955. unfreezeWorldMatrix(): this;
  78956. /**
  78957. * True if the World matrix has been frozen.
  78958. */
  78959. readonly isWorldMatrixFrozen: boolean;
  78960. /**
  78961. * Retuns the mesh absolute position in the World.
  78962. * @returns a Vector3.
  78963. */
  78964. getAbsolutePosition(): Vector3;
  78965. /**
  78966. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78967. * @param absolutePosition the absolute position to set
  78968. * @returns the TransformNode.
  78969. */
  78970. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78971. /**
  78972. * Sets the mesh position in its local space.
  78973. * @param vector3 the position to set in localspace
  78974. * @returns the TransformNode.
  78975. */
  78976. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78977. /**
  78978. * Returns the mesh position in the local space from the current World matrix values.
  78979. * @returns a new Vector3.
  78980. */
  78981. getPositionExpressedInLocalSpace(): Vector3;
  78982. /**
  78983. * Translates the mesh along the passed Vector3 in its local space.
  78984. * @param vector3 the distance to translate in localspace
  78985. * @returns the TransformNode.
  78986. */
  78987. locallyTranslate(vector3: Vector3): TransformNode;
  78988. private static _lookAtVectorCache;
  78989. /**
  78990. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78991. * @param targetPoint the position (must be in same space as current mesh) to look at
  78992. * @param yawCor optional yaw (y-axis) correction in radians
  78993. * @param pitchCor optional pitch (x-axis) correction in radians
  78994. * @param rollCor optional roll (z-axis) correction in radians
  78995. * @param space the choosen space of the target
  78996. * @returns the TransformNode.
  78997. */
  78998. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78999. /**
  79000. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79001. * This Vector3 is expressed in the World space.
  79002. * @param localAxis axis to rotate
  79003. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79004. */
  79005. getDirection(localAxis: Vector3): Vector3;
  79006. /**
  79007. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79008. * localAxis is expressed in the mesh local space.
  79009. * result is computed in the Wordl space from the mesh World matrix.
  79010. * @param localAxis axis to rotate
  79011. * @param result the resulting transformnode
  79012. * @returns this TransformNode.
  79013. */
  79014. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79015. /**
  79016. * Sets this transform node rotation to the given local axis.
  79017. * @param localAxis the axis in local space
  79018. * @param yawCor optional yaw (y-axis) correction in radians
  79019. * @param pitchCor optional pitch (x-axis) correction in radians
  79020. * @param rollCor optional roll (z-axis) correction in radians
  79021. * @returns this TransformNode
  79022. */
  79023. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79024. /**
  79025. * Sets a new pivot point to the current node
  79026. * @param point defines the new pivot point to use
  79027. * @param space defines if the point is in world or local space (local by default)
  79028. * @returns the current TransformNode
  79029. */
  79030. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79031. /**
  79032. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79033. * @returns the pivot point
  79034. */
  79035. getPivotPoint(): Vector3;
  79036. /**
  79037. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79038. * @param result the vector3 to store the result
  79039. * @returns this TransformNode.
  79040. */
  79041. getPivotPointToRef(result: Vector3): TransformNode;
  79042. /**
  79043. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79044. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79045. */
  79046. getAbsolutePivotPoint(): Vector3;
  79047. /**
  79048. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79049. * @param result vector3 to store the result
  79050. * @returns this TransformNode.
  79051. */
  79052. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79053. /**
  79054. * Defines the passed node as the parent of the current node.
  79055. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79056. * @see https://doc.babylonjs.com/how_to/parenting
  79057. * @param node the node ot set as the parent
  79058. * @returns this TransformNode.
  79059. */
  79060. setParent(node: Nullable<Node>): TransformNode;
  79061. private _nonUniformScaling;
  79062. /**
  79063. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79064. */
  79065. readonly nonUniformScaling: boolean;
  79066. /** @hidden */
  79067. _updateNonUniformScalingState(value: boolean): boolean;
  79068. /**
  79069. * Attach the current TransformNode to another TransformNode associated with a bone
  79070. * @param bone Bone affecting the TransformNode
  79071. * @param affectedTransformNode TransformNode associated with the bone
  79072. * @returns this object
  79073. */
  79074. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79075. /**
  79076. * Detach the transform node if its associated with a bone
  79077. * @returns this object
  79078. */
  79079. detachFromBone(): TransformNode;
  79080. private static _rotationAxisCache;
  79081. /**
  79082. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79083. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79084. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79085. * The passed axis is also normalized.
  79086. * @param axis the axis to rotate around
  79087. * @param amount the amount to rotate in radians
  79088. * @param space Space to rotate in (Default: local)
  79089. * @returns the TransformNode.
  79090. */
  79091. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79092. /**
  79093. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79094. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79095. * The passed axis is also normalized. .
  79096. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79097. * @param point the point to rotate around
  79098. * @param axis the axis to rotate around
  79099. * @param amount the amount to rotate in radians
  79100. * @returns the TransformNode
  79101. */
  79102. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79103. /**
  79104. * Translates the mesh along the axis vector for the passed distance in the given space.
  79105. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79106. * @param axis the axis to translate in
  79107. * @param distance the distance to translate
  79108. * @param space Space to rotate in (Default: local)
  79109. * @returns the TransformNode.
  79110. */
  79111. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79112. /**
  79113. * Adds a rotation step to the mesh current rotation.
  79114. * x, y, z are Euler angles expressed in radians.
  79115. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79116. * This means this rotation is made in the mesh local space only.
  79117. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79118. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79119. * ```javascript
  79120. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79121. * ```
  79122. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79123. * 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.
  79124. * @param x Rotation to add
  79125. * @param y Rotation to add
  79126. * @param z Rotation to add
  79127. * @returns the TransformNode.
  79128. */
  79129. addRotation(x: number, y: number, z: number): TransformNode;
  79130. /**
  79131. * @hidden
  79132. */
  79133. protected _getEffectiveParent(): Nullable<Node>;
  79134. /**
  79135. * Computes the world matrix of the node
  79136. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79137. * @returns the world matrix
  79138. */
  79139. computeWorldMatrix(force?: boolean): Matrix;
  79140. protected _afterComputeWorldMatrix(): void;
  79141. /**
  79142. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79143. * @param func callback function to add
  79144. *
  79145. * @returns the TransformNode.
  79146. */
  79147. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79148. /**
  79149. * Removes a registered callback function.
  79150. * @param func callback function to remove
  79151. * @returns the TransformNode.
  79152. */
  79153. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79154. /**
  79155. * Gets the position of the current mesh in camera space
  79156. * @param camera defines the camera to use
  79157. * @returns a position
  79158. */
  79159. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79160. /**
  79161. * Returns the distance from the mesh to the active camera
  79162. * @param camera defines the camera to use
  79163. * @returns the distance
  79164. */
  79165. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79166. /**
  79167. * Clone the current transform node
  79168. * @param name Name of the new clone
  79169. * @param newParent New parent for the clone
  79170. * @param doNotCloneChildren Do not clone children hierarchy
  79171. * @returns the new transform node
  79172. */
  79173. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79174. /**
  79175. * Serializes the objects information.
  79176. * @param currentSerializationObject defines the object to serialize in
  79177. * @returns the serialized object
  79178. */
  79179. serialize(currentSerializationObject?: any): any;
  79180. /**
  79181. * Returns a new TransformNode object parsed from the source provided.
  79182. * @param parsedTransformNode is the source.
  79183. * @param scene the scne the object belongs to
  79184. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79185. * @returns a new TransformNode object parsed from the source provided.
  79186. */
  79187. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79188. /**
  79189. * Get all child-transformNodes of this node
  79190. * @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
  79191. * @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
  79192. * @returns an array of TransformNode
  79193. */
  79194. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79195. /**
  79196. * Releases resources associated with this transform node.
  79197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79199. */
  79200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79201. /**
  79202. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79203. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79204. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79205. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79206. * @returns the current mesh
  79207. */
  79208. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79209. private _syncAbsoluteScalingAndRotation;
  79210. }
  79211. }
  79212. declare module BABYLON {
  79213. /**
  79214. * Defines the types of pose enabled controllers that are supported
  79215. */
  79216. export enum PoseEnabledControllerType {
  79217. /**
  79218. * HTC Vive
  79219. */
  79220. VIVE = 0,
  79221. /**
  79222. * Oculus Rift
  79223. */
  79224. OCULUS = 1,
  79225. /**
  79226. * Windows mixed reality
  79227. */
  79228. WINDOWS = 2,
  79229. /**
  79230. * Samsung gear VR
  79231. */
  79232. GEAR_VR = 3,
  79233. /**
  79234. * Google Daydream
  79235. */
  79236. DAYDREAM = 4,
  79237. /**
  79238. * Generic
  79239. */
  79240. GENERIC = 5
  79241. }
  79242. /**
  79243. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79244. */
  79245. export interface MutableGamepadButton {
  79246. /**
  79247. * Value of the button/trigger
  79248. */
  79249. value: number;
  79250. /**
  79251. * If the button/trigger is currently touched
  79252. */
  79253. touched: boolean;
  79254. /**
  79255. * If the button/trigger is currently pressed
  79256. */
  79257. pressed: boolean;
  79258. }
  79259. /**
  79260. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79261. * @hidden
  79262. */
  79263. export interface ExtendedGamepadButton extends GamepadButton {
  79264. /**
  79265. * If the button/trigger is currently pressed
  79266. */
  79267. readonly pressed: boolean;
  79268. /**
  79269. * If the button/trigger is currently touched
  79270. */
  79271. readonly touched: boolean;
  79272. /**
  79273. * Value of the button/trigger
  79274. */
  79275. readonly value: number;
  79276. }
  79277. /** @hidden */
  79278. export interface _GamePadFactory {
  79279. /**
  79280. * Returns wether or not the current gamepad can be created for this type of controller.
  79281. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79282. * @returns true if it can be created, otherwise false
  79283. */
  79284. canCreate(gamepadInfo: any): boolean;
  79285. /**
  79286. * Creates a new instance of the Gamepad.
  79287. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79288. * @returns the new gamepad instance
  79289. */
  79290. create(gamepadInfo: any): Gamepad;
  79291. }
  79292. /**
  79293. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79294. */
  79295. export class PoseEnabledControllerHelper {
  79296. /** @hidden */
  79297. static _ControllerFactories: _GamePadFactory[];
  79298. /** @hidden */
  79299. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79300. /**
  79301. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79302. * @param vrGamepad the gamepad to initialized
  79303. * @returns a vr controller of the type the gamepad identified as
  79304. */
  79305. static InitiateController(vrGamepad: any): Gamepad;
  79306. }
  79307. /**
  79308. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79309. */
  79310. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79311. /**
  79312. * If the controller is used in a webXR session
  79313. */
  79314. isXR: boolean;
  79315. private _deviceRoomPosition;
  79316. private _deviceRoomRotationQuaternion;
  79317. /**
  79318. * The device position in babylon space
  79319. */
  79320. devicePosition: Vector3;
  79321. /**
  79322. * The device rotation in babylon space
  79323. */
  79324. deviceRotationQuaternion: Quaternion;
  79325. /**
  79326. * The scale factor of the device in babylon space
  79327. */
  79328. deviceScaleFactor: number;
  79329. /**
  79330. * (Likely devicePosition should be used instead) The device position in its room space
  79331. */
  79332. position: Vector3;
  79333. /**
  79334. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79335. */
  79336. rotationQuaternion: Quaternion;
  79337. /**
  79338. * The type of controller (Eg. Windows mixed reality)
  79339. */
  79340. controllerType: PoseEnabledControllerType;
  79341. protected _calculatedPosition: Vector3;
  79342. private _calculatedRotation;
  79343. /**
  79344. * The raw pose from the device
  79345. */
  79346. rawPose: DevicePose;
  79347. private _trackPosition;
  79348. private _maxRotationDistFromHeadset;
  79349. private _draggedRoomRotation;
  79350. /**
  79351. * @hidden
  79352. */
  79353. _disableTrackPosition(fixedPosition: Vector3): void;
  79354. /**
  79355. * Internal, the mesh attached to the controller
  79356. * @hidden
  79357. */
  79358. _mesh: Nullable<AbstractMesh>;
  79359. private _poseControlledCamera;
  79360. private _leftHandSystemQuaternion;
  79361. /**
  79362. * Internal, matrix used to convert room space to babylon space
  79363. * @hidden
  79364. */
  79365. _deviceToWorld: Matrix;
  79366. /**
  79367. * Node to be used when casting a ray from the controller
  79368. * @hidden
  79369. */
  79370. _pointingPoseNode: Nullable<TransformNode>;
  79371. /**
  79372. * Name of the child mesh that can be used to cast a ray from the controller
  79373. */
  79374. static readonly POINTING_POSE: string;
  79375. /**
  79376. * Creates a new PoseEnabledController from a gamepad
  79377. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79378. */
  79379. constructor(browserGamepad: any);
  79380. private _workingMatrix;
  79381. /**
  79382. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79383. */
  79384. update(): void;
  79385. /**
  79386. * Updates only the pose device and mesh without doing any button event checking
  79387. */
  79388. protected _updatePoseAndMesh(): void;
  79389. /**
  79390. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79391. * @param poseData raw pose fromthe device
  79392. */
  79393. updateFromDevice(poseData: DevicePose): void;
  79394. /**
  79395. * @hidden
  79396. */
  79397. _meshAttachedObservable: Observable<AbstractMesh>;
  79398. /**
  79399. * Attaches a mesh to the controller
  79400. * @param mesh the mesh to be attached
  79401. */
  79402. attachToMesh(mesh: AbstractMesh): void;
  79403. /**
  79404. * Attaches the controllers mesh to a camera
  79405. * @param camera the camera the mesh should be attached to
  79406. */
  79407. attachToPoseControlledCamera(camera: TargetCamera): void;
  79408. /**
  79409. * Disposes of the controller
  79410. */
  79411. dispose(): void;
  79412. /**
  79413. * The mesh that is attached to the controller
  79414. */
  79415. readonly mesh: Nullable<AbstractMesh>;
  79416. /**
  79417. * Gets the ray of the controller in the direction the controller is pointing
  79418. * @param length the length the resulting ray should be
  79419. * @returns a ray in the direction the controller is pointing
  79420. */
  79421. getForwardRay(length?: number): Ray;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /**
  79426. * Defines the WebVRController object that represents controllers tracked in 3D space
  79427. */
  79428. export abstract class WebVRController extends PoseEnabledController {
  79429. /**
  79430. * Internal, the default controller model for the controller
  79431. */
  79432. protected _defaultModel: AbstractMesh;
  79433. /**
  79434. * Fired when the trigger state has changed
  79435. */
  79436. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79437. /**
  79438. * Fired when the main button state has changed
  79439. */
  79440. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79441. /**
  79442. * Fired when the secondary button state has changed
  79443. */
  79444. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79445. /**
  79446. * Fired when the pad state has changed
  79447. */
  79448. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79449. /**
  79450. * Fired when controllers stick values have changed
  79451. */
  79452. onPadValuesChangedObservable: Observable<StickValues>;
  79453. /**
  79454. * Array of button availible on the controller
  79455. */
  79456. protected _buttons: Array<MutableGamepadButton>;
  79457. private _onButtonStateChange;
  79458. /**
  79459. * Fired when a controller button's state has changed
  79460. * @param callback the callback containing the button that was modified
  79461. */
  79462. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79463. /**
  79464. * X and Y axis corresponding to the controllers joystick
  79465. */
  79466. pad: StickValues;
  79467. /**
  79468. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79469. */
  79470. hand: string;
  79471. /**
  79472. * The default controller model for the controller
  79473. */
  79474. readonly defaultModel: AbstractMesh;
  79475. /**
  79476. * Creates a new WebVRController from a gamepad
  79477. * @param vrGamepad the gamepad that the WebVRController should be created from
  79478. */
  79479. constructor(vrGamepad: any);
  79480. /**
  79481. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79482. */
  79483. update(): void;
  79484. /**
  79485. * Function to be called when a button is modified
  79486. */
  79487. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79488. /**
  79489. * Loads a mesh and attaches it to the controller
  79490. * @param scene the scene the mesh should be added to
  79491. * @param meshLoaded callback for when the mesh has been loaded
  79492. */
  79493. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79494. private _setButtonValue;
  79495. private _changes;
  79496. private _checkChanges;
  79497. /**
  79498. * Disposes of th webVRCOntroller
  79499. */
  79500. dispose(): void;
  79501. }
  79502. }
  79503. declare module BABYLON {
  79504. /**
  79505. * The HemisphericLight simulates the ambient environment light,
  79506. * so the passed direction is the light reflection direction, not the incoming direction.
  79507. */
  79508. export class HemisphericLight extends Light {
  79509. /**
  79510. * The groundColor is the light in the opposite direction to the one specified during creation.
  79511. * 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.
  79512. */
  79513. groundColor: Color3;
  79514. /**
  79515. * The light reflection direction, not the incoming direction.
  79516. */
  79517. direction: Vector3;
  79518. /**
  79519. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79520. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79521. * The HemisphericLight can't cast shadows.
  79522. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79523. * @param name The friendly name of the light
  79524. * @param direction The direction of the light reflection
  79525. * @param scene The scene the light belongs to
  79526. */
  79527. constructor(name: string, direction: Vector3, scene: Scene);
  79528. protected _buildUniformLayout(): void;
  79529. /**
  79530. * Returns the string "HemisphericLight".
  79531. * @return The class name
  79532. */
  79533. getClassName(): string;
  79534. /**
  79535. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79536. * Returns the updated direction.
  79537. * @param target The target the direction should point to
  79538. * @return The computed direction
  79539. */
  79540. setDirectionToTarget(target: Vector3): Vector3;
  79541. /**
  79542. * Returns the shadow generator associated to the light.
  79543. * @returns Always null for hemispheric lights because it does not support shadows.
  79544. */
  79545. getShadowGenerator(): Nullable<IShadowGenerator>;
  79546. /**
  79547. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79548. * @param effect The effect to update
  79549. * @param lightIndex The index of the light in the effect to update
  79550. * @returns The hemispheric light
  79551. */
  79552. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79553. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  79554. /**
  79555. * Computes the world matrix of the node
  79556. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79557. * @param useWasUpdatedFlag defines a reserved property
  79558. * @returns the world matrix
  79559. */
  79560. computeWorldMatrix(): Matrix;
  79561. /**
  79562. * Returns the integer 3.
  79563. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79564. */
  79565. getTypeID(): number;
  79566. /**
  79567. * Prepares the list of defines specific to the light type.
  79568. * @param defines the list of defines
  79569. * @param lightIndex defines the index of the light for the effect
  79570. */
  79571. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79572. }
  79573. }
  79574. declare module BABYLON {
  79575. /** @hidden */
  79576. export var vrMultiviewToSingleviewPixelShader: {
  79577. name: string;
  79578. shader: string;
  79579. };
  79580. }
  79581. declare module BABYLON {
  79582. /**
  79583. * Renders to multiple views with a single draw call
  79584. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79585. */
  79586. export class MultiviewRenderTarget extends RenderTargetTexture {
  79587. /**
  79588. * Creates a multiview render target
  79589. * @param scene scene used with the render target
  79590. * @param size the size of the render target (used for each view)
  79591. */
  79592. constructor(scene: Scene, size?: number | {
  79593. width: number;
  79594. height: number;
  79595. } | {
  79596. ratio: number;
  79597. });
  79598. /**
  79599. * @hidden
  79600. * @param faceIndex the face index, if its a cube texture
  79601. */
  79602. _bindFrameBuffer(faceIndex?: number): void;
  79603. /**
  79604. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79605. * @returns the view count
  79606. */
  79607. getViewCount(): number;
  79608. }
  79609. }
  79610. declare module BABYLON {
  79611. /**
  79612. * Reprasents a camera frustum
  79613. */
  79614. export class Frustum {
  79615. /**
  79616. * Gets the planes representing the frustum
  79617. * @param transform matrix to be applied to the returned planes
  79618. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79619. */
  79620. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79621. /**
  79622. * Gets the near frustum plane transformed by the transform matrix
  79623. * @param transform transformation matrix to be applied to the resulting frustum plane
  79624. * @param frustumPlane the resuling frustum plane
  79625. */
  79626. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79627. /**
  79628. * Gets the far frustum plane transformed by the transform matrix
  79629. * @param transform transformation matrix to be applied to the resulting frustum plane
  79630. * @param frustumPlane the resuling frustum plane
  79631. */
  79632. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79633. /**
  79634. * Gets the left frustum plane transformed by the transform matrix
  79635. * @param transform transformation matrix to be applied to the resulting frustum plane
  79636. * @param frustumPlane the resuling frustum plane
  79637. */
  79638. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79639. /**
  79640. * Gets the right frustum plane transformed by the transform matrix
  79641. * @param transform transformation matrix to be applied to the resulting frustum plane
  79642. * @param frustumPlane the resuling frustum plane
  79643. */
  79644. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79645. /**
  79646. * Gets the top frustum plane transformed by the transform matrix
  79647. * @param transform transformation matrix to be applied to the resulting frustum plane
  79648. * @param frustumPlane the resuling frustum plane
  79649. */
  79650. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79651. /**
  79652. * Gets the bottom frustum plane transformed by the transform matrix
  79653. * @param transform transformation matrix to be applied to the resulting frustum plane
  79654. * @param frustumPlane the resuling frustum plane
  79655. */
  79656. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79657. /**
  79658. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79659. * @param transform transformation matrix to be applied to the resulting frustum planes
  79660. * @param frustumPlanes the resuling frustum planes
  79661. */
  79662. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79663. }
  79664. }
  79665. declare module BABYLON {
  79666. interface Engine {
  79667. /**
  79668. * Creates a new multiview render target
  79669. * @param width defines the width of the texture
  79670. * @param height defines the height of the texture
  79671. * @returns the created multiview texture
  79672. */
  79673. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79674. /**
  79675. * Binds a multiview framebuffer to be drawn to
  79676. * @param multiviewTexture texture to bind
  79677. */
  79678. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79679. }
  79680. interface Camera {
  79681. /**
  79682. * @hidden
  79683. * 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)
  79684. */
  79685. _useMultiviewToSingleView: boolean;
  79686. /**
  79687. * @hidden
  79688. * 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)
  79689. */
  79690. _multiviewTexture: Nullable<RenderTargetTexture>;
  79691. /**
  79692. * @hidden
  79693. * ensures the multiview texture of the camera exists and has the specified width/height
  79694. * @param width height to set on the multiview texture
  79695. * @param height width to set on the multiview texture
  79696. */
  79697. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79698. }
  79699. interface Scene {
  79700. /** @hidden */
  79701. _transformMatrixR: Matrix;
  79702. /** @hidden */
  79703. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79704. /** @hidden */
  79705. _createMultiviewUbo(): void;
  79706. /** @hidden */
  79707. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79708. /** @hidden */
  79709. _renderMultiviewToSingleView(camera: Camera): void;
  79710. }
  79711. }
  79712. declare module BABYLON {
  79713. /**
  79714. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79715. * This will not be used for webXR as it supports displaying texture arrays directly
  79716. */
  79717. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79718. /**
  79719. * Initializes a VRMultiviewToSingleview
  79720. * @param name name of the post process
  79721. * @param camera camera to be applied to
  79722. * @param scaleFactor scaling factor to the size of the output texture
  79723. */
  79724. constructor(name: string, camera: Camera, scaleFactor: number);
  79725. }
  79726. }
  79727. declare module BABYLON {
  79728. interface Engine {
  79729. /** @hidden */
  79730. _vrDisplay: any;
  79731. /** @hidden */
  79732. _vrSupported: boolean;
  79733. /** @hidden */
  79734. _oldSize: Size;
  79735. /** @hidden */
  79736. _oldHardwareScaleFactor: number;
  79737. /** @hidden */
  79738. _vrExclusivePointerMode: boolean;
  79739. /** @hidden */
  79740. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79741. /** @hidden */
  79742. _onVRDisplayPointerRestricted: () => void;
  79743. /** @hidden */
  79744. _onVRDisplayPointerUnrestricted: () => void;
  79745. /** @hidden */
  79746. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79747. /** @hidden */
  79748. _onVrDisplayDisconnect: Nullable<() => void>;
  79749. /** @hidden */
  79750. _onVrDisplayPresentChange: Nullable<() => void>;
  79751. /**
  79752. * Observable signaled when VR display mode changes
  79753. */
  79754. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79755. /**
  79756. * Observable signaled when VR request present is complete
  79757. */
  79758. onVRRequestPresentComplete: Observable<boolean>;
  79759. /**
  79760. * Observable signaled when VR request present starts
  79761. */
  79762. onVRRequestPresentStart: Observable<Engine>;
  79763. /**
  79764. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79765. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79766. */
  79767. isInVRExclusivePointerMode: boolean;
  79768. /**
  79769. * Gets a boolean indicating if a webVR device was detected
  79770. * @returns true if a webVR device was detected
  79771. */
  79772. isVRDevicePresent(): boolean;
  79773. /**
  79774. * Gets the current webVR device
  79775. * @returns the current webVR device (or null)
  79776. */
  79777. getVRDevice(): any;
  79778. /**
  79779. * Initializes a webVR display and starts listening to display change events
  79780. * The onVRDisplayChangedObservable will be notified upon these changes
  79781. * @returns A promise containing a VRDisplay and if vr is supported
  79782. */
  79783. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79784. /** @hidden */
  79785. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79786. /**
  79787. * Call this function to switch to webVR mode
  79788. * Will do nothing if webVR is not supported or if there is no webVR device
  79789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79790. */
  79791. enableVR(): void;
  79792. /** @hidden */
  79793. _onVRFullScreenTriggered(): void;
  79794. }
  79795. }
  79796. declare module BABYLON {
  79797. /**
  79798. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79799. * IMPORTANT!! The data is right-hand data.
  79800. * @export
  79801. * @interface DevicePose
  79802. */
  79803. export interface DevicePose {
  79804. /**
  79805. * The position of the device, values in array are [x,y,z].
  79806. */
  79807. readonly position: Nullable<Float32Array>;
  79808. /**
  79809. * The linearVelocity of the device, values in array are [x,y,z].
  79810. */
  79811. readonly linearVelocity: Nullable<Float32Array>;
  79812. /**
  79813. * The linearAcceleration of the device, values in array are [x,y,z].
  79814. */
  79815. readonly linearAcceleration: Nullable<Float32Array>;
  79816. /**
  79817. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79818. */
  79819. readonly orientation: Nullable<Float32Array>;
  79820. /**
  79821. * The angularVelocity of the device, values in array are [x,y,z].
  79822. */
  79823. readonly angularVelocity: Nullable<Float32Array>;
  79824. /**
  79825. * The angularAcceleration of the device, values in array are [x,y,z].
  79826. */
  79827. readonly angularAcceleration: Nullable<Float32Array>;
  79828. }
  79829. /**
  79830. * Interface representing a pose controlled object in Babylon.
  79831. * A pose controlled object has both regular pose values as well as pose values
  79832. * from an external device such as a VR head mounted display
  79833. */
  79834. export interface PoseControlled {
  79835. /**
  79836. * The position of the object in babylon space.
  79837. */
  79838. position: Vector3;
  79839. /**
  79840. * The rotation quaternion of the object in babylon space.
  79841. */
  79842. rotationQuaternion: Quaternion;
  79843. /**
  79844. * The position of the device in babylon space.
  79845. */
  79846. devicePosition?: Vector3;
  79847. /**
  79848. * The rotation quaternion of the device in babylon space.
  79849. */
  79850. deviceRotationQuaternion: Quaternion;
  79851. /**
  79852. * The raw pose coming from the device.
  79853. */
  79854. rawPose: Nullable<DevicePose>;
  79855. /**
  79856. * The scale of the device to be used when translating from device space to babylon space.
  79857. */
  79858. deviceScaleFactor: number;
  79859. /**
  79860. * Updates the poseControlled values based on the input device pose.
  79861. * @param poseData the pose data to update the object with
  79862. */
  79863. updateFromDevice(poseData: DevicePose): void;
  79864. }
  79865. /**
  79866. * Set of options to customize the webVRCamera
  79867. */
  79868. export interface WebVROptions {
  79869. /**
  79870. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79871. */
  79872. trackPosition?: boolean;
  79873. /**
  79874. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79875. */
  79876. positionScale?: number;
  79877. /**
  79878. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79879. */
  79880. displayName?: string;
  79881. /**
  79882. * Should the native controller meshes be initialized. (default: true)
  79883. */
  79884. controllerMeshes?: boolean;
  79885. /**
  79886. * Creating a default HemiLight only on controllers. (default: true)
  79887. */
  79888. defaultLightingOnControllers?: boolean;
  79889. /**
  79890. * If you don't want to use the default VR button of the helper. (default: false)
  79891. */
  79892. useCustomVRButton?: boolean;
  79893. /**
  79894. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79895. */
  79896. customVRButton?: HTMLButtonElement;
  79897. /**
  79898. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79899. */
  79900. rayLength?: number;
  79901. /**
  79902. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79903. */
  79904. defaultHeight?: number;
  79905. /**
  79906. * If multiview should be used if availible (default: false)
  79907. */
  79908. useMultiview?: boolean;
  79909. }
  79910. /**
  79911. * This represents a WebVR camera.
  79912. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79913. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79914. */
  79915. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79916. private webVROptions;
  79917. /**
  79918. * @hidden
  79919. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79920. */
  79921. _vrDevice: any;
  79922. /**
  79923. * The rawPose of the vrDevice.
  79924. */
  79925. rawPose: Nullable<DevicePose>;
  79926. private _onVREnabled;
  79927. private _specsVersion;
  79928. private _attached;
  79929. private _frameData;
  79930. protected _descendants: Array<Node>;
  79931. private _deviceRoomPosition;
  79932. /** @hidden */
  79933. _deviceRoomRotationQuaternion: Quaternion;
  79934. private _standingMatrix;
  79935. /**
  79936. * Represents device position in babylon space.
  79937. */
  79938. devicePosition: Vector3;
  79939. /**
  79940. * Represents device rotation in babylon space.
  79941. */
  79942. deviceRotationQuaternion: Quaternion;
  79943. /**
  79944. * The scale of the device to be used when translating from device space to babylon space.
  79945. */
  79946. deviceScaleFactor: number;
  79947. private _deviceToWorld;
  79948. private _worldToDevice;
  79949. /**
  79950. * References to the webVR controllers for the vrDevice.
  79951. */
  79952. controllers: Array<WebVRController>;
  79953. /**
  79954. * Emits an event when a controller is attached.
  79955. */
  79956. onControllersAttachedObservable: Observable<WebVRController[]>;
  79957. /**
  79958. * Emits an event when a controller's mesh has been loaded;
  79959. */
  79960. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79961. /**
  79962. * Emits an event when the HMD's pose has been updated.
  79963. */
  79964. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79965. private _poseSet;
  79966. /**
  79967. * If the rig cameras be used as parent instead of this camera.
  79968. */
  79969. rigParenting: boolean;
  79970. private _lightOnControllers;
  79971. private _defaultHeight?;
  79972. /**
  79973. * Instantiates a WebVRFreeCamera.
  79974. * @param name The name of the WebVRFreeCamera
  79975. * @param position The starting anchor position for the camera
  79976. * @param scene The scene the camera belongs to
  79977. * @param webVROptions a set of customizable options for the webVRCamera
  79978. */
  79979. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79980. /**
  79981. * Gets the device distance from the ground in meters.
  79982. * @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.
  79983. */
  79984. deviceDistanceToRoomGround(): number;
  79985. /**
  79986. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79987. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79988. */
  79989. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79990. /**
  79991. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79992. * @returns A promise with a boolean set to if the standing matrix is supported.
  79993. */
  79994. useStandingMatrixAsync(): Promise<boolean>;
  79995. /**
  79996. * Disposes the camera
  79997. */
  79998. dispose(): void;
  79999. /**
  80000. * Gets a vrController by name.
  80001. * @param name The name of the controller to retreive
  80002. * @returns the controller matching the name specified or null if not found
  80003. */
  80004. getControllerByName(name: string): Nullable<WebVRController>;
  80005. private _leftController;
  80006. /**
  80007. * The controller corresponding to the users left hand.
  80008. */
  80009. readonly leftController: Nullable<WebVRController>;
  80010. private _rightController;
  80011. /**
  80012. * The controller corresponding to the users right hand.
  80013. */
  80014. readonly rightController: Nullable<WebVRController>;
  80015. /**
  80016. * Casts a ray forward from the vrCamera's gaze.
  80017. * @param length Length of the ray (default: 100)
  80018. * @returns the ray corresponding to the gaze
  80019. */
  80020. getForwardRay(length?: number): Ray;
  80021. /**
  80022. * @hidden
  80023. * Updates the camera based on device's frame data
  80024. */
  80025. _checkInputs(): void;
  80026. /**
  80027. * Updates the poseControlled values based on the input device pose.
  80028. * @param poseData Pose coming from the device
  80029. */
  80030. updateFromDevice(poseData: DevicePose): void;
  80031. private _htmlElementAttached;
  80032. private _detachIfAttached;
  80033. /**
  80034. * WebVR's attach control will start broadcasting frames to the device.
  80035. * Note that in certain browsers (chrome for example) this function must be called
  80036. * within a user-interaction callback. Example:
  80037. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80038. *
  80039. * @param element html element to attach the vrDevice to
  80040. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80041. */
  80042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80043. /**
  80044. * Detaches the camera from the html element and disables VR
  80045. *
  80046. * @param element html element to detach from
  80047. */
  80048. detachControl(element: HTMLElement): void;
  80049. /**
  80050. * @returns the name of this class
  80051. */
  80052. getClassName(): string;
  80053. /**
  80054. * Calls resetPose on the vrDisplay
  80055. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80056. */
  80057. resetToCurrentRotation(): void;
  80058. /**
  80059. * @hidden
  80060. * Updates the rig cameras (left and right eye)
  80061. */
  80062. _updateRigCameras(): void;
  80063. private _workingVector;
  80064. private _oneVector;
  80065. private _workingMatrix;
  80066. private updateCacheCalled;
  80067. private _correctPositionIfNotTrackPosition;
  80068. /**
  80069. * @hidden
  80070. * Updates the cached values of the camera
  80071. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80072. */
  80073. _updateCache(ignoreParentClass?: boolean): void;
  80074. /**
  80075. * @hidden
  80076. * Get current device position in babylon world
  80077. */
  80078. _computeDevicePosition(): void;
  80079. /**
  80080. * Updates the current device position and rotation in the babylon world
  80081. */
  80082. update(): void;
  80083. /**
  80084. * @hidden
  80085. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80086. * @returns an identity matrix
  80087. */
  80088. _getViewMatrix(): Matrix;
  80089. private _tmpMatrix;
  80090. /**
  80091. * This function is called by the two RIG cameras.
  80092. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80093. * @hidden
  80094. */
  80095. _getWebVRViewMatrix(): Matrix;
  80096. /** @hidden */
  80097. _getWebVRProjectionMatrix(): Matrix;
  80098. private _onGamepadConnectedObserver;
  80099. private _onGamepadDisconnectedObserver;
  80100. private _updateCacheWhenTrackingDisabledObserver;
  80101. /**
  80102. * Initializes the controllers and their meshes
  80103. */
  80104. initControllers(): void;
  80105. }
  80106. }
  80107. declare module BABYLON {
  80108. /**
  80109. * Size options for a post process
  80110. */
  80111. export type PostProcessOptions = {
  80112. width: number;
  80113. height: number;
  80114. };
  80115. /**
  80116. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80117. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80118. */
  80119. export class PostProcess {
  80120. /** Name of the PostProcess. */
  80121. name: string;
  80122. /**
  80123. * Gets or sets the unique id of the post process
  80124. */
  80125. uniqueId: number;
  80126. /**
  80127. * Width of the texture to apply the post process on
  80128. */
  80129. width: number;
  80130. /**
  80131. * Height of the texture to apply the post process on
  80132. */
  80133. height: number;
  80134. /**
  80135. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80136. * @hidden
  80137. */
  80138. _outputTexture: Nullable<InternalTexture>;
  80139. /**
  80140. * Sampling mode used by the shader
  80141. * See https://doc.babylonjs.com/classes/3.1/texture
  80142. */
  80143. renderTargetSamplingMode: number;
  80144. /**
  80145. * Clear color to use when screen clearing
  80146. */
  80147. clearColor: Color4;
  80148. /**
  80149. * If the buffer needs to be cleared before applying the post process. (default: true)
  80150. * Should be set to false if shader will overwrite all previous pixels.
  80151. */
  80152. autoClear: boolean;
  80153. /**
  80154. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80155. */
  80156. alphaMode: number;
  80157. /**
  80158. * Sets the setAlphaBlendConstants of the babylon engine
  80159. */
  80160. alphaConstants: Color4;
  80161. /**
  80162. * Animations to be used for the post processing
  80163. */
  80164. animations: Animation[];
  80165. /**
  80166. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80167. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80168. */
  80169. enablePixelPerfectMode: boolean;
  80170. /**
  80171. * Force the postprocess to be applied without taking in account viewport
  80172. */
  80173. forceFullscreenViewport: boolean;
  80174. /**
  80175. * List of inspectable custom properties (used by the Inspector)
  80176. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80177. */
  80178. inspectableCustomProperties: IInspectable[];
  80179. /**
  80180. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80181. *
  80182. * | Value | Type | Description |
  80183. * | ----- | ----------------------------------- | ----------- |
  80184. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80185. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80186. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80187. *
  80188. */
  80189. scaleMode: number;
  80190. /**
  80191. * Force textures to be a power of two (default: false)
  80192. */
  80193. alwaysForcePOT: boolean;
  80194. private _samples;
  80195. /**
  80196. * Number of sample textures (default: 1)
  80197. */
  80198. samples: number;
  80199. /**
  80200. * Modify the scale of the post process to be the same as the viewport (default: false)
  80201. */
  80202. adaptScaleToCurrentViewport: boolean;
  80203. private _camera;
  80204. private _scene;
  80205. private _engine;
  80206. private _options;
  80207. private _reusable;
  80208. private _textureType;
  80209. /**
  80210. * Smart array of input and output textures for the post process.
  80211. * @hidden
  80212. */
  80213. _textures: SmartArray<InternalTexture>;
  80214. /**
  80215. * The index in _textures that corresponds to the output texture.
  80216. * @hidden
  80217. */
  80218. _currentRenderTextureInd: number;
  80219. private _effect;
  80220. private _samplers;
  80221. private _fragmentUrl;
  80222. private _vertexUrl;
  80223. private _parameters;
  80224. private _scaleRatio;
  80225. protected _indexParameters: any;
  80226. private _shareOutputWithPostProcess;
  80227. private _texelSize;
  80228. private _forcedOutputTexture;
  80229. /**
  80230. * Returns the fragment url or shader name used in the post process.
  80231. * @returns the fragment url or name in the shader store.
  80232. */
  80233. getEffectName(): string;
  80234. /**
  80235. * An event triggered when the postprocess is activated.
  80236. */
  80237. onActivateObservable: Observable<Camera>;
  80238. private _onActivateObserver;
  80239. /**
  80240. * A function that is added to the onActivateObservable
  80241. */
  80242. onActivate: Nullable<(camera: Camera) => void>;
  80243. /**
  80244. * An event triggered when the postprocess changes its size.
  80245. */
  80246. onSizeChangedObservable: Observable<PostProcess>;
  80247. private _onSizeChangedObserver;
  80248. /**
  80249. * A function that is added to the onSizeChangedObservable
  80250. */
  80251. onSizeChanged: (postProcess: PostProcess) => void;
  80252. /**
  80253. * An event triggered when the postprocess applies its effect.
  80254. */
  80255. onApplyObservable: Observable<Effect>;
  80256. private _onApplyObserver;
  80257. /**
  80258. * A function that is added to the onApplyObservable
  80259. */
  80260. onApply: (effect: Effect) => void;
  80261. /**
  80262. * An event triggered before rendering the postprocess
  80263. */
  80264. onBeforeRenderObservable: Observable<Effect>;
  80265. private _onBeforeRenderObserver;
  80266. /**
  80267. * A function that is added to the onBeforeRenderObservable
  80268. */
  80269. onBeforeRender: (effect: Effect) => void;
  80270. /**
  80271. * An event triggered after rendering the postprocess
  80272. */
  80273. onAfterRenderObservable: Observable<Effect>;
  80274. private _onAfterRenderObserver;
  80275. /**
  80276. * A function that is added to the onAfterRenderObservable
  80277. */
  80278. onAfterRender: (efect: Effect) => void;
  80279. /**
  80280. * 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
  80281. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80282. */
  80283. inputTexture: InternalTexture;
  80284. /**
  80285. * Gets the camera which post process is applied to.
  80286. * @returns The camera the post process is applied to.
  80287. */
  80288. getCamera(): Camera;
  80289. /**
  80290. * Gets the texel size of the postprocess.
  80291. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80292. */
  80293. readonly texelSize: Vector2;
  80294. /**
  80295. * Creates a new instance PostProcess
  80296. * @param name The name of the PostProcess.
  80297. * @param fragmentUrl The url of the fragment shader to be used.
  80298. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80299. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80300. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80301. * @param camera The camera to apply the render pass to.
  80302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80303. * @param engine The engine which the post process will be applied. (default: current engine)
  80304. * @param reusable If the post process can be reused on the same frame. (default: false)
  80305. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80306. * @param textureType Type of textures used when performing the post process. (default: 0)
  80307. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80308. * @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
  80309. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80310. */
  80311. constructor(
  80312. /** Name of the PostProcess. */
  80313. 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);
  80314. /**
  80315. * Gets a string idenfifying the name of the class
  80316. * @returns "PostProcess" string
  80317. */
  80318. getClassName(): string;
  80319. /**
  80320. * Gets the engine which this post process belongs to.
  80321. * @returns The engine the post process was enabled with.
  80322. */
  80323. getEngine(): Engine;
  80324. /**
  80325. * The effect that is created when initializing the post process.
  80326. * @returns The created effect corresponding the the postprocess.
  80327. */
  80328. getEffect(): Effect;
  80329. /**
  80330. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80331. * @param postProcess The post process to share the output with.
  80332. * @returns This post process.
  80333. */
  80334. shareOutputWith(postProcess: PostProcess): PostProcess;
  80335. /**
  80336. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80337. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80338. */
  80339. useOwnOutput(): void;
  80340. /**
  80341. * Updates the effect with the current post process compile time values and recompiles the shader.
  80342. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80343. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80344. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80345. * @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
  80346. * @param onCompiled Called when the shader has been compiled.
  80347. * @param onError Called if there is an error when compiling a shader.
  80348. */
  80349. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80350. /**
  80351. * The post process is reusable if it can be used multiple times within one frame.
  80352. * @returns If the post process is reusable
  80353. */
  80354. isReusable(): boolean;
  80355. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80356. markTextureDirty(): void;
  80357. /**
  80358. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80359. * 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.
  80360. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80361. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80362. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80363. * @returns The target texture that was bound to be written to.
  80364. */
  80365. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80366. /**
  80367. * If the post process is supported.
  80368. */
  80369. readonly isSupported: boolean;
  80370. /**
  80371. * The aspect ratio of the output texture.
  80372. */
  80373. readonly aspectRatio: number;
  80374. /**
  80375. * Get a value indicating if the post-process is ready to be used
  80376. * @returns true if the post-process is ready (shader is compiled)
  80377. */
  80378. isReady(): boolean;
  80379. /**
  80380. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80381. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80382. */
  80383. apply(): Nullable<Effect>;
  80384. private _disposeTextures;
  80385. /**
  80386. * Disposes the post process.
  80387. * @param camera The camera to dispose the post process on.
  80388. */
  80389. dispose(camera?: Camera): void;
  80390. }
  80391. }
  80392. declare module BABYLON {
  80393. /** @hidden */
  80394. export var kernelBlurVaryingDeclaration: {
  80395. name: string;
  80396. shader: string;
  80397. };
  80398. }
  80399. declare module BABYLON {
  80400. /** @hidden */
  80401. export var kernelBlurFragment: {
  80402. name: string;
  80403. shader: string;
  80404. };
  80405. }
  80406. declare module BABYLON {
  80407. /** @hidden */
  80408. export var kernelBlurFragment2: {
  80409. name: string;
  80410. shader: string;
  80411. };
  80412. }
  80413. declare module BABYLON {
  80414. /** @hidden */
  80415. export var kernelBlurPixelShader: {
  80416. name: string;
  80417. shader: string;
  80418. };
  80419. }
  80420. declare module BABYLON {
  80421. /** @hidden */
  80422. export var kernelBlurVertex: {
  80423. name: string;
  80424. shader: string;
  80425. };
  80426. }
  80427. declare module BABYLON {
  80428. /** @hidden */
  80429. export var kernelBlurVertexShader: {
  80430. name: string;
  80431. shader: string;
  80432. };
  80433. }
  80434. declare module BABYLON {
  80435. /**
  80436. * The Blur Post Process which blurs an image based on a kernel and direction.
  80437. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80438. */
  80439. export class BlurPostProcess extends PostProcess {
  80440. /** The direction in which to blur the image. */
  80441. direction: Vector2;
  80442. private blockCompilation;
  80443. protected _kernel: number;
  80444. protected _idealKernel: number;
  80445. protected _packedFloat: boolean;
  80446. private _staticDefines;
  80447. /**
  80448. * Sets the length in pixels of the blur sample region
  80449. */
  80450. /**
  80451. * Gets the length in pixels of the blur sample region
  80452. */
  80453. kernel: number;
  80454. /**
  80455. * Sets wether or not the blur needs to unpack/repack floats
  80456. */
  80457. /**
  80458. * Gets wether or not the blur is unpacking/repacking floats
  80459. */
  80460. packedFloat: boolean;
  80461. /**
  80462. * Creates a new instance BlurPostProcess
  80463. * @param name The name of the effect.
  80464. * @param direction The direction in which to blur the image.
  80465. * @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.
  80466. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80467. * @param camera The camera to apply the render pass to.
  80468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80469. * @param engine The engine which the post process will be applied. (default: current engine)
  80470. * @param reusable If the post process can be reused on the same frame. (default: false)
  80471. * @param textureType Type of textures used when performing the post process. (default: 0)
  80472. * @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)
  80473. */
  80474. constructor(name: string,
  80475. /** The direction in which to blur the image. */
  80476. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80477. /**
  80478. * Updates the effect with the current post process compile time values and recompiles the shader.
  80479. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80480. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80481. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80482. * @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
  80483. * @param onCompiled Called when the shader has been compiled.
  80484. * @param onError Called if there is an error when compiling a shader.
  80485. */
  80486. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80487. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80488. /**
  80489. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80490. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80491. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80492. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80493. * The gaps between physical kernels are compensated for in the weighting of the samples
  80494. * @param idealKernel Ideal blur kernel.
  80495. * @return Nearest best kernel.
  80496. */
  80497. protected _nearestBestKernel(idealKernel: number): number;
  80498. /**
  80499. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80500. * @param x The point on the Gaussian distribution to sample.
  80501. * @return the value of the Gaussian function at x.
  80502. */
  80503. protected _gaussianWeight(x: number): number;
  80504. /**
  80505. * Generates a string that can be used as a floating point number in GLSL.
  80506. * @param x Value to print.
  80507. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80508. * @return GLSL float string.
  80509. */
  80510. protected _glslFloat(x: number, decimalFigures?: number): string;
  80511. }
  80512. }
  80513. declare module BABYLON {
  80514. /**
  80515. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80516. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80517. * You can then easily use it as a reflectionTexture on a flat surface.
  80518. * In case the surface is not a plane, please consider relying on reflection probes.
  80519. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80520. */
  80521. export class MirrorTexture extends RenderTargetTexture {
  80522. private scene;
  80523. /**
  80524. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80525. * 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.
  80526. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80527. */
  80528. mirrorPlane: Plane;
  80529. /**
  80530. * Define the blur ratio used to blur the reflection if needed.
  80531. */
  80532. blurRatio: number;
  80533. /**
  80534. * Define the adaptive blur kernel used to blur the reflection if needed.
  80535. * This will autocompute the closest best match for the `blurKernel`
  80536. */
  80537. adaptiveBlurKernel: number;
  80538. /**
  80539. * Define the blur kernel used to blur the reflection if needed.
  80540. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80541. */
  80542. blurKernel: number;
  80543. /**
  80544. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80545. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80546. */
  80547. blurKernelX: number;
  80548. /**
  80549. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80550. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80551. */
  80552. blurKernelY: number;
  80553. private _autoComputeBlurKernel;
  80554. protected _onRatioRescale(): void;
  80555. private _updateGammaSpace;
  80556. private _imageProcessingConfigChangeObserver;
  80557. private _transformMatrix;
  80558. private _mirrorMatrix;
  80559. private _savedViewMatrix;
  80560. private _blurX;
  80561. private _blurY;
  80562. private _adaptiveBlurKernel;
  80563. private _blurKernelX;
  80564. private _blurKernelY;
  80565. private _blurRatio;
  80566. /**
  80567. * Instantiates a Mirror Texture.
  80568. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80569. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80570. * You can then easily use it as a reflectionTexture on a flat surface.
  80571. * In case the surface is not a plane, please consider relying on reflection probes.
  80572. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80573. * @param name
  80574. * @param size
  80575. * @param scene
  80576. * @param generateMipMaps
  80577. * @param type
  80578. * @param samplingMode
  80579. * @param generateDepthBuffer
  80580. */
  80581. constructor(name: string, size: number | {
  80582. width: number;
  80583. height: number;
  80584. } | {
  80585. ratio: number;
  80586. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80587. private _preparePostProcesses;
  80588. /**
  80589. * Clone the mirror texture.
  80590. * @returns the cloned texture
  80591. */
  80592. clone(): MirrorTexture;
  80593. /**
  80594. * Serialize the texture to a JSON representation you could use in Parse later on
  80595. * @returns the serialized JSON representation
  80596. */
  80597. serialize(): any;
  80598. /**
  80599. * Dispose the texture and release its associated resources.
  80600. */
  80601. dispose(): void;
  80602. }
  80603. }
  80604. declare module BABYLON {
  80605. /**
  80606. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80607. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80608. */
  80609. export class Texture extends BaseTexture {
  80610. /** @hidden */
  80611. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80612. /** @hidden */
  80613. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80614. /** @hidden */
  80615. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80616. /** nearest is mag = nearest and min = nearest and mip = linear */
  80617. static readonly NEAREST_SAMPLINGMODE: number;
  80618. /** nearest is mag = nearest and min = nearest and mip = linear */
  80619. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80620. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80621. static readonly BILINEAR_SAMPLINGMODE: number;
  80622. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80623. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80624. /** Trilinear is mag = linear and min = linear and mip = linear */
  80625. static readonly TRILINEAR_SAMPLINGMODE: number;
  80626. /** Trilinear is mag = linear and min = linear and mip = linear */
  80627. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80628. /** mag = nearest and min = nearest and mip = nearest */
  80629. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80630. /** mag = nearest and min = linear and mip = nearest */
  80631. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80632. /** mag = nearest and min = linear and mip = linear */
  80633. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80634. /** mag = nearest and min = linear and mip = none */
  80635. static readonly NEAREST_LINEAR: number;
  80636. /** mag = nearest and min = nearest and mip = none */
  80637. static readonly NEAREST_NEAREST: number;
  80638. /** mag = linear and min = nearest and mip = nearest */
  80639. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80640. /** mag = linear and min = nearest and mip = linear */
  80641. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80642. /** mag = linear and min = linear and mip = none */
  80643. static readonly LINEAR_LINEAR: number;
  80644. /** mag = linear and min = nearest and mip = none */
  80645. static readonly LINEAR_NEAREST: number;
  80646. /** Explicit coordinates mode */
  80647. static readonly EXPLICIT_MODE: number;
  80648. /** Spherical coordinates mode */
  80649. static readonly SPHERICAL_MODE: number;
  80650. /** Planar coordinates mode */
  80651. static readonly PLANAR_MODE: number;
  80652. /** Cubic coordinates mode */
  80653. static readonly CUBIC_MODE: number;
  80654. /** Projection coordinates mode */
  80655. static readonly PROJECTION_MODE: number;
  80656. /** Inverse Cubic coordinates mode */
  80657. static readonly SKYBOX_MODE: number;
  80658. /** Inverse Cubic coordinates mode */
  80659. static readonly INVCUBIC_MODE: number;
  80660. /** Equirectangular coordinates mode */
  80661. static readonly EQUIRECTANGULAR_MODE: number;
  80662. /** Equirectangular Fixed coordinates mode */
  80663. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80664. /** Equirectangular Fixed Mirrored coordinates mode */
  80665. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80666. /** Texture is not repeating outside of 0..1 UVs */
  80667. static readonly CLAMP_ADDRESSMODE: number;
  80668. /** Texture is repeating outside of 0..1 UVs */
  80669. static readonly WRAP_ADDRESSMODE: number;
  80670. /** Texture is repeating and mirrored */
  80671. static readonly MIRROR_ADDRESSMODE: number;
  80672. /**
  80673. * 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
  80674. */
  80675. static UseSerializedUrlIfAny: boolean;
  80676. /**
  80677. * Define the url of the texture.
  80678. */
  80679. url: Nullable<string>;
  80680. /**
  80681. * Define an offset on the texture to offset the u coordinates of the UVs
  80682. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80683. */
  80684. uOffset: number;
  80685. /**
  80686. * Define an offset on the texture to offset the v coordinates of the UVs
  80687. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80688. */
  80689. vOffset: number;
  80690. /**
  80691. * Define an offset on the texture to scale the u coordinates of the UVs
  80692. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80693. */
  80694. uScale: number;
  80695. /**
  80696. * Define an offset on the texture to scale the v coordinates of the UVs
  80697. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80698. */
  80699. vScale: number;
  80700. /**
  80701. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80702. * @see http://doc.babylonjs.com/how_to/more_materials
  80703. */
  80704. uAng: number;
  80705. /**
  80706. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80707. * @see http://doc.babylonjs.com/how_to/more_materials
  80708. */
  80709. vAng: number;
  80710. /**
  80711. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80712. * @see http://doc.babylonjs.com/how_to/more_materials
  80713. */
  80714. wAng: number;
  80715. /**
  80716. * Defines the center of rotation (U)
  80717. */
  80718. uRotationCenter: number;
  80719. /**
  80720. * Defines the center of rotation (V)
  80721. */
  80722. vRotationCenter: number;
  80723. /**
  80724. * Defines the center of rotation (W)
  80725. */
  80726. wRotationCenter: number;
  80727. /**
  80728. * Are mip maps generated for this texture or not.
  80729. */
  80730. readonly noMipmap: boolean;
  80731. /**
  80732. * List of inspectable custom properties (used by the Inspector)
  80733. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80734. */
  80735. inspectableCustomProperties: Nullable<IInspectable[]>;
  80736. private _noMipmap;
  80737. /** @hidden */
  80738. _invertY: boolean;
  80739. private _rowGenerationMatrix;
  80740. private _cachedTextureMatrix;
  80741. private _projectionModeMatrix;
  80742. private _t0;
  80743. private _t1;
  80744. private _t2;
  80745. private _cachedUOffset;
  80746. private _cachedVOffset;
  80747. private _cachedUScale;
  80748. private _cachedVScale;
  80749. private _cachedUAng;
  80750. private _cachedVAng;
  80751. private _cachedWAng;
  80752. private _cachedProjectionMatrixId;
  80753. private _cachedCoordinatesMode;
  80754. /** @hidden */
  80755. protected _initialSamplingMode: number;
  80756. /** @hidden */
  80757. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80758. private _deleteBuffer;
  80759. protected _format: Nullable<number>;
  80760. private _delayedOnLoad;
  80761. private _delayedOnError;
  80762. /**
  80763. * Observable triggered once the texture has been loaded.
  80764. */
  80765. onLoadObservable: Observable<Texture>;
  80766. protected _isBlocking: boolean;
  80767. /**
  80768. * Is the texture preventing material to render while loading.
  80769. * If false, a default texture will be used instead of the loading one during the preparation step.
  80770. */
  80771. isBlocking: boolean;
  80772. /**
  80773. * Get the current sampling mode associated with the texture.
  80774. */
  80775. readonly samplingMode: number;
  80776. /**
  80777. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80778. */
  80779. readonly invertY: boolean;
  80780. /**
  80781. * Instantiates a new texture.
  80782. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80783. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80784. * @param url define the url of the picture to load as a texture
  80785. * @param scene define the scene or engine the texture will belong to
  80786. * @param noMipmap define if the texture will require mip maps or not
  80787. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80788. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80789. * @param onLoad define a callback triggered when the texture has been loaded
  80790. * @param onError define a callback triggered when an error occurred during the loading session
  80791. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80792. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80793. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80794. */
  80795. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80796. /**
  80797. * Update the url (and optional buffer) of this texture if url was null during construction.
  80798. * @param url the url of the texture
  80799. * @param buffer the buffer of the texture (defaults to null)
  80800. * @param onLoad callback called when the texture is loaded (defaults to null)
  80801. */
  80802. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80803. /**
  80804. * Finish the loading sequence of a texture flagged as delayed load.
  80805. * @hidden
  80806. */
  80807. delayLoad(): void;
  80808. private _prepareRowForTextureGeneration;
  80809. /**
  80810. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80811. * @returns the transform matrix of the texture.
  80812. */
  80813. getTextureMatrix(): Matrix;
  80814. /**
  80815. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80816. * @returns The reflection texture transform
  80817. */
  80818. getReflectionTextureMatrix(): Matrix;
  80819. /**
  80820. * Clones the texture.
  80821. * @returns the cloned texture
  80822. */
  80823. clone(): Texture;
  80824. /**
  80825. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80826. * @returns The JSON representation of the texture
  80827. */
  80828. serialize(): any;
  80829. /**
  80830. * Get the current class name of the texture useful for serialization or dynamic coding.
  80831. * @returns "Texture"
  80832. */
  80833. getClassName(): string;
  80834. /**
  80835. * Dispose the texture and release its associated resources.
  80836. */
  80837. dispose(): void;
  80838. /**
  80839. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80840. * @param parsedTexture Define the JSON representation of the texture
  80841. * @param scene Define the scene the parsed texture should be instantiated in
  80842. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80843. * @returns The parsed texture if successful
  80844. */
  80845. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80846. /**
  80847. * Creates a texture from its base 64 representation.
  80848. * @param data Define the base64 payload without the data: prefix
  80849. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80850. * @param scene Define the scene the texture should belong to
  80851. * @param noMipmap Forces the texture to not create mip map information if true
  80852. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80853. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80854. * @param onLoad define a callback triggered when the texture has been loaded
  80855. * @param onError define a callback triggered when an error occurred during the loading session
  80856. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80857. * @returns the created texture
  80858. */
  80859. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80860. /**
  80861. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80862. * @param data Define the base64 payload without the data: prefix
  80863. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80864. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80865. * @param scene Define the scene the texture should belong to
  80866. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80867. * @param noMipmap Forces the texture to not create mip map information if true
  80868. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80869. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80870. * @param onLoad define a callback triggered when the texture has been loaded
  80871. * @param onError define a callback triggered when an error occurred during the loading session
  80872. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80873. * @returns the created texture
  80874. */
  80875. 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;
  80876. }
  80877. }
  80878. declare module BABYLON {
  80879. /**
  80880. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80881. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80882. */
  80883. export class PostProcessManager {
  80884. private _scene;
  80885. private _indexBuffer;
  80886. private _vertexBuffers;
  80887. /**
  80888. * Creates a new instance PostProcess
  80889. * @param scene The scene that the post process is associated with.
  80890. */
  80891. constructor(scene: Scene);
  80892. private _prepareBuffers;
  80893. private _buildIndexBuffer;
  80894. /**
  80895. * Rebuilds the vertex buffers of the manager.
  80896. * @hidden
  80897. */
  80898. _rebuild(): void;
  80899. /**
  80900. * Prepares a frame to be run through a post process.
  80901. * @param sourceTexture The input texture to the post procesess. (default: null)
  80902. * @param postProcesses An array of post processes to be run. (default: null)
  80903. * @returns True if the post processes were able to be run.
  80904. * @hidden
  80905. */
  80906. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80907. /**
  80908. * Manually render a set of post processes to a texture.
  80909. * @param postProcesses An array of post processes to be run.
  80910. * @param targetTexture The target texture to render to.
  80911. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80912. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80913. * @param lodLevel defines which lod of the texture to render to
  80914. */
  80915. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80916. /**
  80917. * Finalize the result of the output of the postprocesses.
  80918. * @param doNotPresent If true the result will not be displayed to the screen.
  80919. * @param targetTexture The target texture to render to.
  80920. * @param faceIndex The index of the face to bind the target texture to.
  80921. * @param postProcesses The array of post processes to render.
  80922. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80923. * @hidden
  80924. */
  80925. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80926. /**
  80927. * Disposes of the post process manager.
  80928. */
  80929. dispose(): void;
  80930. }
  80931. }
  80932. declare module BABYLON {
  80933. /** Interface used by value gradients (color, factor, ...) */
  80934. export interface IValueGradient {
  80935. /**
  80936. * Gets or sets the gradient value (between 0 and 1)
  80937. */
  80938. gradient: number;
  80939. }
  80940. /** Class used to store color4 gradient */
  80941. export class ColorGradient implements IValueGradient {
  80942. /**
  80943. * Gets or sets the gradient value (between 0 and 1)
  80944. */
  80945. gradient: number;
  80946. /**
  80947. * Gets or sets first associated color
  80948. */
  80949. color1: Color4;
  80950. /**
  80951. * Gets or sets second associated color
  80952. */
  80953. color2?: Color4;
  80954. /**
  80955. * Will get a color picked randomly between color1 and color2.
  80956. * If color2 is undefined then color1 will be used
  80957. * @param result defines the target Color4 to store the result in
  80958. */
  80959. getColorToRef(result: Color4): void;
  80960. }
  80961. /** Class used to store color 3 gradient */
  80962. export class Color3Gradient implements IValueGradient {
  80963. /**
  80964. * Gets or sets the gradient value (between 0 and 1)
  80965. */
  80966. gradient: number;
  80967. /**
  80968. * Gets or sets the associated color
  80969. */
  80970. color: Color3;
  80971. }
  80972. /** Class used to store factor gradient */
  80973. export class FactorGradient implements IValueGradient {
  80974. /**
  80975. * Gets or sets the gradient value (between 0 and 1)
  80976. */
  80977. gradient: number;
  80978. /**
  80979. * Gets or sets first associated factor
  80980. */
  80981. factor1: number;
  80982. /**
  80983. * Gets or sets second associated factor
  80984. */
  80985. factor2?: number;
  80986. /**
  80987. * Will get a number picked randomly between factor1 and factor2.
  80988. * If factor2 is undefined then factor1 will be used
  80989. * @returns the picked number
  80990. */
  80991. getFactor(): number;
  80992. }
  80993. /**
  80994. * Helper used to simplify some generic gradient tasks
  80995. */
  80996. export class GradientHelper {
  80997. /**
  80998. * Gets the current gradient from an array of IValueGradient
  80999. * @param ratio defines the current ratio to get
  81000. * @param gradients defines the array of IValueGradient
  81001. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81002. */
  81003. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81004. }
  81005. }
  81006. declare module BABYLON {
  81007. interface AbstractScene {
  81008. /**
  81009. * The list of procedural textures added to the scene
  81010. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81011. */
  81012. proceduralTextures: Array<ProceduralTexture>;
  81013. }
  81014. /**
  81015. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81016. * in a given scene.
  81017. */
  81018. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81019. /**
  81020. * The component name helpfull to identify the component in the list of scene components.
  81021. */
  81022. readonly name: string;
  81023. /**
  81024. * The scene the component belongs to.
  81025. */
  81026. scene: Scene;
  81027. /**
  81028. * Creates a new instance of the component for the given scene
  81029. * @param scene Defines the scene to register the component in
  81030. */
  81031. constructor(scene: Scene);
  81032. /**
  81033. * Registers the component in a given scene
  81034. */
  81035. register(): void;
  81036. /**
  81037. * Rebuilds the elements related to this component in case of
  81038. * context lost for instance.
  81039. */
  81040. rebuild(): void;
  81041. /**
  81042. * Disposes the component and the associated ressources.
  81043. */
  81044. dispose(): void;
  81045. private _beforeClear;
  81046. }
  81047. }
  81048. declare module BABYLON {
  81049. interface Engine {
  81050. /**
  81051. * Creates a new render target cube texture
  81052. * @param size defines the size of the texture
  81053. * @param options defines the options used to create the texture
  81054. * @returns a new render target cube texture stored in an InternalTexture
  81055. */
  81056. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81057. }
  81058. }
  81059. declare module BABYLON {
  81060. /** @hidden */
  81061. export var proceduralVertexShader: {
  81062. name: string;
  81063. shader: string;
  81064. };
  81065. }
  81066. declare module BABYLON {
  81067. /**
  81068. * 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.
  81069. * This is the base class of any Procedural texture and contains most of the shareable code.
  81070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81071. */
  81072. export class ProceduralTexture extends Texture {
  81073. isCube: boolean;
  81074. /**
  81075. * Define if the texture is enabled or not (disabled texture will not render)
  81076. */
  81077. isEnabled: boolean;
  81078. /**
  81079. * Define if the texture must be cleared before rendering (default is true)
  81080. */
  81081. autoClear: boolean;
  81082. /**
  81083. * Callback called when the texture is generated
  81084. */
  81085. onGenerated: () => void;
  81086. /**
  81087. * Event raised when the texture is generated
  81088. */
  81089. onGeneratedObservable: Observable<ProceduralTexture>;
  81090. /** @hidden */
  81091. _generateMipMaps: boolean;
  81092. /** @hidden **/
  81093. _effect: Effect;
  81094. /** @hidden */
  81095. _textures: {
  81096. [key: string]: Texture;
  81097. };
  81098. private _size;
  81099. private _currentRefreshId;
  81100. private _refreshRate;
  81101. private _vertexBuffers;
  81102. private _indexBuffer;
  81103. private _uniforms;
  81104. private _samplers;
  81105. private _fragment;
  81106. private _floats;
  81107. private _ints;
  81108. private _floatsArrays;
  81109. private _colors3;
  81110. private _colors4;
  81111. private _vectors2;
  81112. private _vectors3;
  81113. private _matrices;
  81114. private _fallbackTexture;
  81115. private _fallbackTextureUsed;
  81116. private _engine;
  81117. private _cachedDefines;
  81118. private _contentUpdateId;
  81119. private _contentData;
  81120. /**
  81121. * Instantiates a new procedural texture.
  81122. * 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.
  81123. * This is the base class of any Procedural texture and contains most of the shareable code.
  81124. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81125. * @param name Define the name of the texture
  81126. * @param size Define the size of the texture to create
  81127. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81128. * @param scene Define the scene the texture belongs to
  81129. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81130. * @param generateMipMaps Define if the texture should creates mip maps or not
  81131. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81132. */
  81133. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81134. /**
  81135. * The effect that is created when initializing the post process.
  81136. * @returns The created effect corresponding the the postprocess.
  81137. */
  81138. getEffect(): Effect;
  81139. /**
  81140. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81141. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81142. */
  81143. getContent(): Nullable<ArrayBufferView>;
  81144. private _createIndexBuffer;
  81145. /** @hidden */
  81146. _rebuild(): void;
  81147. /**
  81148. * Resets the texture in order to recreate its associated resources.
  81149. * This can be called in case of context loss
  81150. */
  81151. reset(): void;
  81152. protected _getDefines(): string;
  81153. /**
  81154. * Is the texture ready to be used ? (rendered at least once)
  81155. * @returns true if ready, otherwise, false.
  81156. */
  81157. isReady(): boolean;
  81158. /**
  81159. * Resets the refresh counter of the texture and start bak from scratch.
  81160. * Could be useful to regenerate the texture if it is setup to render only once.
  81161. */
  81162. resetRefreshCounter(): void;
  81163. /**
  81164. * Set the fragment shader to use in order to render the texture.
  81165. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81166. */
  81167. setFragment(fragment: any): void;
  81168. /**
  81169. * Define the refresh rate of the texture or the rendering frequency.
  81170. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81171. */
  81172. refreshRate: number;
  81173. /** @hidden */
  81174. _shouldRender(): boolean;
  81175. /**
  81176. * Get the size the texture is rendering at.
  81177. * @returns the size (texture is always squared)
  81178. */
  81179. getRenderSize(): number;
  81180. /**
  81181. * Resize the texture to new value.
  81182. * @param size Define the new size the texture should have
  81183. * @param generateMipMaps Define whether the new texture should create mip maps
  81184. */
  81185. resize(size: number, generateMipMaps: boolean): void;
  81186. private _checkUniform;
  81187. /**
  81188. * Set a texture in the shader program used to render.
  81189. * @param name Define the name of the uniform samplers as defined in the shader
  81190. * @param texture Define the texture to bind to this sampler
  81191. * @return the texture itself allowing "fluent" like uniform updates
  81192. */
  81193. setTexture(name: string, texture: Texture): ProceduralTexture;
  81194. /**
  81195. * Set a float in the shader.
  81196. * @param name Define the name of the uniform as defined in the shader
  81197. * @param value Define the value to give to the uniform
  81198. * @return the texture itself allowing "fluent" like uniform updates
  81199. */
  81200. setFloat(name: string, value: number): ProceduralTexture;
  81201. /**
  81202. * Set a int in the shader.
  81203. * @param name Define the name of the uniform as defined in the shader
  81204. * @param value Define the value to give to the uniform
  81205. * @return the texture itself allowing "fluent" like uniform updates
  81206. */
  81207. setInt(name: string, value: number): ProceduralTexture;
  81208. /**
  81209. * Set an array of floats in the shader.
  81210. * @param name Define the name of the uniform as defined in the shader
  81211. * @param value Define the value to give to the uniform
  81212. * @return the texture itself allowing "fluent" like uniform updates
  81213. */
  81214. setFloats(name: string, value: number[]): ProceduralTexture;
  81215. /**
  81216. * Set a vec3 in the shader from a Color3.
  81217. * @param name Define the name of the uniform as defined in the shader
  81218. * @param value Define the value to give to the uniform
  81219. * @return the texture itself allowing "fluent" like uniform updates
  81220. */
  81221. setColor3(name: string, value: Color3): ProceduralTexture;
  81222. /**
  81223. * Set a vec4 in the shader from a Color4.
  81224. * @param name Define the name of the uniform as defined in the shader
  81225. * @param value Define the value to give to the uniform
  81226. * @return the texture itself allowing "fluent" like uniform updates
  81227. */
  81228. setColor4(name: string, value: Color4): ProceduralTexture;
  81229. /**
  81230. * Set a vec2 in the shader from a Vector2.
  81231. * @param name Define the name of the uniform as defined in the shader
  81232. * @param value Define the value to give to the uniform
  81233. * @return the texture itself allowing "fluent" like uniform updates
  81234. */
  81235. setVector2(name: string, value: Vector2): ProceduralTexture;
  81236. /**
  81237. * Set a vec3 in the shader from a Vector3.
  81238. * @param name Define the name of the uniform as defined in the shader
  81239. * @param value Define the value to give to the uniform
  81240. * @return the texture itself allowing "fluent" like uniform updates
  81241. */
  81242. setVector3(name: string, value: Vector3): ProceduralTexture;
  81243. /**
  81244. * Set a mat4 in the shader from a MAtrix.
  81245. * @param name Define the name of the uniform as defined in the shader
  81246. * @param value Define the value to give to the uniform
  81247. * @return the texture itself allowing "fluent" like uniform updates
  81248. */
  81249. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81250. /**
  81251. * Render the texture to its associated render target.
  81252. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81253. */
  81254. render(useCameraPostProcess?: boolean): void;
  81255. /**
  81256. * Clone the texture.
  81257. * @returns the cloned texture
  81258. */
  81259. clone(): ProceduralTexture;
  81260. /**
  81261. * Dispose the texture and release its asoociated resources.
  81262. */
  81263. dispose(): void;
  81264. }
  81265. }
  81266. declare module BABYLON {
  81267. /**
  81268. * This represents the base class for particle system in Babylon.
  81269. * 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.
  81270. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81271. * @example https://doc.babylonjs.com/babylon101/particles
  81272. */
  81273. export class BaseParticleSystem {
  81274. /**
  81275. * Source color is added to the destination color without alpha affecting the result
  81276. */
  81277. static BLENDMODE_ONEONE: number;
  81278. /**
  81279. * Blend current color and particle color using particle’s alpha
  81280. */
  81281. static BLENDMODE_STANDARD: number;
  81282. /**
  81283. * Add current color and particle color multiplied by particle’s alpha
  81284. */
  81285. static BLENDMODE_ADD: number;
  81286. /**
  81287. * Multiply current color with particle color
  81288. */
  81289. static BLENDMODE_MULTIPLY: number;
  81290. /**
  81291. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81292. */
  81293. static BLENDMODE_MULTIPLYADD: number;
  81294. /**
  81295. * List of animations used by the particle system.
  81296. */
  81297. animations: Animation[];
  81298. /**
  81299. * The id of the Particle system.
  81300. */
  81301. id: string;
  81302. /**
  81303. * The friendly name of the Particle system.
  81304. */
  81305. name: string;
  81306. /**
  81307. * The rendering group used by the Particle system to chose when to render.
  81308. */
  81309. renderingGroupId: number;
  81310. /**
  81311. * The emitter represents the Mesh or position we are attaching the particle system to.
  81312. */
  81313. emitter: Nullable<AbstractMesh | Vector3>;
  81314. /**
  81315. * The maximum number of particles to emit per frame
  81316. */
  81317. emitRate: number;
  81318. /**
  81319. * If you want to launch only a few particles at once, that can be done, as well.
  81320. */
  81321. manualEmitCount: number;
  81322. /**
  81323. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81324. */
  81325. updateSpeed: number;
  81326. /**
  81327. * The amount of time the particle system is running (depends of the overall update speed).
  81328. */
  81329. targetStopDuration: number;
  81330. /**
  81331. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81332. */
  81333. disposeOnStop: boolean;
  81334. /**
  81335. * Minimum power of emitting particles.
  81336. */
  81337. minEmitPower: number;
  81338. /**
  81339. * Maximum power of emitting particles.
  81340. */
  81341. maxEmitPower: number;
  81342. /**
  81343. * Minimum life time of emitting particles.
  81344. */
  81345. minLifeTime: number;
  81346. /**
  81347. * Maximum life time of emitting particles.
  81348. */
  81349. maxLifeTime: number;
  81350. /**
  81351. * Minimum Size of emitting particles.
  81352. */
  81353. minSize: number;
  81354. /**
  81355. * Maximum Size of emitting particles.
  81356. */
  81357. maxSize: number;
  81358. /**
  81359. * Minimum scale of emitting particles on X axis.
  81360. */
  81361. minScaleX: number;
  81362. /**
  81363. * Maximum scale of emitting particles on X axis.
  81364. */
  81365. maxScaleX: number;
  81366. /**
  81367. * Minimum scale of emitting particles on Y axis.
  81368. */
  81369. minScaleY: number;
  81370. /**
  81371. * Maximum scale of emitting particles on Y axis.
  81372. */
  81373. maxScaleY: number;
  81374. /**
  81375. * Gets or sets the minimal initial rotation in radians.
  81376. */
  81377. minInitialRotation: number;
  81378. /**
  81379. * Gets or sets the maximal initial rotation in radians.
  81380. */
  81381. maxInitialRotation: number;
  81382. /**
  81383. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81384. */
  81385. minAngularSpeed: number;
  81386. /**
  81387. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81388. */
  81389. maxAngularSpeed: number;
  81390. /**
  81391. * The texture used to render each particle. (this can be a spritesheet)
  81392. */
  81393. particleTexture: Nullable<Texture>;
  81394. /**
  81395. * The layer mask we are rendering the particles through.
  81396. */
  81397. layerMask: number;
  81398. /**
  81399. * This can help using your own shader to render the particle system.
  81400. * The according effect will be created
  81401. */
  81402. customShader: any;
  81403. /**
  81404. * By default particle system starts as soon as they are created. This prevents the
  81405. * automatic start to happen and let you decide when to start emitting particles.
  81406. */
  81407. preventAutoStart: boolean;
  81408. private _noiseTexture;
  81409. /**
  81410. * Gets or sets a texture used to add random noise to particle positions
  81411. */
  81412. noiseTexture: Nullable<ProceduralTexture>;
  81413. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81414. noiseStrength: Vector3;
  81415. /**
  81416. * Callback triggered when the particle animation is ending.
  81417. */
  81418. onAnimationEnd: Nullable<() => void>;
  81419. /**
  81420. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81421. */
  81422. blendMode: number;
  81423. /**
  81424. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81425. * to override the particles.
  81426. */
  81427. forceDepthWrite: boolean;
  81428. /** 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 */
  81429. preWarmCycles: number;
  81430. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81431. preWarmStepOffset: number;
  81432. /**
  81433. * 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)
  81434. */
  81435. spriteCellChangeSpeed: number;
  81436. /**
  81437. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81438. */
  81439. startSpriteCellID: number;
  81440. /**
  81441. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81442. */
  81443. endSpriteCellID: number;
  81444. /**
  81445. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81446. */
  81447. spriteCellWidth: number;
  81448. /**
  81449. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81450. */
  81451. spriteCellHeight: number;
  81452. /**
  81453. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81454. */
  81455. spriteRandomStartCell: boolean;
  81456. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81457. translationPivot: Vector2;
  81458. /** @hidden */
  81459. protected _isAnimationSheetEnabled: boolean;
  81460. /**
  81461. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81462. */
  81463. beginAnimationOnStart: boolean;
  81464. /**
  81465. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81466. */
  81467. beginAnimationFrom: number;
  81468. /**
  81469. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81470. */
  81471. beginAnimationTo: number;
  81472. /**
  81473. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81474. */
  81475. beginAnimationLoop: boolean;
  81476. /**
  81477. * Gets or sets a world offset applied to all particles
  81478. */
  81479. worldOffset: Vector3;
  81480. /**
  81481. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81482. */
  81483. isAnimationSheetEnabled: boolean;
  81484. /**
  81485. * Get hosting scene
  81486. * @returns the scene
  81487. */
  81488. getScene(): Scene;
  81489. /**
  81490. * You can use gravity if you want to give an orientation to your particles.
  81491. */
  81492. gravity: Vector3;
  81493. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81494. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81495. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81496. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81497. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81498. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81499. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81500. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81501. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81502. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81503. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81504. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81505. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81506. /**
  81507. * Defines the delay in milliseconds before starting the system (0 by default)
  81508. */
  81509. startDelay: number;
  81510. /**
  81511. * Gets the current list of drag gradients.
  81512. * You must use addDragGradient and removeDragGradient to udpate this list
  81513. * @returns the list of drag gradients
  81514. */
  81515. getDragGradients(): Nullable<Array<FactorGradient>>;
  81516. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81517. limitVelocityDamping: number;
  81518. /**
  81519. * Gets the current list of limit velocity gradients.
  81520. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81521. * @returns the list of limit velocity gradients
  81522. */
  81523. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81524. /**
  81525. * Gets the current list of color gradients.
  81526. * You must use addColorGradient and removeColorGradient to udpate this list
  81527. * @returns the list of color gradients
  81528. */
  81529. getColorGradients(): Nullable<Array<ColorGradient>>;
  81530. /**
  81531. * Gets the current list of size gradients.
  81532. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81533. * @returns the list of size gradients
  81534. */
  81535. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81536. /**
  81537. * Gets the current list of color remap gradients.
  81538. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81539. * @returns the list of color remap gradients
  81540. */
  81541. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81542. /**
  81543. * Gets the current list of alpha remap gradients.
  81544. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81545. * @returns the list of alpha remap gradients
  81546. */
  81547. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81548. /**
  81549. * Gets the current list of life time gradients.
  81550. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81551. * @returns the list of life time gradients
  81552. */
  81553. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81554. /**
  81555. * Gets the current list of angular speed gradients.
  81556. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81557. * @returns the list of angular speed gradients
  81558. */
  81559. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81560. /**
  81561. * Gets the current list of velocity gradients.
  81562. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81563. * @returns the list of velocity gradients
  81564. */
  81565. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81566. /**
  81567. * Gets the current list of start size gradients.
  81568. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81569. * @returns the list of start size gradients
  81570. */
  81571. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81572. /**
  81573. * Gets the current list of emit rate gradients.
  81574. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81575. * @returns the list of emit rate gradients
  81576. */
  81577. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81578. /**
  81579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81581. */
  81582. direction1: Vector3;
  81583. /**
  81584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81586. */
  81587. direction2: Vector3;
  81588. /**
  81589. * 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.
  81590. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81591. */
  81592. minEmitBox: Vector3;
  81593. /**
  81594. * 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.
  81595. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81596. */
  81597. maxEmitBox: Vector3;
  81598. /**
  81599. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81600. */
  81601. color1: Color4;
  81602. /**
  81603. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81604. */
  81605. color2: Color4;
  81606. /**
  81607. * Color the particle will have at the end of its lifetime
  81608. */
  81609. colorDead: Color4;
  81610. /**
  81611. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81612. */
  81613. textureMask: Color4;
  81614. /**
  81615. * The particle emitter type defines the emitter used by the particle system.
  81616. * It can be for example box, sphere, or cone...
  81617. */
  81618. particleEmitterType: IParticleEmitterType;
  81619. /** @hidden */
  81620. _isSubEmitter: boolean;
  81621. /**
  81622. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81623. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81624. */
  81625. billboardMode: number;
  81626. protected _isBillboardBased: boolean;
  81627. /**
  81628. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81629. */
  81630. isBillboardBased: boolean;
  81631. /**
  81632. * The scene the particle system belongs to.
  81633. */
  81634. protected _scene: Scene;
  81635. /**
  81636. * Local cache of defines for image processing.
  81637. */
  81638. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81639. /**
  81640. * Default configuration related to image processing available in the standard Material.
  81641. */
  81642. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81643. /**
  81644. * Gets the image processing configuration used either in this material.
  81645. */
  81646. /**
  81647. * Sets the Default image processing configuration used either in the this material.
  81648. *
  81649. * If sets to null, the scene one is in use.
  81650. */
  81651. imageProcessingConfiguration: ImageProcessingConfiguration;
  81652. /**
  81653. * Attaches a new image processing configuration to the Standard Material.
  81654. * @param configuration
  81655. */
  81656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81657. /** @hidden */
  81658. protected _reset(): void;
  81659. /** @hidden */
  81660. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81661. /**
  81662. * Instantiates a particle system.
  81663. * 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.
  81664. * @param name The name of the particle system
  81665. */
  81666. constructor(name: string);
  81667. /**
  81668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81671. * @returns the emitter
  81672. */
  81673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81674. /**
  81675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81676. * @param radius The radius of the hemisphere to emit from
  81677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81678. * @returns the emitter
  81679. */
  81680. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81681. /**
  81682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81683. * @param radius The radius of the sphere to emit from
  81684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81685. * @returns the emitter
  81686. */
  81687. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81688. /**
  81689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81690. * @param radius The radius of the sphere to emit from
  81691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81693. * @returns the emitter
  81694. */
  81695. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81696. /**
  81697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81698. * @param radius The radius of the emission cylinder
  81699. * @param height The height of the emission cylinder
  81700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81702. * @returns the emitter
  81703. */
  81704. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81705. /**
  81706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81707. * @param radius The radius of the cylinder to emit from
  81708. * @param height The height of the emission cylinder
  81709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81712. * @returns the emitter
  81713. */
  81714. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81715. /**
  81716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81717. * @param radius The radius of the cone to emit from
  81718. * @param angle The base angle of the cone
  81719. * @returns the emitter
  81720. */
  81721. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81722. /**
  81723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81728. * @returns the emitter
  81729. */
  81730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81731. }
  81732. }
  81733. declare module BABYLON {
  81734. /**
  81735. * Type of sub emitter
  81736. */
  81737. export enum SubEmitterType {
  81738. /**
  81739. * Attached to the particle over it's lifetime
  81740. */
  81741. ATTACHED = 0,
  81742. /**
  81743. * Created when the particle dies
  81744. */
  81745. END = 1
  81746. }
  81747. /**
  81748. * Sub emitter class used to emit particles from an existing particle
  81749. */
  81750. export class SubEmitter {
  81751. /**
  81752. * the particle system to be used by the sub emitter
  81753. */
  81754. particleSystem: ParticleSystem;
  81755. /**
  81756. * Type of the submitter (Default: END)
  81757. */
  81758. type: SubEmitterType;
  81759. /**
  81760. * 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)
  81761. * Note: This only is supported when using an emitter of type Mesh
  81762. */
  81763. inheritDirection: boolean;
  81764. /**
  81765. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81766. */
  81767. inheritedVelocityAmount: number;
  81768. /**
  81769. * Creates a sub emitter
  81770. * @param particleSystem the particle system to be used by the sub emitter
  81771. */
  81772. constructor(
  81773. /**
  81774. * the particle system to be used by the sub emitter
  81775. */
  81776. particleSystem: ParticleSystem);
  81777. /**
  81778. * Clones the sub emitter
  81779. * @returns the cloned sub emitter
  81780. */
  81781. clone(): SubEmitter;
  81782. /**
  81783. * Serialize current object to a JSON object
  81784. * @returns the serialized object
  81785. */
  81786. serialize(): any;
  81787. /** @hidden */
  81788. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81789. /**
  81790. * Creates a new SubEmitter from a serialized JSON version
  81791. * @param serializationObject defines the JSON object to read from
  81792. * @param scene defines the hosting scene
  81793. * @param rootUrl defines the rootUrl for data loading
  81794. * @returns a new SubEmitter
  81795. */
  81796. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81797. /** Release associated resources */
  81798. dispose(): void;
  81799. }
  81800. }
  81801. declare module BABYLON {
  81802. /** @hidden */
  81803. export var clipPlaneFragmentDeclaration: {
  81804. name: string;
  81805. shader: string;
  81806. };
  81807. }
  81808. declare module BABYLON {
  81809. /** @hidden */
  81810. export var imageProcessingDeclaration: {
  81811. name: string;
  81812. shader: string;
  81813. };
  81814. }
  81815. declare module BABYLON {
  81816. /** @hidden */
  81817. export var imageProcessingFunctions: {
  81818. name: string;
  81819. shader: string;
  81820. };
  81821. }
  81822. declare module BABYLON {
  81823. /** @hidden */
  81824. export var clipPlaneFragment: {
  81825. name: string;
  81826. shader: string;
  81827. };
  81828. }
  81829. declare module BABYLON {
  81830. /** @hidden */
  81831. export var particlesPixelShader: {
  81832. name: string;
  81833. shader: string;
  81834. };
  81835. }
  81836. declare module BABYLON {
  81837. /** @hidden */
  81838. export var clipPlaneVertexDeclaration: {
  81839. name: string;
  81840. shader: string;
  81841. };
  81842. }
  81843. declare module BABYLON {
  81844. /** @hidden */
  81845. export var clipPlaneVertex: {
  81846. name: string;
  81847. shader: string;
  81848. };
  81849. }
  81850. declare module BABYLON {
  81851. /** @hidden */
  81852. export var particlesVertexShader: {
  81853. name: string;
  81854. shader: string;
  81855. };
  81856. }
  81857. declare module BABYLON {
  81858. /**
  81859. * This represents a particle system in Babylon.
  81860. * 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.
  81861. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81862. * @example https://doc.babylonjs.com/babylon101/particles
  81863. */
  81864. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81865. /**
  81866. * Billboard mode will only apply to Y axis
  81867. */
  81868. static readonly BILLBOARDMODE_Y: number;
  81869. /**
  81870. * Billboard mode will apply to all axes
  81871. */
  81872. static readonly BILLBOARDMODE_ALL: number;
  81873. /**
  81874. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81875. */
  81876. static readonly BILLBOARDMODE_STRETCHED: number;
  81877. /**
  81878. * This function can be defined to provide custom update for active particles.
  81879. * This function will be called instead of regular update (age, position, color, etc.).
  81880. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81881. */
  81882. updateFunction: (particles: Particle[]) => void;
  81883. private _emitterWorldMatrix;
  81884. /**
  81885. * This function can be defined to specify initial direction for every new particle.
  81886. * It by default use the emitterType defined function
  81887. */
  81888. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81889. /**
  81890. * This function can be defined to specify initial position for every new particle.
  81891. * It by default use the emitterType defined function
  81892. */
  81893. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81894. /**
  81895. * @hidden
  81896. */
  81897. _inheritedVelocityOffset: Vector3;
  81898. /**
  81899. * An event triggered when the system is disposed
  81900. */
  81901. onDisposeObservable: Observable<ParticleSystem>;
  81902. private _onDisposeObserver;
  81903. /**
  81904. * Sets a callback that will be triggered when the system is disposed
  81905. */
  81906. onDispose: () => void;
  81907. private _particles;
  81908. private _epsilon;
  81909. private _capacity;
  81910. private _stockParticles;
  81911. private _newPartsExcess;
  81912. private _vertexData;
  81913. private _vertexBuffer;
  81914. private _vertexBuffers;
  81915. private _spriteBuffer;
  81916. private _indexBuffer;
  81917. private _effect;
  81918. private _customEffect;
  81919. private _cachedDefines;
  81920. private _scaledColorStep;
  81921. private _colorDiff;
  81922. private _scaledDirection;
  81923. private _scaledGravity;
  81924. private _currentRenderId;
  81925. private _alive;
  81926. private _useInstancing;
  81927. private _started;
  81928. private _stopped;
  81929. private _actualFrame;
  81930. private _scaledUpdateSpeed;
  81931. private _vertexBufferSize;
  81932. /** @hidden */
  81933. _currentEmitRateGradient: Nullable<FactorGradient>;
  81934. /** @hidden */
  81935. _currentEmitRate1: number;
  81936. /** @hidden */
  81937. _currentEmitRate2: number;
  81938. /** @hidden */
  81939. _currentStartSizeGradient: Nullable<FactorGradient>;
  81940. /** @hidden */
  81941. _currentStartSize1: number;
  81942. /** @hidden */
  81943. _currentStartSize2: number;
  81944. private readonly _rawTextureWidth;
  81945. private _rampGradientsTexture;
  81946. private _useRampGradients;
  81947. /** Gets or sets a boolean indicating that ramp gradients must be used
  81948. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81949. */
  81950. useRampGradients: boolean;
  81951. /**
  81952. * 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.
  81953. * 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: [])
  81954. */
  81955. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81956. private _subEmitters;
  81957. /**
  81958. * @hidden
  81959. * If the particle systems emitter should be disposed when the particle system is disposed
  81960. */
  81961. _disposeEmitterOnDispose: boolean;
  81962. /**
  81963. * The current active Sub-systems, this property is used by the root particle system only.
  81964. */
  81965. activeSubSystems: Array<ParticleSystem>;
  81966. private _rootParticleSystem;
  81967. /**
  81968. * Gets the current list of active particles
  81969. */
  81970. readonly particles: Particle[];
  81971. /**
  81972. * Returns the string "ParticleSystem"
  81973. * @returns a string containing the class name
  81974. */
  81975. getClassName(): string;
  81976. /**
  81977. * Instantiates a particle system.
  81978. * 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.
  81979. * @param name The name of the particle system
  81980. * @param capacity The max number of particles alive at the same time
  81981. * @param scene The scene the particle system belongs to
  81982. * @param customEffect a custom effect used to change the way particles are rendered by default
  81983. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81984. * @param epsilon Offset used to render the particles
  81985. */
  81986. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81987. private _addFactorGradient;
  81988. private _removeFactorGradient;
  81989. /**
  81990. * Adds a new life time gradient
  81991. * @param gradient defines the gradient to use (between 0 and 1)
  81992. * @param factor defines the life time factor to affect to the specified gradient
  81993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81994. * @returns the current particle system
  81995. */
  81996. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81997. /**
  81998. * Remove a specific life time gradient
  81999. * @param gradient defines the gradient to remove
  82000. * @returns the current particle system
  82001. */
  82002. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82003. /**
  82004. * Adds a new size gradient
  82005. * @param gradient defines the gradient to use (between 0 and 1)
  82006. * @param factor defines the size factor to affect to the specified gradient
  82007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82008. * @returns the current particle system
  82009. */
  82010. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82011. /**
  82012. * Remove a specific size gradient
  82013. * @param gradient defines the gradient to remove
  82014. * @returns the current particle system
  82015. */
  82016. removeSizeGradient(gradient: number): IParticleSystem;
  82017. /**
  82018. * Adds a new color remap gradient
  82019. * @param gradient defines the gradient to use (between 0 and 1)
  82020. * @param min defines the color remap minimal range
  82021. * @param max defines the color remap maximal range
  82022. * @returns the current particle system
  82023. */
  82024. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82025. /**
  82026. * Remove a specific color remap gradient
  82027. * @param gradient defines the gradient to remove
  82028. * @returns the current particle system
  82029. */
  82030. removeColorRemapGradient(gradient: number): IParticleSystem;
  82031. /**
  82032. * Adds a new alpha remap gradient
  82033. * @param gradient defines the gradient to use (between 0 and 1)
  82034. * @param min defines the alpha remap minimal range
  82035. * @param max defines the alpha remap maximal range
  82036. * @returns the current particle system
  82037. */
  82038. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82039. /**
  82040. * Remove a specific alpha remap gradient
  82041. * @param gradient defines the gradient to remove
  82042. * @returns the current particle system
  82043. */
  82044. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82045. /**
  82046. * Adds a new angular speed gradient
  82047. * @param gradient defines the gradient to use (between 0 and 1)
  82048. * @param factor defines the angular speed to affect to the specified gradient
  82049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82050. * @returns the current particle system
  82051. */
  82052. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82053. /**
  82054. * Remove a specific angular speed gradient
  82055. * @param gradient defines the gradient to remove
  82056. * @returns the current particle system
  82057. */
  82058. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82059. /**
  82060. * Adds a new velocity gradient
  82061. * @param gradient defines the gradient to use (between 0 and 1)
  82062. * @param factor defines the velocity to affect to the specified gradient
  82063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82064. * @returns the current particle system
  82065. */
  82066. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82067. /**
  82068. * Remove a specific velocity gradient
  82069. * @param gradient defines the gradient to remove
  82070. * @returns the current particle system
  82071. */
  82072. removeVelocityGradient(gradient: number): IParticleSystem;
  82073. /**
  82074. * Adds a new limit velocity gradient
  82075. * @param gradient defines the gradient to use (between 0 and 1)
  82076. * @param factor defines the limit velocity value to affect to the specified gradient
  82077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82078. * @returns the current particle system
  82079. */
  82080. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82081. /**
  82082. * Remove a specific limit velocity gradient
  82083. * @param gradient defines the gradient to remove
  82084. * @returns the current particle system
  82085. */
  82086. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82087. /**
  82088. * Adds a new drag gradient
  82089. * @param gradient defines the gradient to use (between 0 and 1)
  82090. * @param factor defines the drag value to affect to the specified gradient
  82091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82092. * @returns the current particle system
  82093. */
  82094. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82095. /**
  82096. * Remove a specific drag gradient
  82097. * @param gradient defines the gradient to remove
  82098. * @returns the current particle system
  82099. */
  82100. removeDragGradient(gradient: number): IParticleSystem;
  82101. /**
  82102. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82103. * @param gradient defines the gradient to use (between 0 and 1)
  82104. * @param factor defines the emit rate value to affect to the specified gradient
  82105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82106. * @returns the current particle system
  82107. */
  82108. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82109. /**
  82110. * Remove a specific emit rate gradient
  82111. * @param gradient defines the gradient to remove
  82112. * @returns the current particle system
  82113. */
  82114. removeEmitRateGradient(gradient: number): IParticleSystem;
  82115. /**
  82116. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82117. * @param gradient defines the gradient to use (between 0 and 1)
  82118. * @param factor defines the start size value to affect to the specified gradient
  82119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82120. * @returns the current particle system
  82121. */
  82122. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82123. /**
  82124. * Remove a specific start size gradient
  82125. * @param gradient defines the gradient to remove
  82126. * @returns the current particle system
  82127. */
  82128. removeStartSizeGradient(gradient: number): IParticleSystem;
  82129. private _createRampGradientTexture;
  82130. /**
  82131. * Gets the current list of ramp gradients.
  82132. * You must use addRampGradient and removeRampGradient to udpate this list
  82133. * @returns the list of ramp gradients
  82134. */
  82135. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82136. /**
  82137. * Adds a new ramp gradient used to remap particle colors
  82138. * @param gradient defines the gradient to use (between 0 and 1)
  82139. * @param color defines the color to affect to the specified gradient
  82140. * @returns the current particle system
  82141. */
  82142. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82143. /**
  82144. * Remove a specific ramp gradient
  82145. * @param gradient defines the gradient to remove
  82146. * @returns the current particle system
  82147. */
  82148. removeRampGradient(gradient: number): ParticleSystem;
  82149. /**
  82150. * Adds a new color gradient
  82151. * @param gradient defines the gradient to use (between 0 and 1)
  82152. * @param color1 defines the color to affect to the specified gradient
  82153. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82154. * @returns this particle system
  82155. */
  82156. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82157. /**
  82158. * Remove a specific color gradient
  82159. * @param gradient defines the gradient to remove
  82160. * @returns this particle system
  82161. */
  82162. removeColorGradient(gradient: number): IParticleSystem;
  82163. private _fetchR;
  82164. protected _reset(): void;
  82165. private _resetEffect;
  82166. private _createVertexBuffers;
  82167. private _createIndexBuffer;
  82168. /**
  82169. * Gets the maximum number of particles active at the same time.
  82170. * @returns The max number of active particles.
  82171. */
  82172. getCapacity(): number;
  82173. /**
  82174. * Gets whether there are still active particles in the system.
  82175. * @returns True if it is alive, otherwise false.
  82176. */
  82177. isAlive(): boolean;
  82178. /**
  82179. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82180. * @returns True if it has been started, otherwise false.
  82181. */
  82182. isStarted(): boolean;
  82183. private _prepareSubEmitterInternalArray;
  82184. /**
  82185. * Starts the particle system and begins to emit
  82186. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82187. */
  82188. start(delay?: number): void;
  82189. /**
  82190. * Stops the particle system.
  82191. * @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.
  82192. */
  82193. stop(stopSubEmitters?: boolean): void;
  82194. /**
  82195. * Remove all active particles
  82196. */
  82197. reset(): void;
  82198. /**
  82199. * @hidden (for internal use only)
  82200. */
  82201. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82202. /**
  82203. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82204. * Its lifetime will start back at 0.
  82205. */
  82206. recycleParticle: (particle: Particle) => void;
  82207. private _stopSubEmitters;
  82208. private _createParticle;
  82209. private _removeFromRoot;
  82210. private _emitFromParticle;
  82211. private _update;
  82212. /** @hidden */
  82213. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82214. /** @hidden */
  82215. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82216. /** @hidden */
  82217. private _getEffect;
  82218. /**
  82219. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82220. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82221. */
  82222. animate(preWarmOnly?: boolean): void;
  82223. private _appendParticleVertices;
  82224. /**
  82225. * Rebuilds the particle system.
  82226. */
  82227. rebuild(): void;
  82228. /**
  82229. * Is this system ready to be used/rendered
  82230. * @return true if the system is ready
  82231. */
  82232. isReady(): boolean;
  82233. private _render;
  82234. /**
  82235. * Renders the particle system in its current state.
  82236. * @returns the current number of particles
  82237. */
  82238. render(): number;
  82239. /**
  82240. * Disposes the particle system and free the associated resources
  82241. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82242. */
  82243. dispose(disposeTexture?: boolean): void;
  82244. /**
  82245. * Clones the particle system.
  82246. * @param name The name of the cloned object
  82247. * @param newEmitter The new emitter to use
  82248. * @returns the cloned particle system
  82249. */
  82250. clone(name: string, newEmitter: any): ParticleSystem;
  82251. /**
  82252. * Serializes the particle system to a JSON object.
  82253. * @returns the JSON object
  82254. */
  82255. serialize(): any;
  82256. /** @hidden */
  82257. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82258. /** @hidden */
  82259. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82260. /**
  82261. * Parses a JSON object to create a particle system.
  82262. * @param parsedParticleSystem The JSON object to parse
  82263. * @param scene The scene to create the particle system in
  82264. * @param rootUrl The root url to use to load external dependencies like texture
  82265. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82266. * @returns the Parsed particle system
  82267. */
  82268. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82269. }
  82270. }
  82271. declare module BABYLON {
  82272. /**
  82273. * A particle represents one of the element emitted by a particle system.
  82274. * This is mainly define by its coordinates, direction, velocity and age.
  82275. */
  82276. export class Particle {
  82277. /**
  82278. * The particle system the particle belongs to.
  82279. */
  82280. particleSystem: ParticleSystem;
  82281. private static _Count;
  82282. /**
  82283. * Unique ID of the particle
  82284. */
  82285. id: number;
  82286. /**
  82287. * The world position of the particle in the scene.
  82288. */
  82289. position: Vector3;
  82290. /**
  82291. * The world direction of the particle in the scene.
  82292. */
  82293. direction: Vector3;
  82294. /**
  82295. * The color of the particle.
  82296. */
  82297. color: Color4;
  82298. /**
  82299. * The color change of the particle per step.
  82300. */
  82301. colorStep: Color4;
  82302. /**
  82303. * Defines how long will the life of the particle be.
  82304. */
  82305. lifeTime: number;
  82306. /**
  82307. * The current age of the particle.
  82308. */
  82309. age: number;
  82310. /**
  82311. * The current size of the particle.
  82312. */
  82313. size: number;
  82314. /**
  82315. * The current scale of the particle.
  82316. */
  82317. scale: Vector2;
  82318. /**
  82319. * The current angle of the particle.
  82320. */
  82321. angle: number;
  82322. /**
  82323. * Defines how fast is the angle changing.
  82324. */
  82325. angularSpeed: number;
  82326. /**
  82327. * Defines the cell index used by the particle to be rendered from a sprite.
  82328. */
  82329. cellIndex: number;
  82330. /**
  82331. * The information required to support color remapping
  82332. */
  82333. remapData: Vector4;
  82334. /** @hidden */
  82335. _randomCellOffset?: number;
  82336. /** @hidden */
  82337. _initialDirection: Nullable<Vector3>;
  82338. /** @hidden */
  82339. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82340. /** @hidden */
  82341. _initialStartSpriteCellID: number;
  82342. /** @hidden */
  82343. _initialEndSpriteCellID: number;
  82344. /** @hidden */
  82345. _currentColorGradient: Nullable<ColorGradient>;
  82346. /** @hidden */
  82347. _currentColor1: Color4;
  82348. /** @hidden */
  82349. _currentColor2: Color4;
  82350. /** @hidden */
  82351. _currentSizeGradient: Nullable<FactorGradient>;
  82352. /** @hidden */
  82353. _currentSize1: number;
  82354. /** @hidden */
  82355. _currentSize2: number;
  82356. /** @hidden */
  82357. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82358. /** @hidden */
  82359. _currentAngularSpeed1: number;
  82360. /** @hidden */
  82361. _currentAngularSpeed2: number;
  82362. /** @hidden */
  82363. _currentVelocityGradient: Nullable<FactorGradient>;
  82364. /** @hidden */
  82365. _currentVelocity1: number;
  82366. /** @hidden */
  82367. _currentVelocity2: number;
  82368. /** @hidden */
  82369. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82370. /** @hidden */
  82371. _currentLimitVelocity1: number;
  82372. /** @hidden */
  82373. _currentLimitVelocity2: number;
  82374. /** @hidden */
  82375. _currentDragGradient: Nullable<FactorGradient>;
  82376. /** @hidden */
  82377. _currentDrag1: number;
  82378. /** @hidden */
  82379. _currentDrag2: number;
  82380. /** @hidden */
  82381. _randomNoiseCoordinates1: Vector3;
  82382. /** @hidden */
  82383. _randomNoiseCoordinates2: Vector3;
  82384. /**
  82385. * Creates a new instance Particle
  82386. * @param particleSystem the particle system the particle belongs to
  82387. */
  82388. constructor(
  82389. /**
  82390. * The particle system the particle belongs to.
  82391. */
  82392. particleSystem: ParticleSystem);
  82393. private updateCellInfoFromSystem;
  82394. /**
  82395. * Defines how the sprite cell index is updated for the particle
  82396. */
  82397. updateCellIndex(): void;
  82398. /** @hidden */
  82399. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82400. /** @hidden */
  82401. _inheritParticleInfoToSubEmitters(): void;
  82402. /** @hidden */
  82403. _reset(): void;
  82404. /**
  82405. * Copy the properties of particle to another one.
  82406. * @param other the particle to copy the information to.
  82407. */
  82408. copyTo(other: Particle): void;
  82409. }
  82410. }
  82411. declare module BABYLON {
  82412. /**
  82413. * Particle emitter represents a volume emitting particles.
  82414. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82415. */
  82416. export interface IParticleEmitterType {
  82417. /**
  82418. * Called by the particle System when the direction is computed for the created particle.
  82419. * @param worldMatrix is the world matrix of the particle system
  82420. * @param directionToUpdate is the direction vector to update with the result
  82421. * @param particle is the particle we are computed the direction for
  82422. */
  82423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82424. /**
  82425. * Called by the particle System when the position is computed for the created particle.
  82426. * @param worldMatrix is the world matrix of the particle system
  82427. * @param positionToUpdate is the position vector to update with the result
  82428. * @param particle is the particle we are computed the position for
  82429. */
  82430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82431. /**
  82432. * Clones the current emitter and returns a copy of it
  82433. * @returns the new emitter
  82434. */
  82435. clone(): IParticleEmitterType;
  82436. /**
  82437. * Called by the GPUParticleSystem to setup the update shader
  82438. * @param effect defines the update shader
  82439. */
  82440. applyToShader(effect: Effect): void;
  82441. /**
  82442. * Returns a string to use to update the GPU particles update shader
  82443. * @returns the effect defines string
  82444. */
  82445. getEffectDefines(): string;
  82446. /**
  82447. * Returns a string representing the class name
  82448. * @returns a string containing the class name
  82449. */
  82450. getClassName(): string;
  82451. /**
  82452. * Serializes the particle system to a JSON object.
  82453. * @returns the JSON object
  82454. */
  82455. serialize(): any;
  82456. /**
  82457. * Parse properties from a JSON object
  82458. * @param serializationObject defines the JSON object
  82459. */
  82460. parse(serializationObject: any): void;
  82461. }
  82462. }
  82463. declare module BABYLON {
  82464. /**
  82465. * Particle emitter emitting particles from the inside of a box.
  82466. * It emits the particles randomly between 2 given directions.
  82467. */
  82468. export class BoxParticleEmitter implements IParticleEmitterType {
  82469. /**
  82470. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82471. */
  82472. direction1: Vector3;
  82473. /**
  82474. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82475. */
  82476. direction2: Vector3;
  82477. /**
  82478. * 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.
  82479. */
  82480. minEmitBox: Vector3;
  82481. /**
  82482. * 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.
  82483. */
  82484. maxEmitBox: Vector3;
  82485. /**
  82486. * Creates a new instance BoxParticleEmitter
  82487. */
  82488. constructor();
  82489. /**
  82490. * Called by the particle System when the direction is computed for the created particle.
  82491. * @param worldMatrix is the world matrix of the particle system
  82492. * @param directionToUpdate is the direction vector to update with the result
  82493. * @param particle is the particle we are computed the direction for
  82494. */
  82495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82496. /**
  82497. * Called by the particle System when the position is computed for the created particle.
  82498. * @param worldMatrix is the world matrix of the particle system
  82499. * @param positionToUpdate is the position vector to update with the result
  82500. * @param particle is the particle we are computed the position for
  82501. */
  82502. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82503. /**
  82504. * Clones the current emitter and returns a copy of it
  82505. * @returns the new emitter
  82506. */
  82507. clone(): BoxParticleEmitter;
  82508. /**
  82509. * Called by the GPUParticleSystem to setup the update shader
  82510. * @param effect defines the update shader
  82511. */
  82512. applyToShader(effect: Effect): void;
  82513. /**
  82514. * Returns a string to use to update the GPU particles update shader
  82515. * @returns a string containng the defines string
  82516. */
  82517. getEffectDefines(): string;
  82518. /**
  82519. * Returns the string "BoxParticleEmitter"
  82520. * @returns a string containing the class name
  82521. */
  82522. getClassName(): string;
  82523. /**
  82524. * Serializes the particle system to a JSON object.
  82525. * @returns the JSON object
  82526. */
  82527. serialize(): any;
  82528. /**
  82529. * Parse properties from a JSON object
  82530. * @param serializationObject defines the JSON object
  82531. */
  82532. parse(serializationObject: any): void;
  82533. }
  82534. }
  82535. declare module BABYLON {
  82536. /**
  82537. * Particle emitter emitting particles from the inside of a cone.
  82538. * It emits the particles alongside the cone volume from the base to the particle.
  82539. * The emission direction might be randomized.
  82540. */
  82541. export class ConeParticleEmitter implements IParticleEmitterType {
  82542. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82543. directionRandomizer: number;
  82544. private _radius;
  82545. private _angle;
  82546. private _height;
  82547. /**
  82548. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82549. */
  82550. radiusRange: number;
  82551. /**
  82552. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82553. */
  82554. heightRange: number;
  82555. /**
  82556. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82557. */
  82558. emitFromSpawnPointOnly: boolean;
  82559. /**
  82560. * Gets or sets the radius of the emission cone
  82561. */
  82562. radius: number;
  82563. /**
  82564. * Gets or sets the angle of the emission cone
  82565. */
  82566. angle: number;
  82567. private _buildHeight;
  82568. /**
  82569. * Creates a new instance ConeParticleEmitter
  82570. * @param radius the radius of the emission cone (1 by default)
  82571. * @param angle the cone base angle (PI by default)
  82572. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82573. */
  82574. constructor(radius?: number, angle?: number,
  82575. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82576. directionRandomizer?: number);
  82577. /**
  82578. * Called by the particle System when the direction is computed for the created particle.
  82579. * @param worldMatrix is the world matrix of the particle system
  82580. * @param directionToUpdate is the direction vector to update with the result
  82581. * @param particle is the particle we are computed the direction for
  82582. */
  82583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82584. /**
  82585. * Called by the particle System when the position is computed for the created particle.
  82586. * @param worldMatrix is the world matrix of the particle system
  82587. * @param positionToUpdate is the position vector to update with the result
  82588. * @param particle is the particle we are computed the position for
  82589. */
  82590. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82591. /**
  82592. * Clones the current emitter and returns a copy of it
  82593. * @returns the new emitter
  82594. */
  82595. clone(): ConeParticleEmitter;
  82596. /**
  82597. * Called by the GPUParticleSystem to setup the update shader
  82598. * @param effect defines the update shader
  82599. */
  82600. applyToShader(effect: Effect): void;
  82601. /**
  82602. * Returns a string to use to update the GPU particles update shader
  82603. * @returns a string containng the defines string
  82604. */
  82605. getEffectDefines(): string;
  82606. /**
  82607. * Returns the string "ConeParticleEmitter"
  82608. * @returns a string containing the class name
  82609. */
  82610. getClassName(): string;
  82611. /**
  82612. * Serializes the particle system to a JSON object.
  82613. * @returns the JSON object
  82614. */
  82615. serialize(): any;
  82616. /**
  82617. * Parse properties from a JSON object
  82618. * @param serializationObject defines the JSON object
  82619. */
  82620. parse(serializationObject: any): void;
  82621. }
  82622. }
  82623. declare module BABYLON {
  82624. /**
  82625. * Particle emitter emitting particles from the inside of a cylinder.
  82626. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82627. */
  82628. export class CylinderParticleEmitter implements IParticleEmitterType {
  82629. /**
  82630. * The radius of the emission cylinder.
  82631. */
  82632. radius: number;
  82633. /**
  82634. * The height of the emission cylinder.
  82635. */
  82636. height: number;
  82637. /**
  82638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82639. */
  82640. radiusRange: number;
  82641. /**
  82642. * How much to randomize the particle direction [0-1].
  82643. */
  82644. directionRandomizer: number;
  82645. /**
  82646. * Creates a new instance CylinderParticleEmitter
  82647. * @param radius the radius of the emission cylinder (1 by default)
  82648. * @param height the height of the emission cylinder (1 by default)
  82649. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82650. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82651. */
  82652. constructor(
  82653. /**
  82654. * The radius of the emission cylinder.
  82655. */
  82656. radius?: number,
  82657. /**
  82658. * The height of the emission cylinder.
  82659. */
  82660. height?: number,
  82661. /**
  82662. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82663. */
  82664. radiusRange?: number,
  82665. /**
  82666. * How much to randomize the particle direction [0-1].
  82667. */
  82668. directionRandomizer?: number);
  82669. /**
  82670. * Called by the particle System when the direction is computed for the created particle.
  82671. * @param worldMatrix is the world matrix of the particle system
  82672. * @param directionToUpdate is the direction vector to update with the result
  82673. * @param particle is the particle we are computed the direction for
  82674. */
  82675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82676. /**
  82677. * Called by the particle System when the position is computed for the created particle.
  82678. * @param worldMatrix is the world matrix of the particle system
  82679. * @param positionToUpdate is the position vector to update with the result
  82680. * @param particle is the particle we are computed the position for
  82681. */
  82682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82683. /**
  82684. * Clones the current emitter and returns a copy of it
  82685. * @returns the new emitter
  82686. */
  82687. clone(): CylinderParticleEmitter;
  82688. /**
  82689. * Called by the GPUParticleSystem to setup the update shader
  82690. * @param effect defines the update shader
  82691. */
  82692. applyToShader(effect: Effect): void;
  82693. /**
  82694. * Returns a string to use to update the GPU particles update shader
  82695. * @returns a string containng the defines string
  82696. */
  82697. getEffectDefines(): string;
  82698. /**
  82699. * Returns the string "CylinderParticleEmitter"
  82700. * @returns a string containing the class name
  82701. */
  82702. getClassName(): string;
  82703. /**
  82704. * Serializes the particle system to a JSON object.
  82705. * @returns the JSON object
  82706. */
  82707. serialize(): any;
  82708. /**
  82709. * Parse properties from a JSON object
  82710. * @param serializationObject defines the JSON object
  82711. */
  82712. parse(serializationObject: any): void;
  82713. }
  82714. /**
  82715. * Particle emitter emitting particles from the inside of a cylinder.
  82716. * It emits the particles randomly between two vectors.
  82717. */
  82718. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82719. /**
  82720. * The min limit of the emission direction.
  82721. */
  82722. direction1: Vector3;
  82723. /**
  82724. * The max limit of the emission direction.
  82725. */
  82726. direction2: Vector3;
  82727. /**
  82728. * Creates a new instance CylinderDirectedParticleEmitter
  82729. * @param radius the radius of the emission cylinder (1 by default)
  82730. * @param height the height of the emission cylinder (1 by default)
  82731. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82732. * @param direction1 the min limit of the emission direction (up vector by default)
  82733. * @param direction2 the max limit of the emission direction (up vector by default)
  82734. */
  82735. constructor(radius?: number, height?: number, radiusRange?: number,
  82736. /**
  82737. * The min limit of the emission direction.
  82738. */
  82739. direction1?: Vector3,
  82740. /**
  82741. * The max limit of the emission direction.
  82742. */
  82743. direction2?: Vector3);
  82744. /**
  82745. * Called by the particle System when the direction is computed for the created particle.
  82746. * @param worldMatrix is the world matrix of the particle system
  82747. * @param directionToUpdate is the direction vector to update with the result
  82748. * @param particle is the particle we are computed the direction for
  82749. */
  82750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82751. /**
  82752. * Clones the current emitter and returns a copy of it
  82753. * @returns the new emitter
  82754. */
  82755. clone(): CylinderDirectedParticleEmitter;
  82756. /**
  82757. * Called by the GPUParticleSystem to setup the update shader
  82758. * @param effect defines the update shader
  82759. */
  82760. applyToShader(effect: Effect): void;
  82761. /**
  82762. * Returns a string to use to update the GPU particles update shader
  82763. * @returns a string containng the defines string
  82764. */
  82765. getEffectDefines(): string;
  82766. /**
  82767. * Returns the string "CylinderDirectedParticleEmitter"
  82768. * @returns a string containing the class name
  82769. */
  82770. getClassName(): string;
  82771. /**
  82772. * Serializes the particle system to a JSON object.
  82773. * @returns the JSON object
  82774. */
  82775. serialize(): any;
  82776. /**
  82777. * Parse properties from a JSON object
  82778. * @param serializationObject defines the JSON object
  82779. */
  82780. parse(serializationObject: any): void;
  82781. }
  82782. }
  82783. declare module BABYLON {
  82784. /**
  82785. * Particle emitter emitting particles from the inside of a hemisphere.
  82786. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82787. */
  82788. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82789. /**
  82790. * The radius of the emission hemisphere.
  82791. */
  82792. radius: number;
  82793. /**
  82794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82795. */
  82796. radiusRange: number;
  82797. /**
  82798. * How much to randomize the particle direction [0-1].
  82799. */
  82800. directionRandomizer: number;
  82801. /**
  82802. * Creates a new instance HemisphericParticleEmitter
  82803. * @param radius the radius of the emission hemisphere (1 by default)
  82804. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82805. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82806. */
  82807. constructor(
  82808. /**
  82809. * The radius of the emission hemisphere.
  82810. */
  82811. radius?: number,
  82812. /**
  82813. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82814. */
  82815. radiusRange?: number,
  82816. /**
  82817. * How much to randomize the particle direction [0-1].
  82818. */
  82819. directionRandomizer?: number);
  82820. /**
  82821. * Called by the particle System when the direction is computed for the created particle.
  82822. * @param worldMatrix is the world matrix of the particle system
  82823. * @param directionToUpdate is the direction vector to update with the result
  82824. * @param particle is the particle we are computed the direction for
  82825. */
  82826. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82827. /**
  82828. * Called by the particle System when the position is computed for the created particle.
  82829. * @param worldMatrix is the world matrix of the particle system
  82830. * @param positionToUpdate is the position vector to update with the result
  82831. * @param particle is the particle we are computed the position for
  82832. */
  82833. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82834. /**
  82835. * Clones the current emitter and returns a copy of it
  82836. * @returns the new emitter
  82837. */
  82838. clone(): HemisphericParticleEmitter;
  82839. /**
  82840. * Called by the GPUParticleSystem to setup the update shader
  82841. * @param effect defines the update shader
  82842. */
  82843. applyToShader(effect: Effect): void;
  82844. /**
  82845. * Returns a string to use to update the GPU particles update shader
  82846. * @returns a string containng the defines string
  82847. */
  82848. getEffectDefines(): string;
  82849. /**
  82850. * Returns the string "HemisphericParticleEmitter"
  82851. * @returns a string containing the class name
  82852. */
  82853. getClassName(): string;
  82854. /**
  82855. * Serializes the particle system to a JSON object.
  82856. * @returns the JSON object
  82857. */
  82858. serialize(): any;
  82859. /**
  82860. * Parse properties from a JSON object
  82861. * @param serializationObject defines the JSON object
  82862. */
  82863. parse(serializationObject: any): void;
  82864. }
  82865. }
  82866. declare module BABYLON {
  82867. /**
  82868. * Particle emitter emitting particles from a point.
  82869. * It emits the particles randomly between 2 given directions.
  82870. */
  82871. export class PointParticleEmitter implements IParticleEmitterType {
  82872. /**
  82873. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82874. */
  82875. direction1: Vector3;
  82876. /**
  82877. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82878. */
  82879. direction2: Vector3;
  82880. /**
  82881. * Creates a new instance PointParticleEmitter
  82882. */
  82883. constructor();
  82884. /**
  82885. * Called by the particle System when the direction is computed for the created particle.
  82886. * @param worldMatrix is the world matrix of the particle system
  82887. * @param directionToUpdate is the direction vector to update with the result
  82888. * @param particle is the particle we are computed the direction for
  82889. */
  82890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82891. /**
  82892. * Called by the particle System when the position is computed for the created particle.
  82893. * @param worldMatrix is the world matrix of the particle system
  82894. * @param positionToUpdate is the position vector to update with the result
  82895. * @param particle is the particle we are computed the position for
  82896. */
  82897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82898. /**
  82899. * Clones the current emitter and returns a copy of it
  82900. * @returns the new emitter
  82901. */
  82902. clone(): PointParticleEmitter;
  82903. /**
  82904. * Called by the GPUParticleSystem to setup the update shader
  82905. * @param effect defines the update shader
  82906. */
  82907. applyToShader(effect: Effect): void;
  82908. /**
  82909. * Returns a string to use to update the GPU particles update shader
  82910. * @returns a string containng the defines string
  82911. */
  82912. getEffectDefines(): string;
  82913. /**
  82914. * Returns the string "PointParticleEmitter"
  82915. * @returns a string containing the class name
  82916. */
  82917. getClassName(): string;
  82918. /**
  82919. * Serializes the particle system to a JSON object.
  82920. * @returns the JSON object
  82921. */
  82922. serialize(): any;
  82923. /**
  82924. * Parse properties from a JSON object
  82925. * @param serializationObject defines the JSON object
  82926. */
  82927. parse(serializationObject: any): void;
  82928. }
  82929. }
  82930. declare module BABYLON {
  82931. /**
  82932. * Particle emitter emitting particles from the inside of a sphere.
  82933. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82934. */
  82935. export class SphereParticleEmitter implements IParticleEmitterType {
  82936. /**
  82937. * The radius of the emission sphere.
  82938. */
  82939. radius: number;
  82940. /**
  82941. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82942. */
  82943. radiusRange: number;
  82944. /**
  82945. * How much to randomize the particle direction [0-1].
  82946. */
  82947. directionRandomizer: number;
  82948. /**
  82949. * Creates a new instance SphereParticleEmitter
  82950. * @param radius the radius of the emission sphere (1 by default)
  82951. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82952. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82953. */
  82954. constructor(
  82955. /**
  82956. * The radius of the emission sphere.
  82957. */
  82958. radius?: number,
  82959. /**
  82960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82961. */
  82962. radiusRange?: number,
  82963. /**
  82964. * How much to randomize the particle direction [0-1].
  82965. */
  82966. directionRandomizer?: number);
  82967. /**
  82968. * Called by the particle System when the direction is computed for the created particle.
  82969. * @param worldMatrix is the world matrix of the particle system
  82970. * @param directionToUpdate is the direction vector to update with the result
  82971. * @param particle is the particle we are computed the direction for
  82972. */
  82973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82974. /**
  82975. * Called by the particle System when the position is computed for the created particle.
  82976. * @param worldMatrix is the world matrix of the particle system
  82977. * @param positionToUpdate is the position vector to update with the result
  82978. * @param particle is the particle we are computed the position for
  82979. */
  82980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82981. /**
  82982. * Clones the current emitter and returns a copy of it
  82983. * @returns the new emitter
  82984. */
  82985. clone(): SphereParticleEmitter;
  82986. /**
  82987. * Called by the GPUParticleSystem to setup the update shader
  82988. * @param effect defines the update shader
  82989. */
  82990. applyToShader(effect: Effect): void;
  82991. /**
  82992. * Returns a string to use to update the GPU particles update shader
  82993. * @returns a string containng the defines string
  82994. */
  82995. getEffectDefines(): string;
  82996. /**
  82997. * Returns the string "SphereParticleEmitter"
  82998. * @returns a string containing the class name
  82999. */
  83000. getClassName(): string;
  83001. /**
  83002. * Serializes the particle system to a JSON object.
  83003. * @returns the JSON object
  83004. */
  83005. serialize(): any;
  83006. /**
  83007. * Parse properties from a JSON object
  83008. * @param serializationObject defines the JSON object
  83009. */
  83010. parse(serializationObject: any): void;
  83011. }
  83012. /**
  83013. * Particle emitter emitting particles from the inside of a sphere.
  83014. * It emits the particles randomly between two vectors.
  83015. */
  83016. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83017. /**
  83018. * The min limit of the emission direction.
  83019. */
  83020. direction1: Vector3;
  83021. /**
  83022. * The max limit of the emission direction.
  83023. */
  83024. direction2: Vector3;
  83025. /**
  83026. * Creates a new instance SphereDirectedParticleEmitter
  83027. * @param radius the radius of the emission sphere (1 by default)
  83028. * @param direction1 the min limit of the emission direction (up vector by default)
  83029. * @param direction2 the max limit of the emission direction (up vector by default)
  83030. */
  83031. constructor(radius?: number,
  83032. /**
  83033. * The min limit of the emission direction.
  83034. */
  83035. direction1?: Vector3,
  83036. /**
  83037. * The max limit of the emission direction.
  83038. */
  83039. direction2?: Vector3);
  83040. /**
  83041. * Called by the particle System when the direction is computed for the created particle.
  83042. * @param worldMatrix is the world matrix of the particle system
  83043. * @param directionToUpdate is the direction vector to update with the result
  83044. * @param particle is the particle we are computed the direction for
  83045. */
  83046. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83047. /**
  83048. * Clones the current emitter and returns a copy of it
  83049. * @returns the new emitter
  83050. */
  83051. clone(): SphereDirectedParticleEmitter;
  83052. /**
  83053. * Called by the GPUParticleSystem to setup the update shader
  83054. * @param effect defines the update shader
  83055. */
  83056. applyToShader(effect: Effect): void;
  83057. /**
  83058. * Returns a string to use to update the GPU particles update shader
  83059. * @returns a string containng the defines string
  83060. */
  83061. getEffectDefines(): string;
  83062. /**
  83063. * Returns the string "SphereDirectedParticleEmitter"
  83064. * @returns a string containing the class name
  83065. */
  83066. getClassName(): string;
  83067. /**
  83068. * Serializes the particle system to a JSON object.
  83069. * @returns the JSON object
  83070. */
  83071. serialize(): any;
  83072. /**
  83073. * Parse properties from a JSON object
  83074. * @param serializationObject defines the JSON object
  83075. */
  83076. parse(serializationObject: any): void;
  83077. }
  83078. }
  83079. declare module BABYLON {
  83080. /**
  83081. * Interface representing a particle system in Babylon.js.
  83082. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83083. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83084. */
  83085. export interface IParticleSystem {
  83086. /**
  83087. * List of animations used by the particle system.
  83088. */
  83089. animations: Animation[];
  83090. /**
  83091. * The id of the Particle system.
  83092. */
  83093. id: string;
  83094. /**
  83095. * The name of the Particle system.
  83096. */
  83097. name: string;
  83098. /**
  83099. * The emitter represents the Mesh or position we are attaching the particle system to.
  83100. */
  83101. emitter: Nullable<AbstractMesh | Vector3>;
  83102. /**
  83103. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83104. */
  83105. isBillboardBased: boolean;
  83106. /**
  83107. * The rendering group used by the Particle system to chose when to render.
  83108. */
  83109. renderingGroupId: number;
  83110. /**
  83111. * The layer mask we are rendering the particles through.
  83112. */
  83113. layerMask: number;
  83114. /**
  83115. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83116. */
  83117. updateSpeed: number;
  83118. /**
  83119. * The amount of time the particle system is running (depends of the overall update speed).
  83120. */
  83121. targetStopDuration: number;
  83122. /**
  83123. * The texture used to render each particle. (this can be a spritesheet)
  83124. */
  83125. particleTexture: Nullable<Texture>;
  83126. /**
  83127. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83128. */
  83129. blendMode: number;
  83130. /**
  83131. * Minimum life time of emitting particles.
  83132. */
  83133. minLifeTime: number;
  83134. /**
  83135. * Maximum life time of emitting particles.
  83136. */
  83137. maxLifeTime: number;
  83138. /**
  83139. * Minimum Size of emitting particles.
  83140. */
  83141. minSize: number;
  83142. /**
  83143. * Maximum Size of emitting particles.
  83144. */
  83145. maxSize: number;
  83146. /**
  83147. * Minimum scale of emitting particles on X axis.
  83148. */
  83149. minScaleX: number;
  83150. /**
  83151. * Maximum scale of emitting particles on X axis.
  83152. */
  83153. maxScaleX: number;
  83154. /**
  83155. * Minimum scale of emitting particles on Y axis.
  83156. */
  83157. minScaleY: number;
  83158. /**
  83159. * Maximum scale of emitting particles on Y axis.
  83160. */
  83161. maxScaleY: number;
  83162. /**
  83163. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83164. */
  83165. color1: Color4;
  83166. /**
  83167. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83168. */
  83169. color2: Color4;
  83170. /**
  83171. * Color the particle will have at the end of its lifetime.
  83172. */
  83173. colorDead: Color4;
  83174. /**
  83175. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83176. */
  83177. emitRate: number;
  83178. /**
  83179. * You can use gravity if you want to give an orientation to your particles.
  83180. */
  83181. gravity: Vector3;
  83182. /**
  83183. * Minimum power of emitting particles.
  83184. */
  83185. minEmitPower: number;
  83186. /**
  83187. * Maximum power of emitting particles.
  83188. */
  83189. maxEmitPower: number;
  83190. /**
  83191. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83192. */
  83193. minAngularSpeed: number;
  83194. /**
  83195. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83196. */
  83197. maxAngularSpeed: number;
  83198. /**
  83199. * Gets or sets the minimal initial rotation in radians.
  83200. */
  83201. minInitialRotation: number;
  83202. /**
  83203. * Gets or sets the maximal initial rotation in radians.
  83204. */
  83205. maxInitialRotation: number;
  83206. /**
  83207. * The particle emitter type defines the emitter used by the particle system.
  83208. * It can be for example box, sphere, or cone...
  83209. */
  83210. particleEmitterType: Nullable<IParticleEmitterType>;
  83211. /**
  83212. * Defines the delay in milliseconds before starting the system (0 by default)
  83213. */
  83214. startDelay: number;
  83215. /**
  83216. * 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
  83217. */
  83218. preWarmCycles: number;
  83219. /**
  83220. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83221. */
  83222. preWarmStepOffset: number;
  83223. /**
  83224. * 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)
  83225. */
  83226. spriteCellChangeSpeed: number;
  83227. /**
  83228. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83229. */
  83230. startSpriteCellID: number;
  83231. /**
  83232. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83233. */
  83234. endSpriteCellID: number;
  83235. /**
  83236. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83237. */
  83238. spriteCellWidth: number;
  83239. /**
  83240. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83241. */
  83242. spriteCellHeight: number;
  83243. /**
  83244. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83245. */
  83246. spriteRandomStartCell: boolean;
  83247. /**
  83248. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83249. */
  83250. isAnimationSheetEnabled: boolean;
  83251. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83252. translationPivot: Vector2;
  83253. /**
  83254. * Gets or sets a texture used to add random noise to particle positions
  83255. */
  83256. noiseTexture: Nullable<BaseTexture>;
  83257. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83258. noiseStrength: Vector3;
  83259. /**
  83260. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83261. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83262. */
  83263. billboardMode: number;
  83264. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83265. limitVelocityDamping: number;
  83266. /**
  83267. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83268. */
  83269. beginAnimationOnStart: boolean;
  83270. /**
  83271. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83272. */
  83273. beginAnimationFrom: number;
  83274. /**
  83275. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83276. */
  83277. beginAnimationTo: number;
  83278. /**
  83279. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83280. */
  83281. beginAnimationLoop: boolean;
  83282. /**
  83283. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83284. */
  83285. disposeOnStop: boolean;
  83286. /**
  83287. * Gets the maximum number of particles active at the same time.
  83288. * @returns The max number of active particles.
  83289. */
  83290. getCapacity(): number;
  83291. /**
  83292. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83293. * @returns True if it has been started, otherwise false.
  83294. */
  83295. isStarted(): boolean;
  83296. /**
  83297. * Animates the particle system for this frame.
  83298. */
  83299. animate(): void;
  83300. /**
  83301. * Renders the particle system in its current state.
  83302. * @returns the current number of particles
  83303. */
  83304. render(): number;
  83305. /**
  83306. * Dispose the particle system and frees its associated resources.
  83307. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83308. */
  83309. dispose(disposeTexture?: boolean): void;
  83310. /**
  83311. * Clones the particle system.
  83312. * @param name The name of the cloned object
  83313. * @param newEmitter The new emitter to use
  83314. * @returns the cloned particle system
  83315. */
  83316. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83317. /**
  83318. * Serializes the particle system to a JSON object.
  83319. * @returns the JSON object
  83320. */
  83321. serialize(): any;
  83322. /**
  83323. * Rebuild the particle system
  83324. */
  83325. rebuild(): void;
  83326. /**
  83327. * Starts the particle system and begins to emit
  83328. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83329. */
  83330. start(delay?: number): void;
  83331. /**
  83332. * Stops the particle system.
  83333. */
  83334. stop(): void;
  83335. /**
  83336. * Remove all active particles
  83337. */
  83338. reset(): void;
  83339. /**
  83340. * Is this system ready to be used/rendered
  83341. * @return true if the system is ready
  83342. */
  83343. isReady(): boolean;
  83344. /**
  83345. * Adds a new color gradient
  83346. * @param gradient defines the gradient to use (between 0 and 1)
  83347. * @param color1 defines the color to affect to the specified gradient
  83348. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83349. * @returns the current particle system
  83350. */
  83351. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83352. /**
  83353. * Remove a specific color gradient
  83354. * @param gradient defines the gradient to remove
  83355. * @returns the current particle system
  83356. */
  83357. removeColorGradient(gradient: number): IParticleSystem;
  83358. /**
  83359. * Adds a new size gradient
  83360. * @param gradient defines the gradient to use (between 0 and 1)
  83361. * @param factor defines the size factor to affect to the specified gradient
  83362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83363. * @returns the current particle system
  83364. */
  83365. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83366. /**
  83367. * Remove a specific size gradient
  83368. * @param gradient defines the gradient to remove
  83369. * @returns the current particle system
  83370. */
  83371. removeSizeGradient(gradient: number): IParticleSystem;
  83372. /**
  83373. * Gets the current list of color gradients.
  83374. * You must use addColorGradient and removeColorGradient to udpate this list
  83375. * @returns the list of color gradients
  83376. */
  83377. getColorGradients(): Nullable<Array<ColorGradient>>;
  83378. /**
  83379. * Gets the current list of size gradients.
  83380. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83381. * @returns the list of size gradients
  83382. */
  83383. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83384. /**
  83385. * Gets the current list of angular speed gradients.
  83386. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83387. * @returns the list of angular speed gradients
  83388. */
  83389. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83390. /**
  83391. * Adds a new angular speed gradient
  83392. * @param gradient defines the gradient to use (between 0 and 1)
  83393. * @param factor defines the angular speed to affect to the specified gradient
  83394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83395. * @returns the current particle system
  83396. */
  83397. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83398. /**
  83399. * Remove a specific angular speed gradient
  83400. * @param gradient defines the gradient to remove
  83401. * @returns the current particle system
  83402. */
  83403. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83404. /**
  83405. * Gets the current list of velocity gradients.
  83406. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83407. * @returns the list of velocity gradients
  83408. */
  83409. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83410. /**
  83411. * Adds a new velocity gradient
  83412. * @param gradient defines the gradient to use (between 0 and 1)
  83413. * @param factor defines the velocity to affect to the specified gradient
  83414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83415. * @returns the current particle system
  83416. */
  83417. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83418. /**
  83419. * Remove a specific velocity gradient
  83420. * @param gradient defines the gradient to remove
  83421. * @returns the current particle system
  83422. */
  83423. removeVelocityGradient(gradient: number): IParticleSystem;
  83424. /**
  83425. * Gets the current list of limit velocity gradients.
  83426. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83427. * @returns the list of limit velocity gradients
  83428. */
  83429. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83430. /**
  83431. * Adds a new limit velocity gradient
  83432. * @param gradient defines the gradient to use (between 0 and 1)
  83433. * @param factor defines the limit velocity to affect to the specified gradient
  83434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83435. * @returns the current particle system
  83436. */
  83437. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83438. /**
  83439. * Remove a specific limit velocity gradient
  83440. * @param gradient defines the gradient to remove
  83441. * @returns the current particle system
  83442. */
  83443. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83444. /**
  83445. * Adds a new drag gradient
  83446. * @param gradient defines the gradient to use (between 0 and 1)
  83447. * @param factor defines the drag to affect to the specified gradient
  83448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83449. * @returns the current particle system
  83450. */
  83451. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83452. /**
  83453. * Remove a specific drag gradient
  83454. * @param gradient defines the gradient to remove
  83455. * @returns the current particle system
  83456. */
  83457. removeDragGradient(gradient: number): IParticleSystem;
  83458. /**
  83459. * Gets the current list of drag gradients.
  83460. * You must use addDragGradient and removeDragGradient to udpate this list
  83461. * @returns the list of drag gradients
  83462. */
  83463. getDragGradients(): Nullable<Array<FactorGradient>>;
  83464. /**
  83465. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83466. * @param gradient defines the gradient to use (between 0 and 1)
  83467. * @param factor defines the emit rate to affect to the specified gradient
  83468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83469. * @returns the current particle system
  83470. */
  83471. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83472. /**
  83473. * Remove a specific emit rate gradient
  83474. * @param gradient defines the gradient to remove
  83475. * @returns the current particle system
  83476. */
  83477. removeEmitRateGradient(gradient: number): IParticleSystem;
  83478. /**
  83479. * Gets the current list of emit rate gradients.
  83480. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83481. * @returns the list of emit rate gradients
  83482. */
  83483. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83484. /**
  83485. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83486. * @param gradient defines the gradient to use (between 0 and 1)
  83487. * @param factor defines the start size to affect to the specified gradient
  83488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83489. * @returns the current particle system
  83490. */
  83491. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83492. /**
  83493. * Remove a specific start size gradient
  83494. * @param gradient defines the gradient to remove
  83495. * @returns the current particle system
  83496. */
  83497. removeStartSizeGradient(gradient: number): IParticleSystem;
  83498. /**
  83499. * Gets the current list of start size gradients.
  83500. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83501. * @returns the list of start size gradients
  83502. */
  83503. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83504. /**
  83505. * Adds a new life time gradient
  83506. * @param gradient defines the gradient to use (between 0 and 1)
  83507. * @param factor defines the life time factor to affect to the specified gradient
  83508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83509. * @returns the current particle system
  83510. */
  83511. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83512. /**
  83513. * Remove a specific life time gradient
  83514. * @param gradient defines the gradient to remove
  83515. * @returns the current particle system
  83516. */
  83517. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83518. /**
  83519. * Gets the current list of life time gradients.
  83520. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83521. * @returns the list of life time gradients
  83522. */
  83523. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83524. /**
  83525. * Gets the current list of color gradients.
  83526. * You must use addColorGradient and removeColorGradient to udpate this list
  83527. * @returns the list of color gradients
  83528. */
  83529. getColorGradients(): Nullable<Array<ColorGradient>>;
  83530. /**
  83531. * Adds a new ramp gradient used to remap particle colors
  83532. * @param gradient defines the gradient to use (between 0 and 1)
  83533. * @param color defines the color to affect to the specified gradient
  83534. * @returns the current particle system
  83535. */
  83536. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83537. /**
  83538. * Gets the current list of ramp gradients.
  83539. * You must use addRampGradient and removeRampGradient to udpate this list
  83540. * @returns the list of ramp gradients
  83541. */
  83542. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83543. /** Gets or sets a boolean indicating that ramp gradients must be used
  83544. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83545. */
  83546. useRampGradients: boolean;
  83547. /**
  83548. * Adds a new color remap gradient
  83549. * @param gradient defines the gradient to use (between 0 and 1)
  83550. * @param min defines the color remap minimal range
  83551. * @param max defines the color remap maximal range
  83552. * @returns the current particle system
  83553. */
  83554. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83555. /**
  83556. * Gets the current list of color remap gradients.
  83557. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83558. * @returns the list of color remap gradients
  83559. */
  83560. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83561. /**
  83562. * Adds a new alpha remap gradient
  83563. * @param gradient defines the gradient to use (between 0 and 1)
  83564. * @param min defines the alpha remap minimal range
  83565. * @param max defines the alpha remap maximal range
  83566. * @returns the current particle system
  83567. */
  83568. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83569. /**
  83570. * Gets the current list of alpha remap gradients.
  83571. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83572. * @returns the list of alpha remap gradients
  83573. */
  83574. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83575. /**
  83576. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83579. * @returns the emitter
  83580. */
  83581. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83582. /**
  83583. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83584. * @param radius The radius of the hemisphere to emit from
  83585. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83586. * @returns the emitter
  83587. */
  83588. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83589. /**
  83590. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83591. * @param radius The radius of the sphere to emit from
  83592. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83593. * @returns the emitter
  83594. */
  83595. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83596. /**
  83597. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83598. * @param radius The radius of the sphere to emit from
  83599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83601. * @returns the emitter
  83602. */
  83603. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83604. /**
  83605. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83606. * @param radius The radius of the emission cylinder
  83607. * @param height The height of the emission cylinder
  83608. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83609. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83610. * @returns the emitter
  83611. */
  83612. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83613. /**
  83614. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83615. * @param radius The radius of the cylinder to emit from
  83616. * @param height The height of the emission cylinder
  83617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83620. * @returns the emitter
  83621. */
  83622. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83623. /**
  83624. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83625. * @param radius The radius of the cone to emit from
  83626. * @param angle The base angle of the cone
  83627. * @returns the emitter
  83628. */
  83629. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83630. /**
  83631. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83634. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83635. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83636. * @returns the emitter
  83637. */
  83638. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83639. /**
  83640. * Get hosting scene
  83641. * @returns the scene
  83642. */
  83643. getScene(): Scene;
  83644. }
  83645. }
  83646. declare module BABYLON {
  83647. /**
  83648. * Creates an instance based on a source mesh.
  83649. */
  83650. export class InstancedMesh extends AbstractMesh {
  83651. private _sourceMesh;
  83652. private _currentLOD;
  83653. /** @hidden */
  83654. _indexInSourceMeshInstanceArray: number;
  83655. constructor(name: string, source: Mesh);
  83656. /**
  83657. * Returns the string "InstancedMesh".
  83658. */
  83659. getClassName(): string;
  83660. /** Gets the list of lights affecting that mesh */
  83661. readonly lightSources: Light[];
  83662. _resyncLightSources(): void;
  83663. _resyncLighSource(light: Light): void;
  83664. _removeLightSource(light: Light, dispose: boolean): void;
  83665. /**
  83666. * If the source mesh receives shadows
  83667. */
  83668. readonly receiveShadows: boolean;
  83669. /**
  83670. * The material of the source mesh
  83671. */
  83672. readonly material: Nullable<Material>;
  83673. /**
  83674. * Visibility of the source mesh
  83675. */
  83676. readonly visibility: number;
  83677. /**
  83678. * Skeleton of the source mesh
  83679. */
  83680. readonly skeleton: Nullable<Skeleton>;
  83681. /**
  83682. * Rendering ground id of the source mesh
  83683. */
  83684. renderingGroupId: number;
  83685. /**
  83686. * Returns the total number of vertices (integer).
  83687. */
  83688. getTotalVertices(): number;
  83689. /**
  83690. * Returns a positive integer : the total number of indices in this mesh geometry.
  83691. * @returns the numner of indices or zero if the mesh has no geometry.
  83692. */
  83693. getTotalIndices(): number;
  83694. /**
  83695. * The source mesh of the instance
  83696. */
  83697. readonly sourceMesh: Mesh;
  83698. /**
  83699. * Is this node ready to be used/rendered
  83700. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83701. * @return {boolean} is it ready
  83702. */
  83703. isReady(completeCheck?: boolean): boolean;
  83704. /**
  83705. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83706. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83707. * @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.
  83708. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83709. */
  83710. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83711. /**
  83712. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83713. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83714. * The `data` are either a numeric array either a Float32Array.
  83715. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83716. * 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).
  83717. * Note that a new underlying VertexBuffer object is created each call.
  83718. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83719. *
  83720. * Possible `kind` values :
  83721. * - VertexBuffer.PositionKind
  83722. * - VertexBuffer.UVKind
  83723. * - VertexBuffer.UV2Kind
  83724. * - VertexBuffer.UV3Kind
  83725. * - VertexBuffer.UV4Kind
  83726. * - VertexBuffer.UV5Kind
  83727. * - VertexBuffer.UV6Kind
  83728. * - VertexBuffer.ColorKind
  83729. * - VertexBuffer.MatricesIndicesKind
  83730. * - VertexBuffer.MatricesIndicesExtraKind
  83731. * - VertexBuffer.MatricesWeightsKind
  83732. * - VertexBuffer.MatricesWeightsExtraKind
  83733. *
  83734. * Returns the Mesh.
  83735. */
  83736. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83737. /**
  83738. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83739. * If the mesh has no geometry, it is simply returned as it is.
  83740. * The `data` are either a numeric array either a Float32Array.
  83741. * No new underlying VertexBuffer object is created.
  83742. * 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.
  83743. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83744. *
  83745. * Possible `kind` values :
  83746. * - VertexBuffer.PositionKind
  83747. * - VertexBuffer.UVKind
  83748. * - VertexBuffer.UV2Kind
  83749. * - VertexBuffer.UV3Kind
  83750. * - VertexBuffer.UV4Kind
  83751. * - VertexBuffer.UV5Kind
  83752. * - VertexBuffer.UV6Kind
  83753. * - VertexBuffer.ColorKind
  83754. * - VertexBuffer.MatricesIndicesKind
  83755. * - VertexBuffer.MatricesIndicesExtraKind
  83756. * - VertexBuffer.MatricesWeightsKind
  83757. * - VertexBuffer.MatricesWeightsExtraKind
  83758. *
  83759. * Returns the Mesh.
  83760. */
  83761. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83762. /**
  83763. * Sets the mesh indices.
  83764. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83765. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83766. * This method creates a new index buffer each call.
  83767. * Returns the Mesh.
  83768. */
  83769. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83770. /**
  83771. * Boolean : True if the mesh owns the requested kind of data.
  83772. */
  83773. isVerticesDataPresent(kind: string): boolean;
  83774. /**
  83775. * Returns an array of indices (IndicesArray).
  83776. */
  83777. getIndices(): Nullable<IndicesArray>;
  83778. readonly _positions: Nullable<Vector3[]>;
  83779. /**
  83780. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83781. * This means the mesh underlying bounding box and sphere are recomputed.
  83782. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83783. * @returns the current mesh
  83784. */
  83785. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83786. /** @hidden */
  83787. _preActivate(): InstancedMesh;
  83788. /** @hidden */
  83789. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83790. /** @hidden */
  83791. _postActivate(): void;
  83792. getWorldMatrix(): Matrix;
  83793. readonly isAnInstance: boolean;
  83794. /**
  83795. * Returns the current associated LOD AbstractMesh.
  83796. */
  83797. getLOD(camera: Camera): AbstractMesh;
  83798. /** @hidden */
  83799. _syncSubMeshes(): InstancedMesh;
  83800. /** @hidden */
  83801. _generatePointsArray(): boolean;
  83802. /**
  83803. * Creates a new InstancedMesh from the current mesh.
  83804. * - name (string) : the cloned mesh name
  83805. * - newParent (optional Node) : the optional Node to parent the clone to.
  83806. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83807. *
  83808. * Returns the clone.
  83809. */
  83810. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83811. /**
  83812. * Disposes the InstancedMesh.
  83813. * Returns nothing.
  83814. */
  83815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83816. }
  83817. }
  83818. declare module BABYLON {
  83819. /**
  83820. * Defines the options associated with the creation of a shader material.
  83821. */
  83822. export interface IShaderMaterialOptions {
  83823. /**
  83824. * Does the material work in alpha blend mode
  83825. */
  83826. needAlphaBlending: boolean;
  83827. /**
  83828. * Does the material work in alpha test mode
  83829. */
  83830. needAlphaTesting: boolean;
  83831. /**
  83832. * The list of attribute names used in the shader
  83833. */
  83834. attributes: string[];
  83835. /**
  83836. * The list of unifrom names used in the shader
  83837. */
  83838. uniforms: string[];
  83839. /**
  83840. * The list of UBO names used in the shader
  83841. */
  83842. uniformBuffers: string[];
  83843. /**
  83844. * The list of sampler names used in the shader
  83845. */
  83846. samplers: string[];
  83847. /**
  83848. * The list of defines used in the shader
  83849. */
  83850. defines: string[];
  83851. }
  83852. /**
  83853. * 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.
  83854. *
  83855. * This returned material effects how the mesh will look based on the code in the shaders.
  83856. *
  83857. * @see http://doc.babylonjs.com/how_to/shader_material
  83858. */
  83859. export class ShaderMaterial extends Material {
  83860. private _shaderPath;
  83861. private _options;
  83862. private _textures;
  83863. private _textureArrays;
  83864. private _floats;
  83865. private _ints;
  83866. private _floatsArrays;
  83867. private _colors3;
  83868. private _colors3Arrays;
  83869. private _colors4;
  83870. private _colors4Arrays;
  83871. private _vectors2;
  83872. private _vectors3;
  83873. private _vectors4;
  83874. private _matrices;
  83875. private _matrices3x3;
  83876. private _matrices2x2;
  83877. private _vectors2Arrays;
  83878. private _vectors3Arrays;
  83879. private _vectors4Arrays;
  83880. private _cachedWorldViewMatrix;
  83881. private _cachedWorldViewProjectionMatrix;
  83882. private _renderId;
  83883. /**
  83884. * Instantiate a new shader material.
  83885. * 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.
  83886. * This returned material effects how the mesh will look based on the code in the shaders.
  83887. * @see http://doc.babylonjs.com/how_to/shader_material
  83888. * @param name Define the name of the material in the scene
  83889. * @param scene Define the scene the material belongs to
  83890. * @param shaderPath Defines the route to the shader code in one of three ways:
  83891. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83892. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83893. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83894. * @param options Define the options used to create the shader
  83895. */
  83896. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83897. /**
  83898. * Gets the options used to compile the shader.
  83899. * They can be modified to trigger a new compilation
  83900. */
  83901. readonly options: IShaderMaterialOptions;
  83902. /**
  83903. * Gets the current class name of the material e.g. "ShaderMaterial"
  83904. * Mainly use in serialization.
  83905. * @returns the class name
  83906. */
  83907. getClassName(): string;
  83908. /**
  83909. * Specifies if the material will require alpha blending
  83910. * @returns a boolean specifying if alpha blending is needed
  83911. */
  83912. needAlphaBlending(): boolean;
  83913. /**
  83914. * Specifies if this material should be rendered in alpha test mode
  83915. * @returns a boolean specifying if an alpha test is needed.
  83916. */
  83917. needAlphaTesting(): boolean;
  83918. private _checkUniform;
  83919. /**
  83920. * Set a texture in the shader.
  83921. * @param name Define the name of the uniform samplers as defined in the shader
  83922. * @param texture Define the texture to bind to this sampler
  83923. * @return the material itself allowing "fluent" like uniform updates
  83924. */
  83925. setTexture(name: string, texture: Texture): ShaderMaterial;
  83926. /**
  83927. * Set a texture array in the shader.
  83928. * @param name Define the name of the uniform sampler array as defined in the shader
  83929. * @param textures Define the list of textures to bind to this sampler
  83930. * @return the material itself allowing "fluent" like uniform updates
  83931. */
  83932. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83933. /**
  83934. * Set a float in the shader.
  83935. * @param name Define the name of the uniform as defined in the shader
  83936. * @param value Define the value to give to the uniform
  83937. * @return the material itself allowing "fluent" like uniform updates
  83938. */
  83939. setFloat(name: string, value: number): ShaderMaterial;
  83940. /**
  83941. * Set a int in the shader.
  83942. * @param name Define the name of the uniform as defined in the shader
  83943. * @param value Define the value to give to the uniform
  83944. * @return the material itself allowing "fluent" like uniform updates
  83945. */
  83946. setInt(name: string, value: number): ShaderMaterial;
  83947. /**
  83948. * Set an array of floats in the shader.
  83949. * @param name Define the name of the uniform as defined in the shader
  83950. * @param value Define the value to give to the uniform
  83951. * @return the material itself allowing "fluent" like uniform updates
  83952. */
  83953. setFloats(name: string, value: number[]): ShaderMaterial;
  83954. /**
  83955. * Set a vec3 in the shader from a Color3.
  83956. * @param name Define the name of the uniform as defined in the shader
  83957. * @param value Define the value to give to the uniform
  83958. * @return the material itself allowing "fluent" like uniform updates
  83959. */
  83960. setColor3(name: string, value: Color3): ShaderMaterial;
  83961. /**
  83962. * Set a vec3 array in the shader from a Color3 array.
  83963. * @param name Define the name of the uniform as defined in the shader
  83964. * @param value Define the value to give to the uniform
  83965. * @return the material itself allowing "fluent" like uniform updates
  83966. */
  83967. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83968. /**
  83969. * Set a vec4 in the shader from a Color4.
  83970. * @param name Define the name of the uniform as defined in the shader
  83971. * @param value Define the value to give to the uniform
  83972. * @return the material itself allowing "fluent" like uniform updates
  83973. */
  83974. setColor4(name: string, value: Color4): ShaderMaterial;
  83975. /**
  83976. * Set a vec4 array in the shader from a Color4 array.
  83977. * @param name Define the name of the uniform as defined in the shader
  83978. * @param value Define the value to give to the uniform
  83979. * @return the material itself allowing "fluent" like uniform updates
  83980. */
  83981. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83982. /**
  83983. * Set a vec2 in the shader from a Vector2.
  83984. * @param name Define the name of the uniform as defined in the shader
  83985. * @param value Define the value to give to the uniform
  83986. * @return the material itself allowing "fluent" like uniform updates
  83987. */
  83988. setVector2(name: string, value: Vector2): ShaderMaterial;
  83989. /**
  83990. * Set a vec3 in the shader from a Vector3.
  83991. * @param name Define the name of the uniform as defined in the shader
  83992. * @param value Define the value to give to the uniform
  83993. * @return the material itself allowing "fluent" like uniform updates
  83994. */
  83995. setVector3(name: string, value: Vector3): ShaderMaterial;
  83996. /**
  83997. * Set a vec4 in the shader from a Vector4.
  83998. * @param name Define the name of the uniform as defined in the shader
  83999. * @param value Define the value to give to the uniform
  84000. * @return the material itself allowing "fluent" like uniform updates
  84001. */
  84002. setVector4(name: string, value: Vector4): ShaderMaterial;
  84003. /**
  84004. * Set a mat4 in the shader from a Matrix.
  84005. * @param name Define the name of the uniform as defined in the shader
  84006. * @param value Define the value to give to the uniform
  84007. * @return the material itself allowing "fluent" like uniform updates
  84008. */
  84009. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84010. /**
  84011. * Set a mat3 in the shader from a Float32Array.
  84012. * @param name Define the name of the uniform as defined in the shader
  84013. * @param value Define the value to give to the uniform
  84014. * @return the material itself allowing "fluent" like uniform updates
  84015. */
  84016. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84017. /**
  84018. * Set a mat2 in the shader from a Float32Array.
  84019. * @param name Define the name of the uniform as defined in the shader
  84020. * @param value Define the value to give to the uniform
  84021. * @return the material itself allowing "fluent" like uniform updates
  84022. */
  84023. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84024. /**
  84025. * Set a vec2 array in the shader from a number array.
  84026. * @param name Define the name of the uniform as defined in the shader
  84027. * @param value Define the value to give to the uniform
  84028. * @return the material itself allowing "fluent" like uniform updates
  84029. */
  84030. setArray2(name: string, value: number[]): ShaderMaterial;
  84031. /**
  84032. * Set a vec3 array in the shader from a number array.
  84033. * @param name Define the name of the uniform as defined in the shader
  84034. * @param value Define the value to give to the uniform
  84035. * @return the material itself allowing "fluent" like uniform updates
  84036. */
  84037. setArray3(name: string, value: number[]): ShaderMaterial;
  84038. /**
  84039. * Set a vec4 array in the shader from a number array.
  84040. * @param name Define the name of the uniform as defined in the shader
  84041. * @param value Define the value to give to the uniform
  84042. * @return the material itself allowing "fluent" like uniform updates
  84043. */
  84044. setArray4(name: string, value: number[]): ShaderMaterial;
  84045. private _checkCache;
  84046. /**
  84047. * Specifies that the submesh is ready to be used
  84048. * @param mesh defines the mesh to check
  84049. * @param subMesh defines which submesh to check
  84050. * @param useInstances specifies that instances should be used
  84051. * @returns a boolean indicating that the submesh is ready or not
  84052. */
  84053. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84054. /**
  84055. * Checks if the material is ready to render the requested mesh
  84056. * @param mesh Define the mesh to render
  84057. * @param useInstances Define whether or not the material is used with instances
  84058. * @returns true if ready, otherwise false
  84059. */
  84060. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84061. /**
  84062. * Binds the world matrix to the material
  84063. * @param world defines the world transformation matrix
  84064. */
  84065. bindOnlyWorldMatrix(world: Matrix): void;
  84066. /**
  84067. * Binds the material to the mesh
  84068. * @param world defines the world transformation matrix
  84069. * @param mesh defines the mesh to bind the material to
  84070. */
  84071. bind(world: Matrix, mesh?: Mesh): void;
  84072. /**
  84073. * Gets the active textures from the material
  84074. * @returns an array of textures
  84075. */
  84076. getActiveTextures(): BaseTexture[];
  84077. /**
  84078. * Specifies if the material uses a texture
  84079. * @param texture defines the texture to check against the material
  84080. * @returns a boolean specifying if the material uses the texture
  84081. */
  84082. hasTexture(texture: BaseTexture): boolean;
  84083. /**
  84084. * Makes a duplicate of the material, and gives it a new name
  84085. * @param name defines the new name for the duplicated material
  84086. * @returns the cloned material
  84087. */
  84088. clone(name: string): ShaderMaterial;
  84089. /**
  84090. * Disposes the material
  84091. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84092. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84093. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84094. */
  84095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84096. /**
  84097. * Serializes this material in a JSON representation
  84098. * @returns the serialized material object
  84099. */
  84100. serialize(): any;
  84101. /**
  84102. * Creates a shader material from parsed shader material data
  84103. * @param source defines the JSON represnetation of the material
  84104. * @param scene defines the hosting scene
  84105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84106. * @returns a new material
  84107. */
  84108. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84109. }
  84110. }
  84111. declare module BABYLON {
  84112. /** @hidden */
  84113. export var colorPixelShader: {
  84114. name: string;
  84115. shader: string;
  84116. };
  84117. }
  84118. declare module BABYLON {
  84119. /** @hidden */
  84120. export var colorVertexShader: {
  84121. name: string;
  84122. shader: string;
  84123. };
  84124. }
  84125. declare module BABYLON {
  84126. /**
  84127. * Line mesh
  84128. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84129. */
  84130. export class LinesMesh extends Mesh {
  84131. /**
  84132. * If vertex color should be applied to the mesh
  84133. */
  84134. readonly useVertexColor?: boolean | undefined;
  84135. /**
  84136. * If vertex alpha should be applied to the mesh
  84137. */
  84138. readonly useVertexAlpha?: boolean | undefined;
  84139. /**
  84140. * Color of the line (Default: White)
  84141. */
  84142. color: Color3;
  84143. /**
  84144. * Alpha of the line (Default: 1)
  84145. */
  84146. alpha: number;
  84147. /**
  84148. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84149. * This margin is expressed in world space coordinates, so its value may vary.
  84150. * Default value is 0.1
  84151. */
  84152. intersectionThreshold: number;
  84153. private _colorShader;
  84154. private color4;
  84155. /**
  84156. * Creates a new LinesMesh
  84157. * @param name defines the name
  84158. * @param scene defines the hosting scene
  84159. * @param parent defines the parent mesh if any
  84160. * @param source defines the optional source LinesMesh used to clone data from
  84161. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84162. * When false, achieved by calling a clone(), also passing False.
  84163. * This will make creation of children, recursive.
  84164. * @param useVertexColor defines if this LinesMesh supports vertex color
  84165. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84166. */
  84167. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84168. /**
  84169. * If vertex color should be applied to the mesh
  84170. */
  84171. useVertexColor?: boolean | undefined,
  84172. /**
  84173. * If vertex alpha should be applied to the mesh
  84174. */
  84175. useVertexAlpha?: boolean | undefined);
  84176. private _addClipPlaneDefine;
  84177. private _removeClipPlaneDefine;
  84178. isReady(): boolean;
  84179. /**
  84180. * Returns the string "LineMesh"
  84181. */
  84182. getClassName(): string;
  84183. /**
  84184. * @hidden
  84185. */
  84186. /**
  84187. * @hidden
  84188. */
  84189. material: Material;
  84190. /**
  84191. * @hidden
  84192. */
  84193. readonly checkCollisions: boolean;
  84194. /** @hidden */
  84195. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84196. /** @hidden */
  84197. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84198. /**
  84199. * Disposes of the line mesh
  84200. * @param doNotRecurse If children should be disposed
  84201. */
  84202. dispose(doNotRecurse?: boolean): void;
  84203. /**
  84204. * Returns a new LineMesh object cloned from the current one.
  84205. */
  84206. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84207. /**
  84208. * Creates a new InstancedLinesMesh object from the mesh model.
  84209. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84210. * @param name defines the name of the new instance
  84211. * @returns a new InstancedLinesMesh
  84212. */
  84213. createInstance(name: string): InstancedLinesMesh;
  84214. }
  84215. /**
  84216. * Creates an instance based on a source LinesMesh
  84217. */
  84218. export class InstancedLinesMesh extends InstancedMesh {
  84219. /**
  84220. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84221. * This margin is expressed in world space coordinates, so its value may vary.
  84222. * Initilized with the intersectionThreshold value of the source LinesMesh
  84223. */
  84224. intersectionThreshold: number;
  84225. constructor(name: string, source: LinesMesh);
  84226. /**
  84227. * Returns the string "InstancedLinesMesh".
  84228. */
  84229. getClassName(): string;
  84230. }
  84231. }
  84232. declare module BABYLON {
  84233. /** @hidden */
  84234. export var linePixelShader: {
  84235. name: string;
  84236. shader: string;
  84237. };
  84238. }
  84239. declare module BABYLON {
  84240. /** @hidden */
  84241. export var lineVertexShader: {
  84242. name: string;
  84243. shader: string;
  84244. };
  84245. }
  84246. declare module BABYLON {
  84247. interface AbstractMesh {
  84248. /**
  84249. * Gets the edgesRenderer associated with the mesh
  84250. */
  84251. edgesRenderer: Nullable<EdgesRenderer>;
  84252. }
  84253. interface LinesMesh {
  84254. /**
  84255. * Enables the edge rendering mode on the mesh.
  84256. * This mode makes the mesh edges visible
  84257. * @param epsilon defines the maximal distance between two angles to detect a face
  84258. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84259. * @returns the currentAbstractMesh
  84260. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84261. */
  84262. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84263. }
  84264. interface InstancedLinesMesh {
  84265. /**
  84266. * Enables the edge rendering mode on the mesh.
  84267. * This mode makes the mesh edges visible
  84268. * @param epsilon defines the maximal distance between two angles to detect a face
  84269. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84270. * @returns the current InstancedLinesMesh
  84271. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84272. */
  84273. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84274. }
  84275. /**
  84276. * Defines the minimum contract an Edges renderer should follow.
  84277. */
  84278. export interface IEdgesRenderer extends IDisposable {
  84279. /**
  84280. * Gets or sets a boolean indicating if the edgesRenderer is active
  84281. */
  84282. isEnabled: boolean;
  84283. /**
  84284. * Renders the edges of the attached mesh,
  84285. */
  84286. render(): void;
  84287. /**
  84288. * Checks wether or not the edges renderer is ready to render.
  84289. * @return true if ready, otherwise false.
  84290. */
  84291. isReady(): boolean;
  84292. }
  84293. /**
  84294. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84295. */
  84296. export class EdgesRenderer implements IEdgesRenderer {
  84297. /**
  84298. * Define the size of the edges with an orthographic camera
  84299. */
  84300. edgesWidthScalerForOrthographic: number;
  84301. /**
  84302. * Define the size of the edges with a perspective camera
  84303. */
  84304. edgesWidthScalerForPerspective: number;
  84305. protected _source: AbstractMesh;
  84306. protected _linesPositions: number[];
  84307. protected _linesNormals: number[];
  84308. protected _linesIndices: number[];
  84309. protected _epsilon: number;
  84310. protected _indicesCount: number;
  84311. protected _lineShader: ShaderMaterial;
  84312. protected _ib: DataBuffer;
  84313. protected _buffers: {
  84314. [key: string]: Nullable<VertexBuffer>;
  84315. };
  84316. protected _checkVerticesInsteadOfIndices: boolean;
  84317. private _meshRebuildObserver;
  84318. private _meshDisposeObserver;
  84319. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84320. isEnabled: boolean;
  84321. /**
  84322. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84323. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84324. * @param source Mesh used to create edges
  84325. * @param epsilon sum of angles in adjacency to check for edge
  84326. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84327. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84328. */
  84329. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84330. protected _prepareRessources(): void;
  84331. /** @hidden */
  84332. _rebuild(): void;
  84333. /**
  84334. * Releases the required resources for the edges renderer
  84335. */
  84336. dispose(): void;
  84337. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84338. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84339. /**
  84340. * Checks if the pair of p0 and p1 is en edge
  84341. * @param faceIndex
  84342. * @param edge
  84343. * @param faceNormals
  84344. * @param p0
  84345. * @param p1
  84346. * @private
  84347. */
  84348. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84349. /**
  84350. * push line into the position, normal and index buffer
  84351. * @protected
  84352. */
  84353. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84354. /**
  84355. * Generates lines edges from adjacencjes
  84356. * @private
  84357. */
  84358. _generateEdgesLines(): void;
  84359. /**
  84360. * Checks wether or not the edges renderer is ready to render.
  84361. * @return true if ready, otherwise false.
  84362. */
  84363. isReady(): boolean;
  84364. /**
  84365. * Renders the edges of the attached mesh,
  84366. */
  84367. render(): void;
  84368. }
  84369. /**
  84370. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84371. */
  84372. export class LineEdgesRenderer extends EdgesRenderer {
  84373. /**
  84374. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84375. * @param source LineMesh used to generate edges
  84376. * @param epsilon not important (specified angle for edge detection)
  84377. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84378. */
  84379. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84380. /**
  84381. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84382. */
  84383. _generateEdgesLines(): void;
  84384. }
  84385. }
  84386. declare module BABYLON {
  84387. /**
  84388. * This represents the object necessary to create a rendering group.
  84389. * This is exclusively used and created by the rendering manager.
  84390. * To modify the behavior, you use the available helpers in your scene or meshes.
  84391. * @hidden
  84392. */
  84393. export class RenderingGroup {
  84394. index: number;
  84395. private static _zeroVector;
  84396. private _scene;
  84397. private _opaqueSubMeshes;
  84398. private _transparentSubMeshes;
  84399. private _alphaTestSubMeshes;
  84400. private _depthOnlySubMeshes;
  84401. private _particleSystems;
  84402. private _spriteManagers;
  84403. private _opaqueSortCompareFn;
  84404. private _alphaTestSortCompareFn;
  84405. private _transparentSortCompareFn;
  84406. private _renderOpaque;
  84407. private _renderAlphaTest;
  84408. private _renderTransparent;
  84409. /** @hidden */
  84410. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84411. onBeforeTransparentRendering: () => void;
  84412. /**
  84413. * Set the opaque sort comparison function.
  84414. * If null the sub meshes will be render in the order they were created
  84415. */
  84416. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84417. /**
  84418. * Set the alpha test sort comparison function.
  84419. * If null the sub meshes will be render in the order they were created
  84420. */
  84421. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84422. /**
  84423. * Set the transparent sort comparison function.
  84424. * If null the sub meshes will be render in the order they were created
  84425. */
  84426. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84427. /**
  84428. * Creates a new rendering group.
  84429. * @param index The rendering group index
  84430. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84431. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84432. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84433. */
  84434. 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>);
  84435. /**
  84436. * Render all the sub meshes contained in the group.
  84437. * @param customRenderFunction Used to override the default render behaviour of the group.
  84438. * @returns true if rendered some submeshes.
  84439. */
  84440. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84441. /**
  84442. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84443. * @param subMeshes The submeshes to render
  84444. */
  84445. private renderOpaqueSorted;
  84446. /**
  84447. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84448. * @param subMeshes The submeshes to render
  84449. */
  84450. private renderAlphaTestSorted;
  84451. /**
  84452. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84453. * @param subMeshes The submeshes to render
  84454. */
  84455. private renderTransparentSorted;
  84456. /**
  84457. * Renders the submeshes in a specified order.
  84458. * @param subMeshes The submeshes to sort before render
  84459. * @param sortCompareFn The comparison function use to sort
  84460. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84461. * @param transparent Specifies to activate blending if true
  84462. */
  84463. private static renderSorted;
  84464. /**
  84465. * Renders the submeshes in the order they were dispatched (no sort applied).
  84466. * @param subMeshes The submeshes to render
  84467. */
  84468. private static renderUnsorted;
  84469. /**
  84470. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84471. * are rendered back to front if in the same alpha index.
  84472. *
  84473. * @param a The first submesh
  84474. * @param b The second submesh
  84475. * @returns The result of the comparison
  84476. */
  84477. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84478. /**
  84479. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84480. * are rendered back to front.
  84481. *
  84482. * @param a The first submesh
  84483. * @param b The second submesh
  84484. * @returns The result of the comparison
  84485. */
  84486. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84487. /**
  84488. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84489. * are rendered front to back (prevent overdraw).
  84490. *
  84491. * @param a The first submesh
  84492. * @param b The second submesh
  84493. * @returns The result of the comparison
  84494. */
  84495. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84496. /**
  84497. * Resets the different lists of submeshes to prepare a new frame.
  84498. */
  84499. prepare(): void;
  84500. dispose(): void;
  84501. /**
  84502. * Inserts the submesh in its correct queue depending on its material.
  84503. * @param subMesh The submesh to dispatch
  84504. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84505. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84506. */
  84507. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84508. dispatchSprites(spriteManager: ISpriteManager): void;
  84509. dispatchParticles(particleSystem: IParticleSystem): void;
  84510. private _renderParticles;
  84511. private _renderSprites;
  84512. }
  84513. }
  84514. declare module BABYLON {
  84515. /**
  84516. * Interface describing the different options available in the rendering manager
  84517. * regarding Auto Clear between groups.
  84518. */
  84519. export interface IRenderingManagerAutoClearSetup {
  84520. /**
  84521. * Defines whether or not autoclear is enable.
  84522. */
  84523. autoClear: boolean;
  84524. /**
  84525. * Defines whether or not to autoclear the depth buffer.
  84526. */
  84527. depth: boolean;
  84528. /**
  84529. * Defines whether or not to autoclear the stencil buffer.
  84530. */
  84531. stencil: boolean;
  84532. }
  84533. /**
  84534. * This class is used by the onRenderingGroupObservable
  84535. */
  84536. export class RenderingGroupInfo {
  84537. /**
  84538. * The Scene that being rendered
  84539. */
  84540. scene: Scene;
  84541. /**
  84542. * The camera currently used for the rendering pass
  84543. */
  84544. camera: Nullable<Camera>;
  84545. /**
  84546. * The ID of the renderingGroup being processed
  84547. */
  84548. renderingGroupId: number;
  84549. }
  84550. /**
  84551. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84552. * It is enable to manage the different groups as well as the different necessary sort functions.
  84553. * This should not be used directly aside of the few static configurations
  84554. */
  84555. export class RenderingManager {
  84556. /**
  84557. * The max id used for rendering groups (not included)
  84558. */
  84559. static MAX_RENDERINGGROUPS: number;
  84560. /**
  84561. * The min id used for rendering groups (included)
  84562. */
  84563. static MIN_RENDERINGGROUPS: number;
  84564. /**
  84565. * Used to globally prevent autoclearing scenes.
  84566. */
  84567. static AUTOCLEAR: boolean;
  84568. /**
  84569. * @hidden
  84570. */
  84571. _useSceneAutoClearSetup: boolean;
  84572. private _scene;
  84573. private _renderingGroups;
  84574. private _depthStencilBufferAlreadyCleaned;
  84575. private _autoClearDepthStencil;
  84576. private _customOpaqueSortCompareFn;
  84577. private _customAlphaTestSortCompareFn;
  84578. private _customTransparentSortCompareFn;
  84579. private _renderingGroupInfo;
  84580. /**
  84581. * Instantiates a new rendering group for a particular scene
  84582. * @param scene Defines the scene the groups belongs to
  84583. */
  84584. constructor(scene: Scene);
  84585. private _clearDepthStencilBuffer;
  84586. /**
  84587. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84588. * @hidden
  84589. */
  84590. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84591. /**
  84592. * Resets the different information of the group to prepare a new frame
  84593. * @hidden
  84594. */
  84595. reset(): void;
  84596. /**
  84597. * Dispose and release the group and its associated resources.
  84598. * @hidden
  84599. */
  84600. dispose(): void;
  84601. /**
  84602. * Clear the info related to rendering groups preventing retention points during dispose.
  84603. */
  84604. freeRenderingGroups(): void;
  84605. private _prepareRenderingGroup;
  84606. /**
  84607. * Add a sprite manager to the rendering manager in order to render it this frame.
  84608. * @param spriteManager Define the sprite manager to render
  84609. */
  84610. dispatchSprites(spriteManager: ISpriteManager): void;
  84611. /**
  84612. * Add a particle system to the rendering manager in order to render it this frame.
  84613. * @param particleSystem Define the particle system to render
  84614. */
  84615. dispatchParticles(particleSystem: IParticleSystem): void;
  84616. /**
  84617. * Add a submesh to the manager in order to render it this frame
  84618. * @param subMesh The submesh to dispatch
  84619. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84620. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84621. */
  84622. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84623. /**
  84624. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84625. * This allowed control for front to back rendering or reversly depending of the special needs.
  84626. *
  84627. * @param renderingGroupId The rendering group id corresponding to its index
  84628. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84629. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84630. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84631. */
  84632. 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;
  84633. /**
  84634. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84635. *
  84636. * @param renderingGroupId The rendering group id corresponding to its index
  84637. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84638. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84639. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84640. */
  84641. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84642. /**
  84643. * Gets the current auto clear configuration for one rendering group of the rendering
  84644. * manager.
  84645. * @param index the rendering group index to get the information for
  84646. * @returns The auto clear setup for the requested rendering group
  84647. */
  84648. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84649. }
  84650. }
  84651. declare module BABYLON {
  84652. /**
  84653. * This Helps creating a texture that will be created from a camera in your scene.
  84654. * It is basically a dynamic texture that could be used to create special effects for instance.
  84655. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84656. */
  84657. export class RenderTargetTexture extends Texture {
  84658. isCube: boolean;
  84659. /**
  84660. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84661. */
  84662. static readonly REFRESHRATE_RENDER_ONCE: number;
  84663. /**
  84664. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84665. */
  84666. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84667. /**
  84668. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84669. * the central point of your effect and can save a lot of performances.
  84670. */
  84671. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84672. /**
  84673. * Use this predicate to dynamically define the list of mesh you want to render.
  84674. * If set, the renderList property will be overwritten.
  84675. */
  84676. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84677. private _renderList;
  84678. /**
  84679. * Use this list to define the list of mesh you want to render.
  84680. */
  84681. renderList: Nullable<Array<AbstractMesh>>;
  84682. private _hookArray;
  84683. /**
  84684. * Define if particles should be rendered in your texture.
  84685. */
  84686. renderParticles: boolean;
  84687. /**
  84688. * Define if sprites should be rendered in your texture.
  84689. */
  84690. renderSprites: boolean;
  84691. /**
  84692. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84693. */
  84694. coordinatesMode: number;
  84695. /**
  84696. * Define the camera used to render the texture.
  84697. */
  84698. activeCamera: Nullable<Camera>;
  84699. /**
  84700. * Override the render function of the texture with your own one.
  84701. */
  84702. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84703. /**
  84704. * Define if camera post processes should be use while rendering the texture.
  84705. */
  84706. useCameraPostProcesses: boolean;
  84707. /**
  84708. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84709. */
  84710. ignoreCameraViewport: boolean;
  84711. private _postProcessManager;
  84712. private _postProcesses;
  84713. private _resizeObserver;
  84714. /**
  84715. * An event triggered when the texture is unbind.
  84716. */
  84717. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84718. /**
  84719. * An event triggered when the texture is unbind.
  84720. */
  84721. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84722. private _onAfterUnbindObserver;
  84723. /**
  84724. * Set a after unbind callback in the texture.
  84725. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84726. */
  84727. onAfterUnbind: () => void;
  84728. /**
  84729. * An event triggered before rendering the texture
  84730. */
  84731. onBeforeRenderObservable: Observable<number>;
  84732. private _onBeforeRenderObserver;
  84733. /**
  84734. * Set a before render callback in the texture.
  84735. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84736. */
  84737. onBeforeRender: (faceIndex: number) => void;
  84738. /**
  84739. * An event triggered after rendering the texture
  84740. */
  84741. onAfterRenderObservable: Observable<number>;
  84742. private _onAfterRenderObserver;
  84743. /**
  84744. * Set a after render callback in the texture.
  84745. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84746. */
  84747. onAfterRender: (faceIndex: number) => void;
  84748. /**
  84749. * An event triggered after the texture clear
  84750. */
  84751. onClearObservable: Observable<Engine>;
  84752. private _onClearObserver;
  84753. /**
  84754. * Set a clear callback in the texture.
  84755. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84756. */
  84757. onClear: (Engine: Engine) => void;
  84758. /**
  84759. * An event triggered when the texture is resized.
  84760. */
  84761. onResizeObservable: Observable<RenderTargetTexture>;
  84762. /**
  84763. * Define the clear color of the Render Target if it should be different from the scene.
  84764. */
  84765. clearColor: Color4;
  84766. protected _size: number | {
  84767. width: number;
  84768. height: number;
  84769. };
  84770. protected _initialSizeParameter: number | {
  84771. width: number;
  84772. height: number;
  84773. } | {
  84774. ratio: number;
  84775. };
  84776. protected _sizeRatio: Nullable<number>;
  84777. /** @hidden */
  84778. _generateMipMaps: boolean;
  84779. protected _renderingManager: RenderingManager;
  84780. /** @hidden */
  84781. _waitingRenderList: string[];
  84782. protected _doNotChangeAspectRatio: boolean;
  84783. protected _currentRefreshId: number;
  84784. protected _refreshRate: number;
  84785. protected _textureMatrix: Matrix;
  84786. protected _samples: number;
  84787. protected _renderTargetOptions: RenderTargetCreationOptions;
  84788. /**
  84789. * Gets render target creation options that were used.
  84790. */
  84791. readonly renderTargetOptions: RenderTargetCreationOptions;
  84792. protected _engine: Engine;
  84793. protected _onRatioRescale(): void;
  84794. /**
  84795. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84796. * It must define where the camera used to render the texture is set
  84797. */
  84798. boundingBoxPosition: Vector3;
  84799. private _boundingBoxSize;
  84800. /**
  84801. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84802. * When defined, the cubemap will switch to local mode
  84803. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84804. * @example https://www.babylonjs-playground.com/#RNASML
  84805. */
  84806. boundingBoxSize: Vector3;
  84807. /**
  84808. * In case the RTT has been created with a depth texture, get the associated
  84809. * depth texture.
  84810. * Otherwise, return null.
  84811. */
  84812. depthStencilTexture: Nullable<InternalTexture>;
  84813. /**
  84814. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84815. * or used a shadow, depth texture...
  84816. * @param name The friendly name of the texture
  84817. * @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)
  84818. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84819. * @param generateMipMaps True if mip maps need to be generated after render.
  84820. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84821. * @param type The type of the buffer in the RTT (int, half float, float...)
  84822. * @param isCube True if a cube texture needs to be created
  84823. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84824. * @param generateDepthBuffer True to generate a depth buffer
  84825. * @param generateStencilBuffer True to generate a stencil buffer
  84826. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84827. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84828. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84829. */
  84830. constructor(name: string, size: number | {
  84831. width: number;
  84832. height: number;
  84833. } | {
  84834. ratio: number;
  84835. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84836. /**
  84837. * Creates a depth stencil texture.
  84838. * This is only available in WebGL 2 or with the depth texture extension available.
  84839. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84840. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84841. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84842. */
  84843. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84844. private _processSizeParameter;
  84845. /**
  84846. * Define the number of samples to use in case of MSAA.
  84847. * It defaults to one meaning no MSAA has been enabled.
  84848. */
  84849. samples: number;
  84850. /**
  84851. * Resets the refresh counter of the texture and start bak from scratch.
  84852. * Could be useful to regenerate the texture if it is setup to render only once.
  84853. */
  84854. resetRefreshCounter(): void;
  84855. /**
  84856. * Define the refresh rate of the texture or the rendering frequency.
  84857. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84858. */
  84859. refreshRate: number;
  84860. /**
  84861. * Adds a post process to the render target rendering passes.
  84862. * @param postProcess define the post process to add
  84863. */
  84864. addPostProcess(postProcess: PostProcess): void;
  84865. /**
  84866. * Clear all the post processes attached to the render target
  84867. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84868. */
  84869. clearPostProcesses(dispose?: boolean): void;
  84870. /**
  84871. * Remove one of the post process from the list of attached post processes to the texture
  84872. * @param postProcess define the post process to remove from the list
  84873. */
  84874. removePostProcess(postProcess: PostProcess): void;
  84875. /** @hidden */
  84876. _shouldRender(): boolean;
  84877. /**
  84878. * Gets the actual render size of the texture.
  84879. * @returns the width of the render size
  84880. */
  84881. getRenderSize(): number;
  84882. /**
  84883. * Gets the actual render width of the texture.
  84884. * @returns the width of the render size
  84885. */
  84886. getRenderWidth(): number;
  84887. /**
  84888. * Gets the actual render height of the texture.
  84889. * @returns the height of the render size
  84890. */
  84891. getRenderHeight(): number;
  84892. /**
  84893. * Get if the texture can be rescaled or not.
  84894. */
  84895. readonly canRescale: boolean;
  84896. /**
  84897. * Resize the texture using a ratio.
  84898. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84899. */
  84900. scale(ratio: number): void;
  84901. /**
  84902. * Get the texture reflection matrix used to rotate/transform the reflection.
  84903. * @returns the reflection matrix
  84904. */
  84905. getReflectionTextureMatrix(): Matrix;
  84906. /**
  84907. * Resize the texture to a new desired size.
  84908. * Be carrefull as it will recreate all the data in the new texture.
  84909. * @param size Define the new size. It can be:
  84910. * - a number for squared texture,
  84911. * - an object containing { width: number, height: number }
  84912. * - or an object containing a ratio { ratio: number }
  84913. */
  84914. resize(size: number | {
  84915. width: number;
  84916. height: number;
  84917. } | {
  84918. ratio: number;
  84919. }): void;
  84920. /**
  84921. * Renders all the objects from the render list into the texture.
  84922. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84923. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84924. */
  84925. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84926. private _bestReflectionRenderTargetDimension;
  84927. /**
  84928. * @hidden
  84929. * @param faceIndex face index to bind to if this is a cubetexture
  84930. */
  84931. _bindFrameBuffer(faceIndex?: number): void;
  84932. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84933. private renderToTarget;
  84934. /**
  84935. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84936. * This allowed control for front to back rendering or reversly depending of the special needs.
  84937. *
  84938. * @param renderingGroupId The rendering group id corresponding to its index
  84939. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84940. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84941. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84942. */
  84943. 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;
  84944. /**
  84945. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84946. *
  84947. * @param renderingGroupId The rendering group id corresponding to its index
  84948. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84949. */
  84950. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84951. /**
  84952. * Clones the texture.
  84953. * @returns the cloned texture
  84954. */
  84955. clone(): RenderTargetTexture;
  84956. /**
  84957. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84958. * @returns The JSON representation of the texture
  84959. */
  84960. serialize(): any;
  84961. /**
  84962. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84963. */
  84964. disposeFramebufferObjects(): void;
  84965. /**
  84966. * Dispose the texture and release its associated resources.
  84967. */
  84968. dispose(): void;
  84969. /** @hidden */
  84970. _rebuild(): void;
  84971. /**
  84972. * Clear the info related to rendering groups preventing retention point in material dispose.
  84973. */
  84974. freeRenderingGroups(): void;
  84975. /**
  84976. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84977. * @returns the view count
  84978. */
  84979. getViewCount(): number;
  84980. }
  84981. }
  84982. declare module BABYLON {
  84983. /**
  84984. * Base class for the main features of a material in Babylon.js
  84985. */
  84986. export class Material implements IAnimatable {
  84987. /**
  84988. * Returns the triangle fill mode
  84989. */
  84990. static readonly TriangleFillMode: number;
  84991. /**
  84992. * Returns the wireframe mode
  84993. */
  84994. static readonly WireFrameFillMode: number;
  84995. /**
  84996. * Returns the point fill mode
  84997. */
  84998. static readonly PointFillMode: number;
  84999. /**
  85000. * Returns the point list draw mode
  85001. */
  85002. static readonly PointListDrawMode: number;
  85003. /**
  85004. * Returns the line list draw mode
  85005. */
  85006. static readonly LineListDrawMode: number;
  85007. /**
  85008. * Returns the line loop draw mode
  85009. */
  85010. static readonly LineLoopDrawMode: number;
  85011. /**
  85012. * Returns the line strip draw mode
  85013. */
  85014. static readonly LineStripDrawMode: number;
  85015. /**
  85016. * Returns the triangle strip draw mode
  85017. */
  85018. static readonly TriangleStripDrawMode: number;
  85019. /**
  85020. * Returns the triangle fan draw mode
  85021. */
  85022. static readonly TriangleFanDrawMode: number;
  85023. /**
  85024. * Stores the clock-wise side orientation
  85025. */
  85026. static readonly ClockWiseSideOrientation: number;
  85027. /**
  85028. * Stores the counter clock-wise side orientation
  85029. */
  85030. static readonly CounterClockWiseSideOrientation: number;
  85031. /**
  85032. * The dirty texture flag value
  85033. */
  85034. static readonly TextureDirtyFlag: number;
  85035. /**
  85036. * The dirty light flag value
  85037. */
  85038. static readonly LightDirtyFlag: number;
  85039. /**
  85040. * The dirty fresnel flag value
  85041. */
  85042. static readonly FresnelDirtyFlag: number;
  85043. /**
  85044. * The dirty attribute flag value
  85045. */
  85046. static readonly AttributesDirtyFlag: number;
  85047. /**
  85048. * The dirty misc flag value
  85049. */
  85050. static readonly MiscDirtyFlag: number;
  85051. /**
  85052. * The all dirty flag value
  85053. */
  85054. static readonly AllDirtyFlag: number;
  85055. /**
  85056. * The ID of the material
  85057. */
  85058. id: string;
  85059. /**
  85060. * Gets or sets the unique id of the material
  85061. */
  85062. uniqueId: number;
  85063. /**
  85064. * The name of the material
  85065. */
  85066. name: string;
  85067. /**
  85068. * Gets or sets user defined metadata
  85069. */
  85070. metadata: any;
  85071. /**
  85072. * For internal use only. Please do not use.
  85073. */
  85074. reservedDataStore: any;
  85075. /**
  85076. * Specifies if the ready state should be checked on each call
  85077. */
  85078. checkReadyOnEveryCall: boolean;
  85079. /**
  85080. * Specifies if the ready state should be checked once
  85081. */
  85082. checkReadyOnlyOnce: boolean;
  85083. /**
  85084. * The state of the material
  85085. */
  85086. state: string;
  85087. /**
  85088. * The alpha value of the material
  85089. */
  85090. protected _alpha: number;
  85091. /**
  85092. * List of inspectable custom properties (used by the Inspector)
  85093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85094. */
  85095. inspectableCustomProperties: IInspectable[];
  85096. /**
  85097. * Sets the alpha value of the material
  85098. */
  85099. /**
  85100. * Gets the alpha value of the material
  85101. */
  85102. alpha: number;
  85103. /**
  85104. * Specifies if back face culling is enabled
  85105. */
  85106. protected _backFaceCulling: boolean;
  85107. /**
  85108. * Sets the back-face culling state
  85109. */
  85110. /**
  85111. * Gets the back-face culling state
  85112. */
  85113. backFaceCulling: boolean;
  85114. /**
  85115. * Stores the value for side orientation
  85116. */
  85117. sideOrientation: number;
  85118. /**
  85119. * Callback triggered when the material is compiled
  85120. */
  85121. onCompiled: Nullable<(effect: Effect) => void>;
  85122. /**
  85123. * Callback triggered when an error occurs
  85124. */
  85125. onError: Nullable<(effect: Effect, errors: string) => void>;
  85126. /**
  85127. * Callback triggered to get the render target textures
  85128. */
  85129. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85130. /**
  85131. * Gets a boolean indicating that current material needs to register RTT
  85132. */
  85133. readonly hasRenderTargetTextures: boolean;
  85134. /**
  85135. * Specifies if the material should be serialized
  85136. */
  85137. doNotSerialize: boolean;
  85138. /**
  85139. * @hidden
  85140. */
  85141. _storeEffectOnSubMeshes: boolean;
  85142. /**
  85143. * Stores the animations for the material
  85144. */
  85145. animations: Nullable<Array<Animation>>;
  85146. /**
  85147. * An event triggered when the material is disposed
  85148. */
  85149. onDisposeObservable: Observable<Material>;
  85150. /**
  85151. * An observer which watches for dispose events
  85152. */
  85153. private _onDisposeObserver;
  85154. private _onUnBindObservable;
  85155. /**
  85156. * Called during a dispose event
  85157. */
  85158. onDispose: () => void;
  85159. private _onBindObservable;
  85160. /**
  85161. * An event triggered when the material is bound
  85162. */
  85163. readonly onBindObservable: Observable<AbstractMesh>;
  85164. /**
  85165. * An observer which watches for bind events
  85166. */
  85167. private _onBindObserver;
  85168. /**
  85169. * Called during a bind event
  85170. */
  85171. onBind: (Mesh: AbstractMesh) => void;
  85172. /**
  85173. * An event triggered when the material is unbound
  85174. */
  85175. readonly onUnBindObservable: Observable<Material>;
  85176. /**
  85177. * Stores the value of the alpha mode
  85178. */
  85179. private _alphaMode;
  85180. /**
  85181. * Sets the value of the alpha mode.
  85182. *
  85183. * | Value | Type | Description |
  85184. * | --- | --- | --- |
  85185. * | 0 | ALPHA_DISABLE | |
  85186. * | 1 | ALPHA_ADD | |
  85187. * | 2 | ALPHA_COMBINE | |
  85188. * | 3 | ALPHA_SUBTRACT | |
  85189. * | 4 | ALPHA_MULTIPLY | |
  85190. * | 5 | ALPHA_MAXIMIZED | |
  85191. * | 6 | ALPHA_ONEONE | |
  85192. * | 7 | ALPHA_PREMULTIPLIED | |
  85193. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85194. * | 9 | ALPHA_INTERPOLATE | |
  85195. * | 10 | ALPHA_SCREENMODE | |
  85196. *
  85197. */
  85198. /**
  85199. * Gets the value of the alpha mode
  85200. */
  85201. alphaMode: number;
  85202. /**
  85203. * Stores the state of the need depth pre-pass value
  85204. */
  85205. private _needDepthPrePass;
  85206. /**
  85207. * Sets the need depth pre-pass value
  85208. */
  85209. /**
  85210. * Gets the depth pre-pass value
  85211. */
  85212. needDepthPrePass: boolean;
  85213. /**
  85214. * Specifies if depth writing should be disabled
  85215. */
  85216. disableDepthWrite: boolean;
  85217. /**
  85218. * Specifies if depth writing should be forced
  85219. */
  85220. forceDepthWrite: boolean;
  85221. /**
  85222. * Specifies if there should be a separate pass for culling
  85223. */
  85224. separateCullingPass: boolean;
  85225. /**
  85226. * Stores the state specifing if fog should be enabled
  85227. */
  85228. private _fogEnabled;
  85229. /**
  85230. * Sets the state for enabling fog
  85231. */
  85232. /**
  85233. * Gets the value of the fog enabled state
  85234. */
  85235. fogEnabled: boolean;
  85236. /**
  85237. * Stores the size of points
  85238. */
  85239. pointSize: number;
  85240. /**
  85241. * Stores the z offset value
  85242. */
  85243. zOffset: number;
  85244. /**
  85245. * Gets a value specifying if wireframe mode is enabled
  85246. */
  85247. /**
  85248. * Sets the state of wireframe mode
  85249. */
  85250. wireframe: boolean;
  85251. /**
  85252. * Gets the value specifying if point clouds are enabled
  85253. */
  85254. /**
  85255. * Sets the state of point cloud mode
  85256. */
  85257. pointsCloud: boolean;
  85258. /**
  85259. * Gets the material fill mode
  85260. */
  85261. /**
  85262. * Sets the material fill mode
  85263. */
  85264. fillMode: number;
  85265. /**
  85266. * @hidden
  85267. * Stores the effects for the material
  85268. */
  85269. _effect: Nullable<Effect>;
  85270. /**
  85271. * @hidden
  85272. * Specifies if the material was previously ready
  85273. */
  85274. _wasPreviouslyReady: boolean;
  85275. /**
  85276. * Specifies if uniform buffers should be used
  85277. */
  85278. private _useUBO;
  85279. /**
  85280. * Stores a reference to the scene
  85281. */
  85282. private _scene;
  85283. /**
  85284. * Stores the fill mode state
  85285. */
  85286. private _fillMode;
  85287. /**
  85288. * Specifies if the depth write state should be cached
  85289. */
  85290. private _cachedDepthWriteState;
  85291. /**
  85292. * Stores the uniform buffer
  85293. */
  85294. protected _uniformBuffer: UniformBuffer;
  85295. /** @hidden */
  85296. _indexInSceneMaterialArray: number;
  85297. /** @hidden */
  85298. meshMap: Nullable<{
  85299. [id: string]: AbstractMesh | undefined;
  85300. }>;
  85301. /**
  85302. * Creates a material instance
  85303. * @param name defines the name of the material
  85304. * @param scene defines the scene to reference
  85305. * @param doNotAdd specifies if the material should be added to the scene
  85306. */
  85307. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85308. /**
  85309. * Returns a string representation of the current material
  85310. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85311. * @returns a string with material information
  85312. */
  85313. toString(fullDetails?: boolean): string;
  85314. /**
  85315. * Gets the class name of the material
  85316. * @returns a string with the class name of the material
  85317. */
  85318. getClassName(): string;
  85319. /**
  85320. * Specifies if updates for the material been locked
  85321. */
  85322. readonly isFrozen: boolean;
  85323. /**
  85324. * Locks updates for the material
  85325. */
  85326. freeze(): void;
  85327. /**
  85328. * Unlocks updates for the material
  85329. */
  85330. unfreeze(): void;
  85331. /**
  85332. * Specifies if the material is ready to be used
  85333. * @param mesh defines the mesh to check
  85334. * @param useInstances specifies if instances should be used
  85335. * @returns a boolean indicating if the material is ready to be used
  85336. */
  85337. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85338. /**
  85339. * Specifies that the submesh is ready to be used
  85340. * @param mesh defines the mesh to check
  85341. * @param subMesh defines which submesh to check
  85342. * @param useInstances specifies that instances should be used
  85343. * @returns a boolean indicating that the submesh is ready or not
  85344. */
  85345. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85346. /**
  85347. * Returns the material effect
  85348. * @returns the effect associated with the material
  85349. */
  85350. getEffect(): Nullable<Effect>;
  85351. /**
  85352. * Returns the current scene
  85353. * @returns a Scene
  85354. */
  85355. getScene(): Scene;
  85356. /**
  85357. * Specifies if the material will require alpha blending
  85358. * @returns a boolean specifying if alpha blending is needed
  85359. */
  85360. needAlphaBlending(): boolean;
  85361. /**
  85362. * Specifies if the mesh will require alpha blending
  85363. * @param mesh defines the mesh to check
  85364. * @returns a boolean specifying if alpha blending is needed for the mesh
  85365. */
  85366. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85367. /**
  85368. * Specifies if this material should be rendered in alpha test mode
  85369. * @returns a boolean specifying if an alpha test is needed.
  85370. */
  85371. needAlphaTesting(): boolean;
  85372. /**
  85373. * Gets the texture used for the alpha test
  85374. * @returns the texture to use for alpha testing
  85375. */
  85376. getAlphaTestTexture(): Nullable<BaseTexture>;
  85377. /**
  85378. * Marks the material to indicate that it needs to be re-calculated
  85379. */
  85380. markDirty(): void;
  85381. /** @hidden */
  85382. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85383. /**
  85384. * Binds the material to the mesh
  85385. * @param world defines the world transformation matrix
  85386. * @param mesh defines the mesh to bind the material to
  85387. */
  85388. bind(world: Matrix, mesh?: Mesh): void;
  85389. /**
  85390. * Binds the submesh to the material
  85391. * @param world defines the world transformation matrix
  85392. * @param mesh defines the mesh containing the submesh
  85393. * @param subMesh defines the submesh to bind the material to
  85394. */
  85395. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85396. /**
  85397. * Binds the world matrix to the material
  85398. * @param world defines the world transformation matrix
  85399. */
  85400. bindOnlyWorldMatrix(world: Matrix): void;
  85401. /**
  85402. * Binds the scene's uniform buffer to the effect.
  85403. * @param effect defines the effect to bind to the scene uniform buffer
  85404. * @param sceneUbo defines the uniform buffer storing scene data
  85405. */
  85406. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85407. /**
  85408. * Binds the view matrix to the effect
  85409. * @param effect defines the effect to bind the view matrix to
  85410. */
  85411. bindView(effect: Effect): void;
  85412. /**
  85413. * Binds the view projection matrix to the effect
  85414. * @param effect defines the effect to bind the view projection matrix to
  85415. */
  85416. bindViewProjection(effect: Effect): void;
  85417. /**
  85418. * Specifies if material alpha testing should be turned on for the mesh
  85419. * @param mesh defines the mesh to check
  85420. */
  85421. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85422. /**
  85423. * Processes to execute after binding the material to a mesh
  85424. * @param mesh defines the rendered mesh
  85425. */
  85426. protected _afterBind(mesh?: Mesh): void;
  85427. /**
  85428. * Unbinds the material from the mesh
  85429. */
  85430. unbind(): void;
  85431. /**
  85432. * Gets the active textures from the material
  85433. * @returns an array of textures
  85434. */
  85435. getActiveTextures(): BaseTexture[];
  85436. /**
  85437. * Specifies if the material uses a texture
  85438. * @param texture defines the texture to check against the material
  85439. * @returns a boolean specifying if the material uses the texture
  85440. */
  85441. hasTexture(texture: BaseTexture): boolean;
  85442. /**
  85443. * Makes a duplicate of the material, and gives it a new name
  85444. * @param name defines the new name for the duplicated material
  85445. * @returns the cloned material
  85446. */
  85447. clone(name: string): Nullable<Material>;
  85448. /**
  85449. * Gets the meshes bound to the material
  85450. * @returns an array of meshes bound to the material
  85451. */
  85452. getBindedMeshes(): AbstractMesh[];
  85453. /**
  85454. * Force shader compilation
  85455. * @param mesh defines the mesh associated with this material
  85456. * @param onCompiled defines a function to execute once the material is compiled
  85457. * @param options defines the options to configure the compilation
  85458. */
  85459. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85460. clipPlane: boolean;
  85461. }>): void;
  85462. /**
  85463. * Force shader compilation
  85464. * @param mesh defines the mesh that will use this material
  85465. * @param options defines additional options for compiling the shaders
  85466. * @returns a promise that resolves when the compilation completes
  85467. */
  85468. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85469. clipPlane: boolean;
  85470. }>): Promise<void>;
  85471. private static readonly _AllDirtyCallBack;
  85472. private static readonly _ImageProcessingDirtyCallBack;
  85473. private static readonly _TextureDirtyCallBack;
  85474. private static readonly _FresnelDirtyCallBack;
  85475. private static readonly _MiscDirtyCallBack;
  85476. private static readonly _LightsDirtyCallBack;
  85477. private static readonly _AttributeDirtyCallBack;
  85478. private static _FresnelAndMiscDirtyCallBack;
  85479. private static _TextureAndMiscDirtyCallBack;
  85480. private static readonly _DirtyCallbackArray;
  85481. private static readonly _RunDirtyCallBacks;
  85482. /**
  85483. * Marks a define in the material to indicate that it needs to be re-computed
  85484. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85485. */
  85486. markAsDirty(flag: number): void;
  85487. /**
  85488. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85489. * @param func defines a function which checks material defines against the submeshes
  85490. */
  85491. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85492. /**
  85493. * Indicates that we need to re-calculated for all submeshes
  85494. */
  85495. protected _markAllSubMeshesAsAllDirty(): void;
  85496. /**
  85497. * Indicates that image processing needs to be re-calculated for all submeshes
  85498. */
  85499. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85500. /**
  85501. * Indicates that textures need to be re-calculated for all submeshes
  85502. */
  85503. protected _markAllSubMeshesAsTexturesDirty(): void;
  85504. /**
  85505. * Indicates that fresnel needs to be re-calculated for all submeshes
  85506. */
  85507. protected _markAllSubMeshesAsFresnelDirty(): void;
  85508. /**
  85509. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85510. */
  85511. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85512. /**
  85513. * Indicates that lights need to be re-calculated for all submeshes
  85514. */
  85515. protected _markAllSubMeshesAsLightsDirty(): void;
  85516. /**
  85517. * Indicates that attributes need to be re-calculated for all submeshes
  85518. */
  85519. protected _markAllSubMeshesAsAttributesDirty(): void;
  85520. /**
  85521. * Indicates that misc needs to be re-calculated for all submeshes
  85522. */
  85523. protected _markAllSubMeshesAsMiscDirty(): void;
  85524. /**
  85525. * Indicates that textures and misc need to be re-calculated for all submeshes
  85526. */
  85527. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85528. /**
  85529. * Disposes the material
  85530. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85531. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85532. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85533. */
  85534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85535. /** @hidden */
  85536. private releaseVertexArrayObject;
  85537. /**
  85538. * Serializes this material
  85539. * @returns the serialized material object
  85540. */
  85541. serialize(): any;
  85542. /**
  85543. * Creates a material from parsed material data
  85544. * @param parsedMaterial defines parsed material data
  85545. * @param scene defines the hosting scene
  85546. * @param rootUrl defines the root URL to use to load textures
  85547. * @returns a new material
  85548. */
  85549. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85550. }
  85551. }
  85552. declare module BABYLON {
  85553. /**
  85554. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85555. * separate meshes. This can be use to improve performances.
  85556. * @see http://doc.babylonjs.com/how_to/multi_materials
  85557. */
  85558. export class MultiMaterial extends Material {
  85559. private _subMaterials;
  85560. /**
  85561. * Gets or Sets the list of Materials used within the multi material.
  85562. * They need to be ordered according to the submeshes order in the associated mesh
  85563. */
  85564. subMaterials: Nullable<Material>[];
  85565. /**
  85566. * Function used to align with Node.getChildren()
  85567. * @returns the list of Materials used within the multi material
  85568. */
  85569. getChildren(): Nullable<Material>[];
  85570. /**
  85571. * Instantiates a new Multi Material
  85572. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85573. * separate meshes. This can be use to improve performances.
  85574. * @see http://doc.babylonjs.com/how_to/multi_materials
  85575. * @param name Define the name in the scene
  85576. * @param scene Define the scene the material belongs to
  85577. */
  85578. constructor(name: string, scene: Scene);
  85579. private _hookArray;
  85580. /**
  85581. * Get one of the submaterial by its index in the submaterials array
  85582. * @param index The index to look the sub material at
  85583. * @returns The Material if the index has been defined
  85584. */
  85585. getSubMaterial(index: number): Nullable<Material>;
  85586. /**
  85587. * Get the list of active textures for the whole sub materials list.
  85588. * @returns All the textures that will be used during the rendering
  85589. */
  85590. getActiveTextures(): BaseTexture[];
  85591. /**
  85592. * Gets the current class name of the material e.g. "MultiMaterial"
  85593. * Mainly use in serialization.
  85594. * @returns the class name
  85595. */
  85596. getClassName(): string;
  85597. /**
  85598. * Checks if the material is ready to render the requested sub mesh
  85599. * @param mesh Define the mesh the submesh belongs to
  85600. * @param subMesh Define the sub mesh to look readyness for
  85601. * @param useInstances Define whether or not the material is used with instances
  85602. * @returns true if ready, otherwise false
  85603. */
  85604. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85605. /**
  85606. * Clones the current material and its related sub materials
  85607. * @param name Define the name of the newly cloned material
  85608. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85609. * @returns the cloned material
  85610. */
  85611. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85612. /**
  85613. * Serializes the materials into a JSON representation.
  85614. * @returns the JSON representation
  85615. */
  85616. serialize(): any;
  85617. /**
  85618. * Dispose the material and release its associated resources
  85619. * @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)
  85620. * @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)
  85621. * @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)
  85622. */
  85623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85624. /**
  85625. * Creates a MultiMaterial from parsed MultiMaterial data.
  85626. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85627. * @param scene defines the hosting scene
  85628. * @returns a new MultiMaterial
  85629. */
  85630. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85631. }
  85632. }
  85633. declare module BABYLON {
  85634. /**
  85635. * Base class for submeshes
  85636. */
  85637. export class BaseSubMesh {
  85638. /** @hidden */
  85639. _materialDefines: Nullable<MaterialDefines>;
  85640. /** @hidden */
  85641. _materialEffect: Nullable<Effect>;
  85642. /**
  85643. * Gets associated effect
  85644. */
  85645. readonly effect: Nullable<Effect>;
  85646. /**
  85647. * Sets associated effect (effect used to render this submesh)
  85648. * @param effect defines the effect to associate with
  85649. * @param defines defines the set of defines used to compile this effect
  85650. */
  85651. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85652. }
  85653. /**
  85654. * Defines a subdivision inside a mesh
  85655. */
  85656. export class SubMesh extends BaseSubMesh implements ICullable {
  85657. /** the material index to use */
  85658. materialIndex: number;
  85659. /** vertex index start */
  85660. verticesStart: number;
  85661. /** vertices count */
  85662. verticesCount: number;
  85663. /** index start */
  85664. indexStart: number;
  85665. /** indices count */
  85666. indexCount: number;
  85667. /** @hidden */
  85668. _linesIndexCount: number;
  85669. private _mesh;
  85670. private _renderingMesh;
  85671. private _boundingInfo;
  85672. private _linesIndexBuffer;
  85673. /** @hidden */
  85674. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85675. /** @hidden */
  85676. _trianglePlanes: Plane[];
  85677. /** @hidden */
  85678. _lastColliderTransformMatrix: Nullable<Matrix>;
  85679. /** @hidden */
  85680. _renderId: number;
  85681. /** @hidden */
  85682. _alphaIndex: number;
  85683. /** @hidden */
  85684. _distanceToCamera: number;
  85685. /** @hidden */
  85686. _id: number;
  85687. private _currentMaterial;
  85688. /**
  85689. * Add a new submesh to a mesh
  85690. * @param materialIndex defines the material index to use
  85691. * @param verticesStart defines vertex index start
  85692. * @param verticesCount defines vertices count
  85693. * @param indexStart defines index start
  85694. * @param indexCount defines indices count
  85695. * @param mesh defines the parent mesh
  85696. * @param renderingMesh defines an optional rendering mesh
  85697. * @param createBoundingBox defines if bounding box should be created for this submesh
  85698. * @returns the new submesh
  85699. */
  85700. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85701. /**
  85702. * Creates a new submesh
  85703. * @param materialIndex defines the material index to use
  85704. * @param verticesStart defines vertex index start
  85705. * @param verticesCount defines vertices count
  85706. * @param indexStart defines index start
  85707. * @param indexCount defines indices count
  85708. * @param mesh defines the parent mesh
  85709. * @param renderingMesh defines an optional rendering mesh
  85710. * @param createBoundingBox defines if bounding box should be created for this submesh
  85711. */
  85712. constructor(
  85713. /** the material index to use */
  85714. materialIndex: number,
  85715. /** vertex index start */
  85716. verticesStart: number,
  85717. /** vertices count */
  85718. verticesCount: number,
  85719. /** index start */
  85720. indexStart: number,
  85721. /** indices count */
  85722. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85723. /**
  85724. * Returns true if this submesh covers the entire parent mesh
  85725. * @ignorenaming
  85726. */
  85727. readonly IsGlobal: boolean;
  85728. /**
  85729. * Returns the submesh BoudingInfo object
  85730. * @returns current bounding info (or mesh's one if the submesh is global)
  85731. */
  85732. getBoundingInfo(): BoundingInfo;
  85733. /**
  85734. * Sets the submesh BoundingInfo
  85735. * @param boundingInfo defines the new bounding info to use
  85736. * @returns the SubMesh
  85737. */
  85738. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85739. /**
  85740. * Returns the mesh of the current submesh
  85741. * @return the parent mesh
  85742. */
  85743. getMesh(): AbstractMesh;
  85744. /**
  85745. * Returns the rendering mesh of the submesh
  85746. * @returns the rendering mesh (could be different from parent mesh)
  85747. */
  85748. getRenderingMesh(): Mesh;
  85749. /**
  85750. * Returns the submesh material
  85751. * @returns null or the current material
  85752. */
  85753. getMaterial(): Nullable<Material>;
  85754. /**
  85755. * Sets a new updated BoundingInfo object to the submesh
  85756. * @param data defines an optional position array to use to determine the bounding info
  85757. * @returns the SubMesh
  85758. */
  85759. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85760. /** @hidden */
  85761. _checkCollision(collider: Collider): boolean;
  85762. /**
  85763. * Updates the submesh BoundingInfo
  85764. * @param world defines the world matrix to use to update the bounding info
  85765. * @returns the submesh
  85766. */
  85767. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85768. /**
  85769. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85770. * @param frustumPlanes defines the frustum planes
  85771. * @returns true if the submesh is intersecting with the frustum
  85772. */
  85773. isInFrustum(frustumPlanes: Plane[]): boolean;
  85774. /**
  85775. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85776. * @param frustumPlanes defines the frustum planes
  85777. * @returns true if the submesh is inside the frustum
  85778. */
  85779. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85780. /**
  85781. * Renders the submesh
  85782. * @param enableAlphaMode defines if alpha needs to be used
  85783. * @returns the submesh
  85784. */
  85785. render(enableAlphaMode: boolean): SubMesh;
  85786. /**
  85787. * @hidden
  85788. */
  85789. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85790. /**
  85791. * Checks if the submesh intersects with a ray
  85792. * @param ray defines the ray to test
  85793. * @returns true is the passed ray intersects the submesh bounding box
  85794. */
  85795. canIntersects(ray: Ray): boolean;
  85796. /**
  85797. * Intersects current submesh with a ray
  85798. * @param ray defines the ray to test
  85799. * @param positions defines mesh's positions array
  85800. * @param indices defines mesh's indices array
  85801. * @param fastCheck defines if only bounding info should be used
  85802. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85803. * @returns intersection info or null if no intersection
  85804. */
  85805. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85806. /** @hidden */
  85807. private _intersectLines;
  85808. /** @hidden */
  85809. private _intersectUnIndexedLines;
  85810. /** @hidden */
  85811. private _intersectTriangles;
  85812. /** @hidden */
  85813. private _intersectUnIndexedTriangles;
  85814. /** @hidden */
  85815. _rebuild(): void;
  85816. /**
  85817. * Creates a new submesh from the passed mesh
  85818. * @param newMesh defines the new hosting mesh
  85819. * @param newRenderingMesh defines an optional rendering mesh
  85820. * @returns the new submesh
  85821. */
  85822. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85823. /**
  85824. * Release associated resources
  85825. */
  85826. dispose(): void;
  85827. /**
  85828. * Gets the class name
  85829. * @returns the string "SubMesh".
  85830. */
  85831. getClassName(): string;
  85832. /**
  85833. * Creates a new submesh from indices data
  85834. * @param materialIndex the index of the main mesh material
  85835. * @param startIndex the index where to start the copy in the mesh indices array
  85836. * @param indexCount the number of indices to copy then from the startIndex
  85837. * @param mesh the main mesh to create the submesh from
  85838. * @param renderingMesh the optional rendering mesh
  85839. * @returns a new submesh
  85840. */
  85841. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85842. }
  85843. }
  85844. declare module BABYLON {
  85845. /**
  85846. * Class used to represent data loading progression
  85847. */
  85848. export class SceneLoaderFlags {
  85849. private static _ForceFullSceneLoadingForIncremental;
  85850. private static _ShowLoadingScreen;
  85851. private static _CleanBoneMatrixWeights;
  85852. private static _loggingLevel;
  85853. /**
  85854. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85855. */
  85856. static ForceFullSceneLoadingForIncremental: boolean;
  85857. /**
  85858. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85859. */
  85860. static ShowLoadingScreen: boolean;
  85861. /**
  85862. * Defines the current logging level (while loading the scene)
  85863. * @ignorenaming
  85864. */
  85865. static loggingLevel: number;
  85866. /**
  85867. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85868. */
  85869. static CleanBoneMatrixWeights: boolean;
  85870. }
  85871. }
  85872. declare module BABYLON {
  85873. /**
  85874. * Class used to store geometry data (vertex buffers + index buffer)
  85875. */
  85876. export class Geometry implements IGetSetVerticesData {
  85877. /**
  85878. * Gets or sets the ID of the geometry
  85879. */
  85880. id: string;
  85881. /**
  85882. * Gets or sets the unique ID of the geometry
  85883. */
  85884. uniqueId: number;
  85885. /**
  85886. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85887. */
  85888. delayLoadState: number;
  85889. /**
  85890. * Gets the file containing the data to load when running in delay load state
  85891. */
  85892. delayLoadingFile: Nullable<string>;
  85893. /**
  85894. * Callback called when the geometry is updated
  85895. */
  85896. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85897. private _scene;
  85898. private _engine;
  85899. private _meshes;
  85900. private _totalVertices;
  85901. /** @hidden */
  85902. _indices: IndicesArray;
  85903. /** @hidden */
  85904. _vertexBuffers: {
  85905. [key: string]: VertexBuffer;
  85906. };
  85907. private _isDisposed;
  85908. private _extend;
  85909. private _boundingBias;
  85910. /** @hidden */
  85911. _delayInfo: Array<string>;
  85912. private _indexBuffer;
  85913. private _indexBufferIsUpdatable;
  85914. /** @hidden */
  85915. _boundingInfo: Nullable<BoundingInfo>;
  85916. /** @hidden */
  85917. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85918. /** @hidden */
  85919. _softwareSkinningFrameId: number;
  85920. private _vertexArrayObjects;
  85921. private _updatable;
  85922. /** @hidden */
  85923. _positions: Nullable<Vector3[]>;
  85924. /**
  85925. * 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
  85926. */
  85927. /**
  85928. * 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
  85929. */
  85930. boundingBias: Vector2;
  85931. /**
  85932. * Static function used to attach a new empty geometry to a mesh
  85933. * @param mesh defines the mesh to attach the geometry to
  85934. * @returns the new Geometry
  85935. */
  85936. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85937. /**
  85938. * Creates a new geometry
  85939. * @param id defines the unique ID
  85940. * @param scene defines the hosting scene
  85941. * @param vertexData defines the VertexData used to get geometry data
  85942. * @param updatable defines if geometry must be updatable (false by default)
  85943. * @param mesh defines the mesh that will be associated with the geometry
  85944. */
  85945. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85946. /**
  85947. * Gets the current extend of the geometry
  85948. */
  85949. readonly extend: {
  85950. minimum: Vector3;
  85951. maximum: Vector3;
  85952. };
  85953. /**
  85954. * Gets the hosting scene
  85955. * @returns the hosting Scene
  85956. */
  85957. getScene(): Scene;
  85958. /**
  85959. * Gets the hosting engine
  85960. * @returns the hosting Engine
  85961. */
  85962. getEngine(): Engine;
  85963. /**
  85964. * Defines if the geometry is ready to use
  85965. * @returns true if the geometry is ready to be used
  85966. */
  85967. isReady(): boolean;
  85968. /**
  85969. * Gets a value indicating that the geometry should not be serialized
  85970. */
  85971. readonly doNotSerialize: boolean;
  85972. /** @hidden */
  85973. _rebuild(): void;
  85974. /**
  85975. * Affects all geometry data in one call
  85976. * @param vertexData defines the geometry data
  85977. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85978. */
  85979. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85980. /**
  85981. * Set specific vertex data
  85982. * @param kind defines the data kind (Position, normal, etc...)
  85983. * @param data defines the vertex data to use
  85984. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85985. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85986. */
  85987. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85988. /**
  85989. * Removes a specific vertex data
  85990. * @param kind defines the data kind (Position, normal, etc...)
  85991. */
  85992. removeVerticesData(kind: string): void;
  85993. /**
  85994. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85995. * @param buffer defines the vertex buffer to use
  85996. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85997. */
  85998. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85999. /**
  86000. * Update a specific vertex buffer
  86001. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86002. * It will do nothing if the buffer is not updatable
  86003. * @param kind defines the data kind (Position, normal, etc...)
  86004. * @param data defines the data to use
  86005. * @param offset defines the offset in the target buffer where to store the data
  86006. * @param useBytes set to true if the offset is in bytes
  86007. */
  86008. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86009. /**
  86010. * Update a specific vertex buffer
  86011. * This function will create a new buffer if the current one is not updatable
  86012. * @param kind defines the data kind (Position, normal, etc...)
  86013. * @param data defines the data to use
  86014. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86015. */
  86016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86017. private _updateBoundingInfo;
  86018. /** @hidden */
  86019. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86020. /**
  86021. * Gets total number of vertices
  86022. * @returns the total number of vertices
  86023. */
  86024. getTotalVertices(): number;
  86025. /**
  86026. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86027. * @param kind defines the data kind (Position, normal, etc...)
  86028. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86029. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86030. * @returns a float array containing vertex data
  86031. */
  86032. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86033. /**
  86034. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86035. * @param kind defines the data kind (Position, normal, etc...)
  86036. * @returns true if the vertex buffer with the specified kind is updatable
  86037. */
  86038. isVertexBufferUpdatable(kind: string): boolean;
  86039. /**
  86040. * Gets a specific vertex buffer
  86041. * @param kind defines the data kind (Position, normal, etc...)
  86042. * @returns a VertexBuffer
  86043. */
  86044. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86045. /**
  86046. * Returns all vertex buffers
  86047. * @return an object holding all vertex buffers indexed by kind
  86048. */
  86049. getVertexBuffers(): Nullable<{
  86050. [key: string]: VertexBuffer;
  86051. }>;
  86052. /**
  86053. * Gets a boolean indicating if specific vertex buffer is present
  86054. * @param kind defines the data kind (Position, normal, etc...)
  86055. * @returns true if data is present
  86056. */
  86057. isVerticesDataPresent(kind: string): boolean;
  86058. /**
  86059. * Gets a list of all attached data kinds (Position, normal, etc...)
  86060. * @returns a list of string containing all kinds
  86061. */
  86062. getVerticesDataKinds(): string[];
  86063. /**
  86064. * Update index buffer
  86065. * @param indices defines the indices to store in the index buffer
  86066. * @param offset defines the offset in the target buffer where to store the data
  86067. * @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)
  86068. */
  86069. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86070. /**
  86071. * Creates a new index buffer
  86072. * @param indices defines the indices to store in the index buffer
  86073. * @param totalVertices defines the total number of vertices (could be null)
  86074. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86075. */
  86076. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86077. /**
  86078. * Return the total number of indices
  86079. * @returns the total number of indices
  86080. */
  86081. getTotalIndices(): number;
  86082. /**
  86083. * Gets the index buffer array
  86084. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86086. * @returns the index buffer array
  86087. */
  86088. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86089. /**
  86090. * Gets the index buffer
  86091. * @return the index buffer
  86092. */
  86093. getIndexBuffer(): Nullable<DataBuffer>;
  86094. /** @hidden */
  86095. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86096. /**
  86097. * Release the associated resources for a specific mesh
  86098. * @param mesh defines the source mesh
  86099. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86100. */
  86101. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86102. /**
  86103. * Apply current geometry to a given mesh
  86104. * @param mesh defines the mesh to apply geometry to
  86105. */
  86106. applyToMesh(mesh: Mesh): void;
  86107. private _updateExtend;
  86108. private _applyToMesh;
  86109. private notifyUpdate;
  86110. /**
  86111. * Load the geometry if it was flagged as delay loaded
  86112. * @param scene defines the hosting scene
  86113. * @param onLoaded defines a callback called when the geometry is loaded
  86114. */
  86115. load(scene: Scene, onLoaded?: () => void): void;
  86116. private _queueLoad;
  86117. /**
  86118. * Invert the geometry to move from a right handed system to a left handed one.
  86119. */
  86120. toLeftHanded(): void;
  86121. /** @hidden */
  86122. _resetPointsArrayCache(): void;
  86123. /** @hidden */
  86124. _generatePointsArray(): boolean;
  86125. /**
  86126. * Gets a value indicating if the geometry is disposed
  86127. * @returns true if the geometry was disposed
  86128. */
  86129. isDisposed(): boolean;
  86130. private _disposeVertexArrayObjects;
  86131. /**
  86132. * Free all associated resources
  86133. */
  86134. dispose(): void;
  86135. /**
  86136. * Clone the current geometry into a new geometry
  86137. * @param id defines the unique ID of the new geometry
  86138. * @returns a new geometry object
  86139. */
  86140. copy(id: string): Geometry;
  86141. /**
  86142. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86143. * @return a JSON representation of the current geometry data (without the vertices data)
  86144. */
  86145. serialize(): any;
  86146. private toNumberArray;
  86147. /**
  86148. * Serialize all vertices data into a JSON oject
  86149. * @returns a JSON representation of the current geometry data
  86150. */
  86151. serializeVerticeData(): any;
  86152. /**
  86153. * Extracts a clone of a mesh geometry
  86154. * @param mesh defines the source mesh
  86155. * @param id defines the unique ID of the new geometry object
  86156. * @returns the new geometry object
  86157. */
  86158. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86159. /**
  86160. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86161. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86162. * Be aware Math.random() could cause collisions, but:
  86163. * "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"
  86164. * @returns a string containing a new GUID
  86165. */
  86166. static RandomId(): string;
  86167. /** @hidden */
  86168. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86169. private static _CleanMatricesWeights;
  86170. /**
  86171. * Create a new geometry from persisted data (Using .babylon file format)
  86172. * @param parsedVertexData defines the persisted data
  86173. * @param scene defines the hosting scene
  86174. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86175. * @returns the new geometry object
  86176. */
  86177. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86178. }
  86179. }
  86180. declare module BABYLON {
  86181. /**
  86182. * Define an interface for all classes that will get and set the data on vertices
  86183. */
  86184. export interface IGetSetVerticesData {
  86185. /**
  86186. * Gets a boolean indicating if specific vertex data is present
  86187. * @param kind defines the vertex data kind to use
  86188. * @returns true is data kind is present
  86189. */
  86190. isVerticesDataPresent(kind: string): boolean;
  86191. /**
  86192. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86193. * @param kind defines the data kind (Position, normal, etc...)
  86194. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86195. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86196. * @returns a float array containing vertex data
  86197. */
  86198. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86199. /**
  86200. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86201. * @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.
  86202. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86203. * @returns the indices array or an empty array if the mesh has no geometry
  86204. */
  86205. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86206. /**
  86207. * Set specific vertex data
  86208. * @param kind defines the data kind (Position, normal, etc...)
  86209. * @param data defines the vertex data to use
  86210. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86211. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86212. */
  86213. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86214. /**
  86215. * Update a specific associated vertex buffer
  86216. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86217. * - VertexBuffer.PositionKind
  86218. * - VertexBuffer.UVKind
  86219. * - VertexBuffer.UV2Kind
  86220. * - VertexBuffer.UV3Kind
  86221. * - VertexBuffer.UV4Kind
  86222. * - VertexBuffer.UV5Kind
  86223. * - VertexBuffer.UV6Kind
  86224. * - VertexBuffer.ColorKind
  86225. * - VertexBuffer.MatricesIndicesKind
  86226. * - VertexBuffer.MatricesIndicesExtraKind
  86227. * - VertexBuffer.MatricesWeightsKind
  86228. * - VertexBuffer.MatricesWeightsExtraKind
  86229. * @param data defines the data source
  86230. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86231. * @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)
  86232. */
  86233. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86234. /**
  86235. * Creates a new index buffer
  86236. * @param indices defines the indices to store in the index buffer
  86237. * @param totalVertices defines the total number of vertices (could be null)
  86238. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86239. */
  86240. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86241. }
  86242. /**
  86243. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86244. */
  86245. export class VertexData {
  86246. /**
  86247. * Mesh side orientation : usually the external or front surface
  86248. */
  86249. static readonly FRONTSIDE: number;
  86250. /**
  86251. * Mesh side orientation : usually the internal or back surface
  86252. */
  86253. static readonly BACKSIDE: number;
  86254. /**
  86255. * Mesh side orientation : both internal and external or front and back surfaces
  86256. */
  86257. static readonly DOUBLESIDE: number;
  86258. /**
  86259. * Mesh side orientation : by default, `FRONTSIDE`
  86260. */
  86261. static readonly DEFAULTSIDE: number;
  86262. /**
  86263. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86264. */
  86265. positions: Nullable<FloatArray>;
  86266. /**
  86267. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86268. */
  86269. normals: Nullable<FloatArray>;
  86270. /**
  86271. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86272. */
  86273. tangents: Nullable<FloatArray>;
  86274. /**
  86275. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86276. */
  86277. uvs: Nullable<FloatArray>;
  86278. /**
  86279. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86280. */
  86281. uvs2: Nullable<FloatArray>;
  86282. /**
  86283. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86284. */
  86285. uvs3: Nullable<FloatArray>;
  86286. /**
  86287. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86288. */
  86289. uvs4: Nullable<FloatArray>;
  86290. /**
  86291. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86292. */
  86293. uvs5: Nullable<FloatArray>;
  86294. /**
  86295. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86296. */
  86297. uvs6: Nullable<FloatArray>;
  86298. /**
  86299. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86300. */
  86301. colors: Nullable<FloatArray>;
  86302. /**
  86303. * 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).
  86304. */
  86305. matricesIndices: Nullable<FloatArray>;
  86306. /**
  86307. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86308. */
  86309. matricesWeights: Nullable<FloatArray>;
  86310. /**
  86311. * An array extending the number of possible indices
  86312. */
  86313. matricesIndicesExtra: Nullable<FloatArray>;
  86314. /**
  86315. * An array extending the number of possible weights when the number of indices is extended
  86316. */
  86317. matricesWeightsExtra: Nullable<FloatArray>;
  86318. /**
  86319. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86320. */
  86321. indices: Nullable<IndicesArray>;
  86322. /**
  86323. * Uses the passed data array to set the set the values for the specified kind of data
  86324. * @param data a linear array of floating numbers
  86325. * @param kind the type of data that is being set, eg positions, colors etc
  86326. */
  86327. set(data: FloatArray, kind: string): void;
  86328. /**
  86329. * Associates the vertexData to the passed Mesh.
  86330. * Sets it as updatable or not (default `false`)
  86331. * @param mesh the mesh the vertexData is applied to
  86332. * @param updatable when used and having the value true allows new data to update the vertexData
  86333. * @returns the VertexData
  86334. */
  86335. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86336. /**
  86337. * Associates the vertexData to the passed Geometry.
  86338. * Sets it as updatable or not (default `false`)
  86339. * @param geometry the geometry the vertexData is applied to
  86340. * @param updatable when used and having the value true allows new data to update the vertexData
  86341. * @returns VertexData
  86342. */
  86343. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86344. /**
  86345. * Updates the associated mesh
  86346. * @param mesh the mesh to be updated
  86347. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86348. * @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
  86349. * @returns VertexData
  86350. */
  86351. updateMesh(mesh: Mesh): VertexData;
  86352. /**
  86353. * Updates the associated geometry
  86354. * @param geometry the geometry to be updated
  86355. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86356. * @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
  86357. * @returns VertexData.
  86358. */
  86359. updateGeometry(geometry: Geometry): VertexData;
  86360. private _applyTo;
  86361. private _update;
  86362. /**
  86363. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86364. * @param matrix the transforming matrix
  86365. * @returns the VertexData
  86366. */
  86367. transform(matrix: Matrix): VertexData;
  86368. /**
  86369. * Merges the passed VertexData into the current one
  86370. * @param other the VertexData to be merged into the current one
  86371. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86372. * @returns the modified VertexData
  86373. */
  86374. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86375. private _mergeElement;
  86376. private _validate;
  86377. /**
  86378. * Serializes the VertexData
  86379. * @returns a serialized object
  86380. */
  86381. serialize(): any;
  86382. /**
  86383. * Extracts the vertexData from a mesh
  86384. * @param mesh the mesh from which to extract the VertexData
  86385. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86386. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86387. * @returns the object VertexData associated to the passed mesh
  86388. */
  86389. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86390. /**
  86391. * Extracts the vertexData from the geometry
  86392. * @param geometry the geometry from which to extract the VertexData
  86393. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86394. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86395. * @returns the object VertexData associated to the passed mesh
  86396. */
  86397. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86398. private static _ExtractFrom;
  86399. /**
  86400. * Creates the VertexData for a Ribbon
  86401. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86402. * * pathArray array of paths, each of which an array of successive Vector3
  86403. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86404. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86405. * * 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
  86406. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86407. * * 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)
  86408. * * 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)
  86409. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86410. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86411. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86412. * @returns the VertexData of the ribbon
  86413. */
  86414. static CreateRibbon(options: {
  86415. pathArray: Vector3[][];
  86416. closeArray?: boolean;
  86417. closePath?: boolean;
  86418. offset?: number;
  86419. sideOrientation?: number;
  86420. frontUVs?: Vector4;
  86421. backUVs?: Vector4;
  86422. invertUV?: boolean;
  86423. uvs?: Vector2[];
  86424. colors?: Color4[];
  86425. }): VertexData;
  86426. /**
  86427. * Creates the VertexData for a box
  86428. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86429. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86430. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86431. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86432. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86433. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86434. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86436. * * 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)
  86437. * * 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)
  86438. * @returns the VertexData of the box
  86439. */
  86440. static CreateBox(options: {
  86441. size?: number;
  86442. width?: number;
  86443. height?: number;
  86444. depth?: number;
  86445. faceUV?: Vector4[];
  86446. faceColors?: Color4[];
  86447. sideOrientation?: number;
  86448. frontUVs?: Vector4;
  86449. backUVs?: Vector4;
  86450. }): VertexData;
  86451. /**
  86452. * Creates the VertexData for a tiled box
  86453. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86454. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86455. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86456. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86458. * @returns the VertexData of the box
  86459. */
  86460. static CreateTiledBox(options: {
  86461. pattern?: number;
  86462. width?: number;
  86463. height?: number;
  86464. depth?: number;
  86465. tileSize?: number;
  86466. tileWidth?: number;
  86467. tileHeight?: number;
  86468. alignHorizontal?: number;
  86469. alignVertical?: number;
  86470. faceUV?: Vector4[];
  86471. faceColors?: Color4[];
  86472. sideOrientation?: number;
  86473. }): VertexData;
  86474. /**
  86475. * Creates the VertexData for a tiled plane
  86476. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86477. * * pattern a limited pattern arrangement depending on the number
  86478. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86479. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86480. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86482. * * 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)
  86483. * * 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)
  86484. * @returns the VertexData of the tiled plane
  86485. */
  86486. static CreateTiledPlane(options: {
  86487. pattern?: number;
  86488. tileSize?: number;
  86489. tileWidth?: number;
  86490. tileHeight?: number;
  86491. size?: number;
  86492. width?: number;
  86493. height?: number;
  86494. alignHorizontal?: number;
  86495. alignVertical?: number;
  86496. sideOrientation?: number;
  86497. frontUVs?: Vector4;
  86498. backUVs?: Vector4;
  86499. }): VertexData;
  86500. /**
  86501. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86502. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86503. * * segments sets the number of horizontal strips optional, default 32
  86504. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86505. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86506. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86507. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86508. * * 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
  86509. * * 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
  86510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86511. * * 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)
  86512. * * 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)
  86513. * @returns the VertexData of the ellipsoid
  86514. */
  86515. static CreateSphere(options: {
  86516. segments?: number;
  86517. diameter?: number;
  86518. diameterX?: number;
  86519. diameterY?: number;
  86520. diameterZ?: number;
  86521. arc?: number;
  86522. slice?: number;
  86523. sideOrientation?: number;
  86524. frontUVs?: Vector4;
  86525. backUVs?: Vector4;
  86526. }): VertexData;
  86527. /**
  86528. * Creates the VertexData for a cylinder, cone or prism
  86529. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86530. * * height sets the height (y direction) of the cylinder, optional, default 2
  86531. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86532. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86533. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86534. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86535. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86536. * * 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
  86537. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86538. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86539. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86540. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86542. * * 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)
  86543. * * 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)
  86544. * @returns the VertexData of the cylinder, cone or prism
  86545. */
  86546. static CreateCylinder(options: {
  86547. height?: number;
  86548. diameterTop?: number;
  86549. diameterBottom?: number;
  86550. diameter?: number;
  86551. tessellation?: number;
  86552. subdivisions?: number;
  86553. arc?: number;
  86554. faceColors?: Color4[];
  86555. faceUV?: Vector4[];
  86556. hasRings?: boolean;
  86557. enclose?: boolean;
  86558. sideOrientation?: number;
  86559. frontUVs?: Vector4;
  86560. backUVs?: Vector4;
  86561. }): VertexData;
  86562. /**
  86563. * Creates the VertexData for a torus
  86564. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86565. * * diameter the diameter of the torus, optional default 1
  86566. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86567. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86568. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86569. * * 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)
  86570. * * 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)
  86571. * @returns the VertexData of the torus
  86572. */
  86573. static CreateTorus(options: {
  86574. diameter?: number;
  86575. thickness?: number;
  86576. tessellation?: number;
  86577. sideOrientation?: number;
  86578. frontUVs?: Vector4;
  86579. backUVs?: Vector4;
  86580. }): VertexData;
  86581. /**
  86582. * Creates the VertexData of the LineSystem
  86583. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86584. * - lines an array of lines, each line being an array of successive Vector3
  86585. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86586. * @returns the VertexData of the LineSystem
  86587. */
  86588. static CreateLineSystem(options: {
  86589. lines: Vector3[][];
  86590. colors?: Nullable<Color4[][]>;
  86591. }): VertexData;
  86592. /**
  86593. * Create the VertexData for a DashedLines
  86594. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86595. * - points an array successive Vector3
  86596. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86597. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86598. * - dashNb the intended total number of dashes, optional, default 200
  86599. * @returns the VertexData for the DashedLines
  86600. */
  86601. static CreateDashedLines(options: {
  86602. points: Vector3[];
  86603. dashSize?: number;
  86604. gapSize?: number;
  86605. dashNb?: number;
  86606. }): VertexData;
  86607. /**
  86608. * Creates the VertexData for a Ground
  86609. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86610. * - width the width (x direction) of the ground, optional, default 1
  86611. * - height the height (z direction) of the ground, optional, default 1
  86612. * - subdivisions the number of subdivisions per side, optional, default 1
  86613. * @returns the VertexData of the Ground
  86614. */
  86615. static CreateGround(options: {
  86616. width?: number;
  86617. height?: number;
  86618. subdivisions?: number;
  86619. subdivisionsX?: number;
  86620. subdivisionsY?: number;
  86621. }): VertexData;
  86622. /**
  86623. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86624. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86625. * * xmin the ground minimum X coordinate, optional, default -1
  86626. * * zmin the ground minimum Z coordinate, optional, default -1
  86627. * * xmax the ground maximum X coordinate, optional, default 1
  86628. * * zmax the ground maximum Z coordinate, optional, default 1
  86629. * * 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}
  86630. * * 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}
  86631. * @returns the VertexData of the TiledGround
  86632. */
  86633. static CreateTiledGround(options: {
  86634. xmin: number;
  86635. zmin: number;
  86636. xmax: number;
  86637. zmax: number;
  86638. subdivisions?: {
  86639. w: number;
  86640. h: number;
  86641. };
  86642. precision?: {
  86643. w: number;
  86644. h: number;
  86645. };
  86646. }): VertexData;
  86647. /**
  86648. * Creates the VertexData of the Ground designed from a heightmap
  86649. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86650. * * width the width (x direction) of the ground
  86651. * * height the height (z direction) of the ground
  86652. * * subdivisions the number of subdivisions per side
  86653. * * minHeight the minimum altitude on the ground, optional, default 0
  86654. * * maxHeight the maximum altitude on the ground, optional default 1
  86655. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86656. * * buffer the array holding the image color data
  86657. * * bufferWidth the width of image
  86658. * * bufferHeight the height of image
  86659. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86660. * @returns the VertexData of the Ground designed from a heightmap
  86661. */
  86662. static CreateGroundFromHeightMap(options: {
  86663. width: number;
  86664. height: number;
  86665. subdivisions: number;
  86666. minHeight: number;
  86667. maxHeight: number;
  86668. colorFilter: Color3;
  86669. buffer: Uint8Array;
  86670. bufferWidth: number;
  86671. bufferHeight: number;
  86672. alphaFilter: number;
  86673. }): VertexData;
  86674. /**
  86675. * Creates the VertexData for a Plane
  86676. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86677. * * size sets the width and height of the plane to the value of size, optional default 1
  86678. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86679. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86681. * * 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)
  86682. * * 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)
  86683. * @returns the VertexData of the box
  86684. */
  86685. static CreatePlane(options: {
  86686. size?: number;
  86687. width?: number;
  86688. height?: number;
  86689. sideOrientation?: number;
  86690. frontUVs?: Vector4;
  86691. backUVs?: Vector4;
  86692. }): VertexData;
  86693. /**
  86694. * Creates the VertexData of the Disc or regular Polygon
  86695. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86696. * * radius the radius of the disc, optional default 0.5
  86697. * * tessellation the number of polygon sides, optional, default 64
  86698. * * 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
  86699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86700. * * 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)
  86701. * * 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)
  86702. * @returns the VertexData of the box
  86703. */
  86704. static CreateDisc(options: {
  86705. radius?: number;
  86706. tessellation?: number;
  86707. arc?: number;
  86708. sideOrientation?: number;
  86709. frontUVs?: Vector4;
  86710. backUVs?: Vector4;
  86711. }): VertexData;
  86712. /**
  86713. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86714. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86715. * @param polygon a mesh built from polygonTriangulation.build()
  86716. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86717. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86718. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86719. * @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)
  86720. * @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)
  86721. * @returns the VertexData of the Polygon
  86722. */
  86723. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86724. /**
  86725. * Creates the VertexData of the IcoSphere
  86726. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86727. * * radius the radius of the IcoSphere, optional default 1
  86728. * * radiusX allows stretching in the x direction, optional, default radius
  86729. * * radiusY allows stretching in the y direction, optional, default radius
  86730. * * radiusZ allows stretching in the z direction, optional, default radius
  86731. * * flat when true creates a flat shaded mesh, optional, default true
  86732. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86733. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86734. * * 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)
  86735. * * 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)
  86736. * @returns the VertexData of the IcoSphere
  86737. */
  86738. static CreateIcoSphere(options: {
  86739. radius?: number;
  86740. radiusX?: number;
  86741. radiusY?: number;
  86742. radiusZ?: number;
  86743. flat?: boolean;
  86744. subdivisions?: number;
  86745. sideOrientation?: number;
  86746. frontUVs?: Vector4;
  86747. backUVs?: Vector4;
  86748. }): VertexData;
  86749. /**
  86750. * Creates the VertexData for a Polyhedron
  86751. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86752. * * type provided types are:
  86753. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86754. * * 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)
  86755. * * size the size of the IcoSphere, optional default 1
  86756. * * sizeX allows stretching in the x direction, optional, default size
  86757. * * sizeY allows stretching in the y direction, optional, default size
  86758. * * sizeZ allows stretching in the z direction, optional, default size
  86759. * * 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
  86760. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86761. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86762. * * flat when true creates a flat shaded mesh, optional, default true
  86763. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86765. * * 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)
  86766. * * 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)
  86767. * @returns the VertexData of the Polyhedron
  86768. */
  86769. static CreatePolyhedron(options: {
  86770. type?: number;
  86771. size?: number;
  86772. sizeX?: number;
  86773. sizeY?: number;
  86774. sizeZ?: number;
  86775. custom?: any;
  86776. faceUV?: Vector4[];
  86777. faceColors?: Color4[];
  86778. flat?: boolean;
  86779. sideOrientation?: number;
  86780. frontUVs?: Vector4;
  86781. backUVs?: Vector4;
  86782. }): VertexData;
  86783. /**
  86784. * Creates the VertexData for a TorusKnot
  86785. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86786. * * radius the radius of the torus knot, optional, default 2
  86787. * * tube the thickness of the tube, optional, default 0.5
  86788. * * radialSegments the number of sides on each tube segments, optional, default 32
  86789. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86790. * * p the number of windings around the z axis, optional, default 2
  86791. * * q the number of windings around the x axis, optional, default 3
  86792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86793. * * 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)
  86794. * * 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)
  86795. * @returns the VertexData of the Torus Knot
  86796. */
  86797. static CreateTorusKnot(options: {
  86798. radius?: number;
  86799. tube?: number;
  86800. radialSegments?: number;
  86801. tubularSegments?: number;
  86802. p?: number;
  86803. q?: number;
  86804. sideOrientation?: number;
  86805. frontUVs?: Vector4;
  86806. backUVs?: Vector4;
  86807. }): VertexData;
  86808. /**
  86809. * Compute normals for given positions and indices
  86810. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86811. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86812. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86813. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86814. * * facetNormals : optional array of facet normals (vector3)
  86815. * * facetPositions : optional array of facet positions (vector3)
  86816. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86817. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86818. * * bInfo : optional bounding info, required for facetPartitioning computation
  86819. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86820. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86821. * * useRightHandedSystem: optional boolean to for right handed system computation
  86822. * * depthSort : optional boolean to enable the facet depth sort computation
  86823. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86824. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86825. */
  86826. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86827. facetNormals?: any;
  86828. facetPositions?: any;
  86829. facetPartitioning?: any;
  86830. ratio?: number;
  86831. bInfo?: any;
  86832. bbSize?: Vector3;
  86833. subDiv?: any;
  86834. useRightHandedSystem?: boolean;
  86835. depthSort?: boolean;
  86836. distanceTo?: Vector3;
  86837. depthSortedFacets?: any;
  86838. }): void;
  86839. /** @hidden */
  86840. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86841. /**
  86842. * Applies VertexData created from the imported parameters to the geometry
  86843. * @param parsedVertexData the parsed data from an imported file
  86844. * @param geometry the geometry to apply the VertexData to
  86845. */
  86846. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86847. }
  86848. }
  86849. declare module BABYLON {
  86850. /**
  86851. * Defines a target to use with MorphTargetManager
  86852. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86853. */
  86854. export class MorphTarget implements IAnimatable {
  86855. /** defines the name of the target */
  86856. name: string;
  86857. /**
  86858. * Gets or sets the list of animations
  86859. */
  86860. animations: Animation[];
  86861. private _scene;
  86862. private _positions;
  86863. private _normals;
  86864. private _tangents;
  86865. private _uvs;
  86866. private _influence;
  86867. /**
  86868. * Observable raised when the influence changes
  86869. */
  86870. onInfluenceChanged: Observable<boolean>;
  86871. /** @hidden */
  86872. _onDataLayoutChanged: Observable<void>;
  86873. /**
  86874. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86875. */
  86876. influence: number;
  86877. /**
  86878. * Gets or sets the id of the morph Target
  86879. */
  86880. id: string;
  86881. private _animationPropertiesOverride;
  86882. /**
  86883. * Gets or sets the animation properties override
  86884. */
  86885. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86886. /**
  86887. * Creates a new MorphTarget
  86888. * @param name defines the name of the target
  86889. * @param influence defines the influence to use
  86890. * @param scene defines the scene the morphtarget belongs to
  86891. */
  86892. constructor(
  86893. /** defines the name of the target */
  86894. name: string, influence?: number, scene?: Nullable<Scene>);
  86895. /**
  86896. * Gets a boolean defining if the target contains position data
  86897. */
  86898. readonly hasPositions: boolean;
  86899. /**
  86900. * Gets a boolean defining if the target contains normal data
  86901. */
  86902. readonly hasNormals: boolean;
  86903. /**
  86904. * Gets a boolean defining if the target contains tangent data
  86905. */
  86906. readonly hasTangents: boolean;
  86907. /**
  86908. * Gets a boolean defining if the target contains texture coordinates data
  86909. */
  86910. readonly hasUVs: boolean;
  86911. /**
  86912. * Affects position data to this target
  86913. * @param data defines the position data to use
  86914. */
  86915. setPositions(data: Nullable<FloatArray>): void;
  86916. /**
  86917. * Gets the position data stored in this target
  86918. * @returns a FloatArray containing the position data (or null if not present)
  86919. */
  86920. getPositions(): Nullable<FloatArray>;
  86921. /**
  86922. * Affects normal data to this target
  86923. * @param data defines the normal data to use
  86924. */
  86925. setNormals(data: Nullable<FloatArray>): void;
  86926. /**
  86927. * Gets the normal data stored in this target
  86928. * @returns a FloatArray containing the normal data (or null if not present)
  86929. */
  86930. getNormals(): Nullable<FloatArray>;
  86931. /**
  86932. * Affects tangent data to this target
  86933. * @param data defines the tangent data to use
  86934. */
  86935. setTangents(data: Nullable<FloatArray>): void;
  86936. /**
  86937. * Gets the tangent data stored in this target
  86938. * @returns a FloatArray containing the tangent data (or null if not present)
  86939. */
  86940. getTangents(): Nullable<FloatArray>;
  86941. /**
  86942. * Affects texture coordinates data to this target
  86943. * @param data defines the texture coordinates data to use
  86944. */
  86945. setUVs(data: Nullable<FloatArray>): void;
  86946. /**
  86947. * Gets the texture coordinates data stored in this target
  86948. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86949. */
  86950. getUVs(): Nullable<FloatArray>;
  86951. /**
  86952. * Serializes the current target into a Serialization object
  86953. * @returns the serialized object
  86954. */
  86955. serialize(): any;
  86956. /**
  86957. * Returns the string "MorphTarget"
  86958. * @returns "MorphTarget"
  86959. */
  86960. getClassName(): string;
  86961. /**
  86962. * Creates a new target from serialized data
  86963. * @param serializationObject defines the serialized data to use
  86964. * @returns a new MorphTarget
  86965. */
  86966. static Parse(serializationObject: any): MorphTarget;
  86967. /**
  86968. * Creates a MorphTarget from mesh data
  86969. * @param mesh defines the source mesh
  86970. * @param name defines the name to use for the new target
  86971. * @param influence defines the influence to attach to the target
  86972. * @returns a new MorphTarget
  86973. */
  86974. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86975. }
  86976. }
  86977. declare module BABYLON {
  86978. /**
  86979. * This class is used to deform meshes using morphing between different targets
  86980. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86981. */
  86982. export class MorphTargetManager {
  86983. private _targets;
  86984. private _targetInfluenceChangedObservers;
  86985. private _targetDataLayoutChangedObservers;
  86986. private _activeTargets;
  86987. private _scene;
  86988. private _influences;
  86989. private _supportsNormals;
  86990. private _supportsTangents;
  86991. private _supportsUVs;
  86992. private _vertexCount;
  86993. private _uniqueId;
  86994. private _tempInfluences;
  86995. /**
  86996. * Gets or sets a boolean indicating if normals must be morphed
  86997. */
  86998. enableNormalMorphing: boolean;
  86999. /**
  87000. * Gets or sets a boolean indicating if tangents must be morphed
  87001. */
  87002. enableTangentMorphing: boolean;
  87003. /**
  87004. * Gets or sets a boolean indicating if UV must be morphed
  87005. */
  87006. enableUVMorphing: boolean;
  87007. /**
  87008. * Creates a new MorphTargetManager
  87009. * @param scene defines the current scene
  87010. */
  87011. constructor(scene?: Nullable<Scene>);
  87012. /**
  87013. * Gets the unique ID of this manager
  87014. */
  87015. readonly uniqueId: number;
  87016. /**
  87017. * Gets the number of vertices handled by this manager
  87018. */
  87019. readonly vertexCount: number;
  87020. /**
  87021. * Gets a boolean indicating if this manager supports morphing of normals
  87022. */
  87023. readonly supportsNormals: boolean;
  87024. /**
  87025. * Gets a boolean indicating if this manager supports morphing of tangents
  87026. */
  87027. readonly supportsTangents: boolean;
  87028. /**
  87029. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87030. */
  87031. readonly supportsUVs: boolean;
  87032. /**
  87033. * Gets the number of targets stored in this manager
  87034. */
  87035. readonly numTargets: number;
  87036. /**
  87037. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87038. */
  87039. readonly numInfluencers: number;
  87040. /**
  87041. * Gets the list of influences (one per target)
  87042. */
  87043. readonly influences: Float32Array;
  87044. /**
  87045. * Gets the active target at specified index. An active target is a target with an influence > 0
  87046. * @param index defines the index to check
  87047. * @returns the requested target
  87048. */
  87049. getActiveTarget(index: number): MorphTarget;
  87050. /**
  87051. * Gets the target at specified index
  87052. * @param index defines the index to check
  87053. * @returns the requested target
  87054. */
  87055. getTarget(index: number): MorphTarget;
  87056. /**
  87057. * Add a new target to this manager
  87058. * @param target defines the target to add
  87059. */
  87060. addTarget(target: MorphTarget): void;
  87061. /**
  87062. * Removes a target from the manager
  87063. * @param target defines the target to remove
  87064. */
  87065. removeTarget(target: MorphTarget): void;
  87066. /**
  87067. * Serializes the current manager into a Serialization object
  87068. * @returns the serialized object
  87069. */
  87070. serialize(): any;
  87071. private _syncActiveTargets;
  87072. /**
  87073. * Syncrhonize the targets with all the meshes using this morph target manager
  87074. */
  87075. synchronize(): void;
  87076. /**
  87077. * Creates a new MorphTargetManager from serialized data
  87078. * @param serializationObject defines the serialized data
  87079. * @param scene defines the hosting scene
  87080. * @returns the new MorphTargetManager
  87081. */
  87082. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87083. }
  87084. }
  87085. declare module BABYLON {
  87086. /**
  87087. * Class used to represent a specific level of detail of a mesh
  87088. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87089. */
  87090. export class MeshLODLevel {
  87091. /** Defines the distance where this level should star being displayed */
  87092. distance: number;
  87093. /** Defines the mesh to use to render this level */
  87094. mesh: Nullable<Mesh>;
  87095. /**
  87096. * Creates a new LOD level
  87097. * @param distance defines the distance where this level should star being displayed
  87098. * @param mesh defines the mesh to use to render this level
  87099. */
  87100. constructor(
  87101. /** Defines the distance where this level should star being displayed */
  87102. distance: number,
  87103. /** Defines the mesh to use to render this level */
  87104. mesh: Nullable<Mesh>);
  87105. }
  87106. }
  87107. declare module BABYLON {
  87108. /**
  87109. * Mesh representing the gorund
  87110. */
  87111. export class GroundMesh extends Mesh {
  87112. /** If octree should be generated */
  87113. generateOctree: boolean;
  87114. private _heightQuads;
  87115. /** @hidden */
  87116. _subdivisionsX: number;
  87117. /** @hidden */
  87118. _subdivisionsY: number;
  87119. /** @hidden */
  87120. _width: number;
  87121. /** @hidden */
  87122. _height: number;
  87123. /** @hidden */
  87124. _minX: number;
  87125. /** @hidden */
  87126. _maxX: number;
  87127. /** @hidden */
  87128. _minZ: number;
  87129. /** @hidden */
  87130. _maxZ: number;
  87131. constructor(name: string, scene: Scene);
  87132. /**
  87133. * "GroundMesh"
  87134. * @returns "GroundMesh"
  87135. */
  87136. getClassName(): string;
  87137. /**
  87138. * The minimum of x and y subdivisions
  87139. */
  87140. readonly subdivisions: number;
  87141. /**
  87142. * X subdivisions
  87143. */
  87144. readonly subdivisionsX: number;
  87145. /**
  87146. * Y subdivisions
  87147. */
  87148. readonly subdivisionsY: number;
  87149. /**
  87150. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87151. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87152. * @param chunksCount the number of subdivisions for x and y
  87153. * @param octreeBlocksSize (Default: 32)
  87154. */
  87155. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87156. /**
  87157. * Returns a height (y) value in the Worl system :
  87158. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87159. * @param x x coordinate
  87160. * @param z z coordinate
  87161. * @returns the ground y position if (x, z) are outside the ground surface.
  87162. */
  87163. getHeightAtCoordinates(x: number, z: number): number;
  87164. /**
  87165. * Returns a normalized vector (Vector3) orthogonal to the ground
  87166. * at the ground coordinates (x, z) expressed in the World system.
  87167. * @param x x coordinate
  87168. * @param z z coordinate
  87169. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87170. */
  87171. getNormalAtCoordinates(x: number, z: number): Vector3;
  87172. /**
  87173. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87174. * at the ground coordinates (x, z) expressed in the World system.
  87175. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87176. * @param x x coordinate
  87177. * @param z z coordinate
  87178. * @param ref vector to store the result
  87179. * @returns the GroundMesh.
  87180. */
  87181. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87182. /**
  87183. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87184. * if the ground has been updated.
  87185. * This can be used in the render loop.
  87186. * @returns the GroundMesh.
  87187. */
  87188. updateCoordinateHeights(): GroundMesh;
  87189. private _getFacetAt;
  87190. private _initHeightQuads;
  87191. private _computeHeightQuads;
  87192. /**
  87193. * Serializes this ground mesh
  87194. * @param serializationObject object to write serialization to
  87195. */
  87196. serialize(serializationObject: any): void;
  87197. /**
  87198. * Parses a serialized ground mesh
  87199. * @param parsedMesh the serialized mesh
  87200. * @param scene the scene to create the ground mesh in
  87201. * @returns the created ground mesh
  87202. */
  87203. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87204. }
  87205. }
  87206. declare module BABYLON {
  87207. /**
  87208. * Interface for Physics-Joint data
  87209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87210. */
  87211. export interface PhysicsJointData {
  87212. /**
  87213. * The main pivot of the joint
  87214. */
  87215. mainPivot?: Vector3;
  87216. /**
  87217. * The connected pivot of the joint
  87218. */
  87219. connectedPivot?: Vector3;
  87220. /**
  87221. * The main axis of the joint
  87222. */
  87223. mainAxis?: Vector3;
  87224. /**
  87225. * The connected axis of the joint
  87226. */
  87227. connectedAxis?: Vector3;
  87228. /**
  87229. * The collision of the joint
  87230. */
  87231. collision?: boolean;
  87232. /**
  87233. * Native Oimo/Cannon/Energy data
  87234. */
  87235. nativeParams?: any;
  87236. }
  87237. /**
  87238. * This is a holder class for the physics joint created by the physics plugin
  87239. * It holds a set of functions to control the underlying joint
  87240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87241. */
  87242. export class PhysicsJoint {
  87243. /**
  87244. * The type of the physics joint
  87245. */
  87246. type: number;
  87247. /**
  87248. * The data for the physics joint
  87249. */
  87250. jointData: PhysicsJointData;
  87251. private _physicsJoint;
  87252. protected _physicsPlugin: IPhysicsEnginePlugin;
  87253. /**
  87254. * Initializes the physics joint
  87255. * @param type The type of the physics joint
  87256. * @param jointData The data for the physics joint
  87257. */
  87258. constructor(
  87259. /**
  87260. * The type of the physics joint
  87261. */
  87262. type: number,
  87263. /**
  87264. * The data for the physics joint
  87265. */
  87266. jointData: PhysicsJointData);
  87267. /**
  87268. * Gets the physics joint
  87269. */
  87270. /**
  87271. * Sets the physics joint
  87272. */
  87273. physicsJoint: any;
  87274. /**
  87275. * Sets the physics plugin
  87276. */
  87277. physicsPlugin: IPhysicsEnginePlugin;
  87278. /**
  87279. * Execute a function that is physics-plugin specific.
  87280. * @param {Function} func the function that will be executed.
  87281. * It accepts two parameters: the physics world and the physics joint
  87282. */
  87283. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87284. /**
  87285. * Distance-Joint type
  87286. */
  87287. static DistanceJoint: number;
  87288. /**
  87289. * Hinge-Joint type
  87290. */
  87291. static HingeJoint: number;
  87292. /**
  87293. * Ball-and-Socket joint type
  87294. */
  87295. static BallAndSocketJoint: number;
  87296. /**
  87297. * Wheel-Joint type
  87298. */
  87299. static WheelJoint: number;
  87300. /**
  87301. * Slider-Joint type
  87302. */
  87303. static SliderJoint: number;
  87304. /**
  87305. * Prismatic-Joint type
  87306. */
  87307. static PrismaticJoint: number;
  87308. /**
  87309. * Universal-Joint type
  87310. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87311. */
  87312. static UniversalJoint: number;
  87313. /**
  87314. * Hinge-Joint 2 type
  87315. */
  87316. static Hinge2Joint: number;
  87317. /**
  87318. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87319. */
  87320. static PointToPointJoint: number;
  87321. /**
  87322. * Spring-Joint type
  87323. */
  87324. static SpringJoint: number;
  87325. /**
  87326. * Lock-Joint type
  87327. */
  87328. static LockJoint: number;
  87329. }
  87330. /**
  87331. * A class representing a physics distance joint
  87332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87333. */
  87334. export class DistanceJoint extends PhysicsJoint {
  87335. /**
  87336. *
  87337. * @param jointData The data for the Distance-Joint
  87338. */
  87339. constructor(jointData: DistanceJointData);
  87340. /**
  87341. * Update the predefined distance.
  87342. * @param maxDistance The maximum preferred distance
  87343. * @param minDistance The minimum preferred distance
  87344. */
  87345. updateDistance(maxDistance: number, minDistance?: number): void;
  87346. }
  87347. /**
  87348. * Represents a Motor-Enabled Joint
  87349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87350. */
  87351. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87352. /**
  87353. * Initializes the Motor-Enabled Joint
  87354. * @param type The type of the joint
  87355. * @param jointData The physica joint data for the joint
  87356. */
  87357. constructor(type: number, jointData: PhysicsJointData);
  87358. /**
  87359. * Set the motor values.
  87360. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87361. * @param force the force to apply
  87362. * @param maxForce max force for this motor.
  87363. */
  87364. setMotor(force?: number, maxForce?: number): void;
  87365. /**
  87366. * Set the motor's limits.
  87367. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87368. * @param upperLimit The upper limit of the motor
  87369. * @param lowerLimit The lower limit of the motor
  87370. */
  87371. setLimit(upperLimit: number, lowerLimit?: number): void;
  87372. }
  87373. /**
  87374. * This class represents a single physics Hinge-Joint
  87375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87376. */
  87377. export class HingeJoint extends MotorEnabledJoint {
  87378. /**
  87379. * Initializes the Hinge-Joint
  87380. * @param jointData The joint data for the Hinge-Joint
  87381. */
  87382. constructor(jointData: PhysicsJointData);
  87383. /**
  87384. * Set the motor values.
  87385. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87386. * @param {number} force the force to apply
  87387. * @param {number} maxForce max force for this motor.
  87388. */
  87389. setMotor(force?: number, maxForce?: number): void;
  87390. /**
  87391. * Set the motor's limits.
  87392. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87393. * @param upperLimit The upper limit of the motor
  87394. * @param lowerLimit The lower limit of the motor
  87395. */
  87396. setLimit(upperLimit: number, lowerLimit?: number): void;
  87397. }
  87398. /**
  87399. * This class represents a dual hinge physics joint (same as wheel joint)
  87400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87401. */
  87402. export class Hinge2Joint extends MotorEnabledJoint {
  87403. /**
  87404. * Initializes the Hinge2-Joint
  87405. * @param jointData The joint data for the Hinge2-Joint
  87406. */
  87407. constructor(jointData: PhysicsJointData);
  87408. /**
  87409. * Set the motor values.
  87410. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87411. * @param {number} targetSpeed the speed the motor is to reach
  87412. * @param {number} maxForce max force for this motor.
  87413. * @param {motorIndex} the motor's index, 0 or 1.
  87414. */
  87415. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87416. /**
  87417. * Set the motor limits.
  87418. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87419. * @param {number} upperLimit the upper limit
  87420. * @param {number} lowerLimit lower limit
  87421. * @param {motorIndex} the motor's index, 0 or 1.
  87422. */
  87423. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87424. }
  87425. /**
  87426. * Interface for a motor enabled joint
  87427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87428. */
  87429. export interface IMotorEnabledJoint {
  87430. /**
  87431. * Physics joint
  87432. */
  87433. physicsJoint: any;
  87434. /**
  87435. * Sets the motor of the motor-enabled joint
  87436. * @param force The force of the motor
  87437. * @param maxForce The maximum force of the motor
  87438. * @param motorIndex The index of the motor
  87439. */
  87440. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87441. /**
  87442. * Sets the limit of the motor
  87443. * @param upperLimit The upper limit of the motor
  87444. * @param lowerLimit The lower limit of the motor
  87445. * @param motorIndex The index of the motor
  87446. */
  87447. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87448. }
  87449. /**
  87450. * Joint data for a Distance-Joint
  87451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87452. */
  87453. export interface DistanceJointData extends PhysicsJointData {
  87454. /**
  87455. * Max distance the 2 joint objects can be apart
  87456. */
  87457. maxDistance: number;
  87458. }
  87459. /**
  87460. * Joint data from a spring joint
  87461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87462. */
  87463. export interface SpringJointData extends PhysicsJointData {
  87464. /**
  87465. * Length of the spring
  87466. */
  87467. length: number;
  87468. /**
  87469. * Stiffness of the spring
  87470. */
  87471. stiffness: number;
  87472. /**
  87473. * Damping of the spring
  87474. */
  87475. damping: number;
  87476. /** this callback will be called when applying the force to the impostors. */
  87477. forceApplicationCallback: () => void;
  87478. }
  87479. }
  87480. declare module BABYLON {
  87481. /**
  87482. * Holds the data for the raycast result
  87483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87484. */
  87485. export class PhysicsRaycastResult {
  87486. private _hasHit;
  87487. private _hitDistance;
  87488. private _hitNormalWorld;
  87489. private _hitPointWorld;
  87490. private _rayFromWorld;
  87491. private _rayToWorld;
  87492. /**
  87493. * Gets if there was a hit
  87494. */
  87495. readonly hasHit: boolean;
  87496. /**
  87497. * Gets the distance from the hit
  87498. */
  87499. readonly hitDistance: number;
  87500. /**
  87501. * Gets the hit normal/direction in the world
  87502. */
  87503. readonly hitNormalWorld: Vector3;
  87504. /**
  87505. * Gets the hit point in the world
  87506. */
  87507. readonly hitPointWorld: Vector3;
  87508. /**
  87509. * Gets the ray "start point" of the ray in the world
  87510. */
  87511. readonly rayFromWorld: Vector3;
  87512. /**
  87513. * Gets the ray "end point" of the ray in the world
  87514. */
  87515. readonly rayToWorld: Vector3;
  87516. /**
  87517. * Sets the hit data (normal & point in world space)
  87518. * @param hitNormalWorld defines the normal in world space
  87519. * @param hitPointWorld defines the point in world space
  87520. */
  87521. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87522. /**
  87523. * Sets the distance from the start point to the hit point
  87524. * @param distance
  87525. */
  87526. setHitDistance(distance: number): void;
  87527. /**
  87528. * Calculates the distance manually
  87529. */
  87530. calculateHitDistance(): void;
  87531. /**
  87532. * Resets all the values to default
  87533. * @param from The from point on world space
  87534. * @param to The to point on world space
  87535. */
  87536. reset(from?: Vector3, to?: Vector3): void;
  87537. }
  87538. /**
  87539. * Interface for the size containing width and height
  87540. */
  87541. interface IXYZ {
  87542. /**
  87543. * X
  87544. */
  87545. x: number;
  87546. /**
  87547. * Y
  87548. */
  87549. y: number;
  87550. /**
  87551. * Z
  87552. */
  87553. z: number;
  87554. }
  87555. }
  87556. declare module BABYLON {
  87557. /**
  87558. * Interface used to describe a physics joint
  87559. */
  87560. export interface PhysicsImpostorJoint {
  87561. /** Defines the main impostor to which the joint is linked */
  87562. mainImpostor: PhysicsImpostor;
  87563. /** Defines the impostor that is connected to the main impostor using this joint */
  87564. connectedImpostor: PhysicsImpostor;
  87565. /** Defines the joint itself */
  87566. joint: PhysicsJoint;
  87567. }
  87568. /** @hidden */
  87569. export interface IPhysicsEnginePlugin {
  87570. world: any;
  87571. name: string;
  87572. setGravity(gravity: Vector3): void;
  87573. setTimeStep(timeStep: number): void;
  87574. getTimeStep(): number;
  87575. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  87576. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87577. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  87579. removePhysicsBody(impostor: PhysicsImpostor): void;
  87580. generateJoint(joint: PhysicsImpostorJoint): void;
  87581. removeJoint(joint: PhysicsImpostorJoint): void;
  87582. isSupported(): boolean;
  87583. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87584. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87585. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87586. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87587. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87588. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87589. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87590. getBodyMass(impostor: PhysicsImpostor): number;
  87591. getBodyFriction(impostor: PhysicsImpostor): number;
  87592. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87593. getBodyRestitution(impostor: PhysicsImpostor): number;
  87594. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87595. getBodyPressure?(impostor: PhysicsImpostor): number;
  87596. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87597. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87598. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87599. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87600. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87601. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87602. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87603. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87604. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87605. sleepBody(impostor: PhysicsImpostor): void;
  87606. wakeUpBody(impostor: PhysicsImpostor): void;
  87607. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87608. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87609. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87610. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87611. getRadius(impostor: PhysicsImpostor): number;
  87612. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87613. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87614. dispose(): void;
  87615. }
  87616. /**
  87617. * Interface used to define a physics engine
  87618. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87619. */
  87620. export interface IPhysicsEngine {
  87621. /**
  87622. * Gets the gravity vector used by the simulation
  87623. */
  87624. gravity: Vector3;
  87625. /**
  87626. * Sets the gravity vector used by the simulation
  87627. * @param gravity defines the gravity vector to use
  87628. */
  87629. setGravity(gravity: Vector3): void;
  87630. /**
  87631. * Set the time step of the physics engine.
  87632. * Default is 1/60.
  87633. * To slow it down, enter 1/600 for example.
  87634. * To speed it up, 1/30
  87635. * @param newTimeStep the new timestep to apply to this world.
  87636. */
  87637. setTimeStep(newTimeStep: number): void;
  87638. /**
  87639. * Get the time step of the physics engine.
  87640. * @returns the current time step
  87641. */
  87642. getTimeStep(): number;
  87643. /**
  87644. * Release all resources
  87645. */
  87646. dispose(): void;
  87647. /**
  87648. * Gets the name of the current physics plugin
  87649. * @returns the name of the plugin
  87650. */
  87651. getPhysicsPluginName(): string;
  87652. /**
  87653. * Adding a new impostor for the impostor tracking.
  87654. * This will be done by the impostor itself.
  87655. * @param impostor the impostor to add
  87656. */
  87657. addImpostor(impostor: PhysicsImpostor): void;
  87658. /**
  87659. * Remove an impostor from the engine.
  87660. * This impostor and its mesh will not longer be updated by the physics engine.
  87661. * @param impostor the impostor to remove
  87662. */
  87663. removeImpostor(impostor: PhysicsImpostor): void;
  87664. /**
  87665. * Add a joint to the physics engine
  87666. * @param mainImpostor defines the main impostor to which the joint is added.
  87667. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87668. * @param joint defines the joint that will connect both impostors.
  87669. */
  87670. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87671. /**
  87672. * Removes a joint from the simulation
  87673. * @param mainImpostor defines the impostor used with the joint
  87674. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87675. * @param joint defines the joint to remove
  87676. */
  87677. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87678. /**
  87679. * Gets the current plugin used to run the simulation
  87680. * @returns current plugin
  87681. */
  87682. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87683. /**
  87684. * Gets the list of physic impostors
  87685. * @returns an array of PhysicsImpostor
  87686. */
  87687. getImpostors(): Array<PhysicsImpostor>;
  87688. /**
  87689. * Gets the impostor for a physics enabled object
  87690. * @param object defines the object impersonated by the impostor
  87691. * @returns the PhysicsImpostor or null if not found
  87692. */
  87693. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87694. /**
  87695. * Gets the impostor for a physics body object
  87696. * @param body defines physics body used by the impostor
  87697. * @returns the PhysicsImpostor or null if not found
  87698. */
  87699. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87700. /**
  87701. * Does a raycast in the physics world
  87702. * @param from when should the ray start?
  87703. * @param to when should the ray end?
  87704. * @returns PhysicsRaycastResult
  87705. */
  87706. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87707. /**
  87708. * Called by the scene. No need to call it.
  87709. * @param delta defines the timespam between frames
  87710. */
  87711. _step(delta: number): void;
  87712. }
  87713. }
  87714. declare module BABYLON {
  87715. /**
  87716. * The interface for the physics imposter parameters
  87717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87718. */
  87719. export interface PhysicsImpostorParameters {
  87720. /**
  87721. * The mass of the physics imposter
  87722. */
  87723. mass: number;
  87724. /**
  87725. * The friction of the physics imposter
  87726. */
  87727. friction?: number;
  87728. /**
  87729. * The coefficient of restitution of the physics imposter
  87730. */
  87731. restitution?: number;
  87732. /**
  87733. * The native options of the physics imposter
  87734. */
  87735. nativeOptions?: any;
  87736. /**
  87737. * Specifies if the parent should be ignored
  87738. */
  87739. ignoreParent?: boolean;
  87740. /**
  87741. * Specifies if bi-directional transformations should be disabled
  87742. */
  87743. disableBidirectionalTransformation?: boolean;
  87744. /**
  87745. * The pressure inside the physics imposter, soft object only
  87746. */
  87747. pressure?: number;
  87748. /**
  87749. * The stiffness the physics imposter, soft object only
  87750. */
  87751. stiffness?: number;
  87752. /**
  87753. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87754. */
  87755. velocityIterations?: number;
  87756. /**
  87757. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87758. */
  87759. positionIterations?: number;
  87760. /**
  87761. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87762. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87763. * Add to fix multiple points
  87764. */
  87765. fixedPoints?: number;
  87766. /**
  87767. * The collision margin around a soft object
  87768. */
  87769. margin?: number;
  87770. /**
  87771. * The collision margin around a soft object
  87772. */
  87773. damping?: number;
  87774. /**
  87775. * The path for a rope based on an extrusion
  87776. */
  87777. path?: any;
  87778. /**
  87779. * The shape of an extrusion used for a rope based on an extrusion
  87780. */
  87781. shape?: any;
  87782. }
  87783. /**
  87784. * Interface for a physics-enabled object
  87785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87786. */
  87787. export interface IPhysicsEnabledObject {
  87788. /**
  87789. * The position of the physics-enabled object
  87790. */
  87791. position: Vector3;
  87792. /**
  87793. * The rotation of the physics-enabled object
  87794. */
  87795. rotationQuaternion: Nullable<Quaternion>;
  87796. /**
  87797. * The scale of the physics-enabled object
  87798. */
  87799. scaling: Vector3;
  87800. /**
  87801. * The rotation of the physics-enabled object
  87802. */
  87803. rotation?: Vector3;
  87804. /**
  87805. * The parent of the physics-enabled object
  87806. */
  87807. parent?: any;
  87808. /**
  87809. * The bounding info of the physics-enabled object
  87810. * @returns The bounding info of the physics-enabled object
  87811. */
  87812. getBoundingInfo(): BoundingInfo;
  87813. /**
  87814. * Computes the world matrix
  87815. * @param force Specifies if the world matrix should be computed by force
  87816. * @returns A world matrix
  87817. */
  87818. computeWorldMatrix(force: boolean): Matrix;
  87819. /**
  87820. * Gets the world matrix
  87821. * @returns A world matrix
  87822. */
  87823. getWorldMatrix?(): Matrix;
  87824. /**
  87825. * Gets the child meshes
  87826. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87827. * @returns An array of abstract meshes
  87828. */
  87829. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87830. /**
  87831. * Gets the vertex data
  87832. * @param kind The type of vertex data
  87833. * @returns A nullable array of numbers, or a float32 array
  87834. */
  87835. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87836. /**
  87837. * Gets the indices from the mesh
  87838. * @returns A nullable array of index arrays
  87839. */
  87840. getIndices?(): Nullable<IndicesArray>;
  87841. /**
  87842. * Gets the scene from the mesh
  87843. * @returns the indices array or null
  87844. */
  87845. getScene?(): Scene;
  87846. /**
  87847. * Gets the absolute position from the mesh
  87848. * @returns the absolute position
  87849. */
  87850. getAbsolutePosition(): Vector3;
  87851. /**
  87852. * Gets the absolute pivot point from the mesh
  87853. * @returns the absolute pivot point
  87854. */
  87855. getAbsolutePivotPoint(): Vector3;
  87856. /**
  87857. * Rotates the mesh
  87858. * @param axis The axis of rotation
  87859. * @param amount The amount of rotation
  87860. * @param space The space of the rotation
  87861. * @returns The rotation transform node
  87862. */
  87863. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87864. /**
  87865. * Translates the mesh
  87866. * @param axis The axis of translation
  87867. * @param distance The distance of translation
  87868. * @param space The space of the translation
  87869. * @returns The transform node
  87870. */
  87871. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87872. /**
  87873. * Sets the absolute position of the mesh
  87874. * @param absolutePosition The absolute position of the mesh
  87875. * @returns The transform node
  87876. */
  87877. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87878. /**
  87879. * Gets the class name of the mesh
  87880. * @returns The class name
  87881. */
  87882. getClassName(): string;
  87883. }
  87884. /**
  87885. * Represents a physics imposter
  87886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87887. */
  87888. export class PhysicsImpostor {
  87889. /**
  87890. * The physics-enabled object used as the physics imposter
  87891. */
  87892. object: IPhysicsEnabledObject;
  87893. /**
  87894. * The type of the physics imposter
  87895. */
  87896. type: number;
  87897. private _options;
  87898. private _scene?;
  87899. /**
  87900. * The default object size of the imposter
  87901. */
  87902. static DEFAULT_OBJECT_SIZE: Vector3;
  87903. /**
  87904. * The identity quaternion of the imposter
  87905. */
  87906. static IDENTITY_QUATERNION: Quaternion;
  87907. /** @hidden */
  87908. _pluginData: any;
  87909. private _physicsEngine;
  87910. private _physicsBody;
  87911. private _bodyUpdateRequired;
  87912. private _onBeforePhysicsStepCallbacks;
  87913. private _onAfterPhysicsStepCallbacks;
  87914. /** @hidden */
  87915. _onPhysicsCollideCallbacks: Array<{
  87916. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87917. otherImpostors: Array<PhysicsImpostor>;
  87918. }>;
  87919. private _deltaPosition;
  87920. private _deltaRotation;
  87921. private _deltaRotationConjugated;
  87922. /** @hidden */
  87923. _isFromLine: boolean;
  87924. private _parent;
  87925. private _isDisposed;
  87926. private static _tmpVecs;
  87927. private static _tmpQuat;
  87928. /**
  87929. * Specifies if the physics imposter is disposed
  87930. */
  87931. readonly isDisposed: boolean;
  87932. /**
  87933. * Gets the mass of the physics imposter
  87934. */
  87935. mass: number;
  87936. /**
  87937. * Gets the coefficient of friction
  87938. */
  87939. /**
  87940. * Sets the coefficient of friction
  87941. */
  87942. friction: number;
  87943. /**
  87944. * Gets the coefficient of restitution
  87945. */
  87946. /**
  87947. * Sets the coefficient of restitution
  87948. */
  87949. restitution: number;
  87950. /**
  87951. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87952. */
  87953. /**
  87954. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87955. */
  87956. pressure: number;
  87957. /**
  87958. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87959. */
  87960. /**
  87961. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87962. */
  87963. stiffness: number;
  87964. /**
  87965. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87966. */
  87967. /**
  87968. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87969. */
  87970. velocityIterations: number;
  87971. /**
  87972. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87973. */
  87974. /**
  87975. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87976. */
  87977. positionIterations: number;
  87978. /**
  87979. * The unique id of the physics imposter
  87980. * set by the physics engine when adding this impostor to the array
  87981. */
  87982. uniqueId: number;
  87983. /**
  87984. * @hidden
  87985. */
  87986. soft: boolean;
  87987. /**
  87988. * @hidden
  87989. */
  87990. segments: number;
  87991. private _joints;
  87992. /**
  87993. * Initializes the physics imposter
  87994. * @param object The physics-enabled object used as the physics imposter
  87995. * @param type The type of the physics imposter
  87996. * @param _options The options for the physics imposter
  87997. * @param _scene The Babylon scene
  87998. */
  87999. constructor(
  88000. /**
  88001. * The physics-enabled object used as the physics imposter
  88002. */
  88003. object: IPhysicsEnabledObject,
  88004. /**
  88005. * The type of the physics imposter
  88006. */
  88007. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88008. /**
  88009. * This function will completly initialize this impostor.
  88010. * It will create a new body - but only if this mesh has no parent.
  88011. * If it has, this impostor will not be used other than to define the impostor
  88012. * of the child mesh.
  88013. * @hidden
  88014. */
  88015. _init(): void;
  88016. private _getPhysicsParent;
  88017. /**
  88018. * Should a new body be generated.
  88019. * @returns boolean specifying if body initialization is required
  88020. */
  88021. isBodyInitRequired(): boolean;
  88022. /**
  88023. * Sets the updated scaling
  88024. * @param updated Specifies if the scaling is updated
  88025. */
  88026. setScalingUpdated(): void;
  88027. /**
  88028. * Force a regeneration of this or the parent's impostor's body.
  88029. * Use under cautious - This will remove all joints already implemented.
  88030. */
  88031. forceUpdate(): void;
  88032. /**
  88033. * Gets the body that holds this impostor. Either its own, or its parent.
  88034. */
  88035. /**
  88036. * Set the physics body. Used mainly by the physics engine/plugin
  88037. */
  88038. physicsBody: any;
  88039. /**
  88040. * Get the parent of the physics imposter
  88041. * @returns Physics imposter or null
  88042. */
  88043. /**
  88044. * Sets the parent of the physics imposter
  88045. */
  88046. parent: Nullable<PhysicsImpostor>;
  88047. /**
  88048. * Resets the update flags
  88049. */
  88050. resetUpdateFlags(): void;
  88051. /**
  88052. * Gets the object extend size
  88053. * @returns the object extend size
  88054. */
  88055. getObjectExtendSize(): Vector3;
  88056. /**
  88057. * Gets the object center
  88058. * @returns The object center
  88059. */
  88060. getObjectCenter(): Vector3;
  88061. /**
  88062. * Get a specific parametes from the options parameter
  88063. * @param paramName The object parameter name
  88064. * @returns The object parameter
  88065. */
  88066. getParam(paramName: string): any;
  88067. /**
  88068. * Sets a specific parameter in the options given to the physics plugin
  88069. * @param paramName The parameter name
  88070. * @param value The value of the parameter
  88071. */
  88072. setParam(paramName: string, value: number): void;
  88073. /**
  88074. * Specifically change the body's mass option. Won't recreate the physics body object
  88075. * @param mass The mass of the physics imposter
  88076. */
  88077. setMass(mass: number): void;
  88078. /**
  88079. * Gets the linear velocity
  88080. * @returns linear velocity or null
  88081. */
  88082. getLinearVelocity(): Nullable<Vector3>;
  88083. /**
  88084. * Sets the linear velocity
  88085. * @param velocity linear velocity or null
  88086. */
  88087. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88088. /**
  88089. * Gets the angular velocity
  88090. * @returns angular velocity or null
  88091. */
  88092. getAngularVelocity(): Nullable<Vector3>;
  88093. /**
  88094. * Sets the angular velocity
  88095. * @param velocity The velocity or null
  88096. */
  88097. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88098. /**
  88099. * Execute a function with the physics plugin native code
  88100. * Provide a function the will have two variables - the world object and the physics body object
  88101. * @param func The function to execute with the physics plugin native code
  88102. */
  88103. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88104. /**
  88105. * Register a function that will be executed before the physics world is stepping forward
  88106. * @param func The function to execute before the physics world is stepped forward
  88107. */
  88108. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88109. /**
  88110. * Unregister a function that will be executed before the physics world is stepping forward
  88111. * @param func The function to execute before the physics world is stepped forward
  88112. */
  88113. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88114. /**
  88115. * Register a function that will be executed after the physics step
  88116. * @param func The function to execute after physics step
  88117. */
  88118. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88119. /**
  88120. * Unregisters a function that will be executed after the physics step
  88121. * @param func The function to execute after physics step
  88122. */
  88123. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88124. /**
  88125. * register a function that will be executed when this impostor collides against a different body
  88126. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88127. * @param func Callback that is executed on collision
  88128. */
  88129. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88130. /**
  88131. * Unregisters the physics imposter on contact
  88132. * @param collideAgainst The physics object to collide against
  88133. * @param func Callback to execute on collision
  88134. */
  88135. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88136. private _tmpQuat;
  88137. private _tmpQuat2;
  88138. /**
  88139. * Get the parent rotation
  88140. * @returns The parent rotation
  88141. */
  88142. getParentsRotation(): Quaternion;
  88143. /**
  88144. * this function is executed by the physics engine.
  88145. */
  88146. beforeStep: () => void;
  88147. /**
  88148. * this function is executed by the physics engine
  88149. */
  88150. afterStep: () => void;
  88151. /**
  88152. * Legacy collision detection event support
  88153. */
  88154. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88155. /**
  88156. * event and body object due to cannon's event-based architecture.
  88157. */
  88158. onCollide: (e: {
  88159. body: any;
  88160. }) => void;
  88161. /**
  88162. * Apply a force
  88163. * @param force The force to apply
  88164. * @param contactPoint The contact point for the force
  88165. * @returns The physics imposter
  88166. */
  88167. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88168. /**
  88169. * Apply an impulse
  88170. * @param force The impulse force
  88171. * @param contactPoint The contact point for the impulse force
  88172. * @returns The physics imposter
  88173. */
  88174. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88175. /**
  88176. * A help function to create a joint
  88177. * @param otherImpostor A physics imposter used to create a joint
  88178. * @param jointType The type of joint
  88179. * @param jointData The data for the joint
  88180. * @returns The physics imposter
  88181. */
  88182. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88183. /**
  88184. * Add a joint to this impostor with a different impostor
  88185. * @param otherImpostor A physics imposter used to add a joint
  88186. * @param joint The joint to add
  88187. * @returns The physics imposter
  88188. */
  88189. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88190. /**
  88191. * Add an anchor to a cloth impostor
  88192. * @param otherImpostor rigid impostor to anchor to
  88193. * @param width ratio across width from 0 to 1
  88194. * @param height ratio up height from 0 to 1
  88195. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88196. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88197. * @returns impostor the soft imposter
  88198. */
  88199. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88200. /**
  88201. * Add a hook to a rope impostor
  88202. * @param otherImpostor rigid impostor to anchor to
  88203. * @param length ratio across rope from 0 to 1
  88204. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88205. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88206. * @returns impostor the rope imposter
  88207. */
  88208. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88209. /**
  88210. * Will keep this body still, in a sleep mode.
  88211. * @returns the physics imposter
  88212. */
  88213. sleep(): PhysicsImpostor;
  88214. /**
  88215. * Wake the body up.
  88216. * @returns The physics imposter
  88217. */
  88218. wakeUp(): PhysicsImpostor;
  88219. /**
  88220. * Clones the physics imposter
  88221. * @param newObject The physics imposter clones to this physics-enabled object
  88222. * @returns A nullable physics imposter
  88223. */
  88224. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88225. /**
  88226. * Disposes the physics imposter
  88227. */
  88228. dispose(): void;
  88229. /**
  88230. * Sets the delta position
  88231. * @param position The delta position amount
  88232. */
  88233. setDeltaPosition(position: Vector3): void;
  88234. /**
  88235. * Sets the delta rotation
  88236. * @param rotation The delta rotation amount
  88237. */
  88238. setDeltaRotation(rotation: Quaternion): void;
  88239. /**
  88240. * Gets the box size of the physics imposter and stores the result in the input parameter
  88241. * @param result Stores the box size
  88242. * @returns The physics imposter
  88243. */
  88244. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88245. /**
  88246. * Gets the radius of the physics imposter
  88247. * @returns Radius of the physics imposter
  88248. */
  88249. getRadius(): number;
  88250. /**
  88251. * Sync a bone with this impostor
  88252. * @param bone The bone to sync to the impostor.
  88253. * @param boneMesh The mesh that the bone is influencing.
  88254. * @param jointPivot The pivot of the joint / bone in local space.
  88255. * @param distToJoint Optional distance from the impostor to the joint.
  88256. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88257. */
  88258. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88259. /**
  88260. * Sync impostor to a bone
  88261. * @param bone The bone that the impostor will be synced to.
  88262. * @param boneMesh The mesh that the bone is influencing.
  88263. * @param jointPivot The pivot of the joint / bone in local space.
  88264. * @param distToJoint Optional distance from the impostor to the joint.
  88265. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88266. * @param boneAxis Optional vector3 axis the bone is aligned with
  88267. */
  88268. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88269. /**
  88270. * No-Imposter type
  88271. */
  88272. static NoImpostor: number;
  88273. /**
  88274. * Sphere-Imposter type
  88275. */
  88276. static SphereImpostor: number;
  88277. /**
  88278. * Box-Imposter type
  88279. */
  88280. static BoxImpostor: number;
  88281. /**
  88282. * Plane-Imposter type
  88283. */
  88284. static PlaneImpostor: number;
  88285. /**
  88286. * Mesh-imposter type
  88287. */
  88288. static MeshImpostor: number;
  88289. /**
  88290. * Capsule-Impostor type (Ammo.js plugin only)
  88291. */
  88292. static CapsuleImpostor: number;
  88293. /**
  88294. * Cylinder-Imposter type
  88295. */
  88296. static CylinderImpostor: number;
  88297. /**
  88298. * Particle-Imposter type
  88299. */
  88300. static ParticleImpostor: number;
  88301. /**
  88302. * Heightmap-Imposter type
  88303. */
  88304. static HeightmapImpostor: number;
  88305. /**
  88306. * ConvexHull-Impostor type (Ammo.js plugin only)
  88307. */
  88308. static ConvexHullImpostor: number;
  88309. /**
  88310. * Rope-Imposter type
  88311. */
  88312. static RopeImpostor: number;
  88313. /**
  88314. * Cloth-Imposter type
  88315. */
  88316. static ClothImpostor: number;
  88317. /**
  88318. * Softbody-Imposter type
  88319. */
  88320. static SoftbodyImpostor: number;
  88321. }
  88322. }
  88323. declare module BABYLON {
  88324. /**
  88325. * @hidden
  88326. **/
  88327. export class _CreationDataStorage {
  88328. closePath?: boolean;
  88329. closeArray?: boolean;
  88330. idx: number[];
  88331. dashSize: number;
  88332. gapSize: number;
  88333. path3D: Path3D;
  88334. pathArray: Vector3[][];
  88335. arc: number;
  88336. radius: number;
  88337. cap: number;
  88338. tessellation: number;
  88339. }
  88340. /**
  88341. * @hidden
  88342. **/
  88343. class _InstanceDataStorage {
  88344. visibleInstances: any;
  88345. batchCache: _InstancesBatch;
  88346. instancesBufferSize: number;
  88347. instancesBuffer: Nullable<Buffer>;
  88348. instancesData: Float32Array;
  88349. overridenInstanceCount: number;
  88350. isFrozen: boolean;
  88351. previousBatch: Nullable<_InstancesBatch>;
  88352. hardwareInstancedRendering: boolean;
  88353. sideOrientation: number;
  88354. }
  88355. /**
  88356. * @hidden
  88357. **/
  88358. export class _InstancesBatch {
  88359. mustReturn: boolean;
  88360. visibleInstances: Nullable<InstancedMesh[]>[];
  88361. renderSelf: boolean[];
  88362. hardwareInstancedRendering: boolean[];
  88363. }
  88364. /**
  88365. * Class used to represent renderable models
  88366. */
  88367. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88368. /**
  88369. * Mesh side orientation : usually the external or front surface
  88370. */
  88371. static readonly FRONTSIDE: number;
  88372. /**
  88373. * Mesh side orientation : usually the internal or back surface
  88374. */
  88375. static readonly BACKSIDE: number;
  88376. /**
  88377. * Mesh side orientation : both internal and external or front and back surfaces
  88378. */
  88379. static readonly DOUBLESIDE: number;
  88380. /**
  88381. * Mesh side orientation : by default, `FRONTSIDE`
  88382. */
  88383. static readonly DEFAULTSIDE: number;
  88384. /**
  88385. * Mesh cap setting : no cap
  88386. */
  88387. static readonly NO_CAP: number;
  88388. /**
  88389. * Mesh cap setting : one cap at the beginning of the mesh
  88390. */
  88391. static readonly CAP_START: number;
  88392. /**
  88393. * Mesh cap setting : one cap at the end of the mesh
  88394. */
  88395. static readonly CAP_END: number;
  88396. /**
  88397. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88398. */
  88399. static readonly CAP_ALL: number;
  88400. /**
  88401. * Mesh pattern setting : no flip or rotate
  88402. */
  88403. static readonly NO_FLIP: number;
  88404. /**
  88405. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88406. */
  88407. static readonly FLIP_TILE: number;
  88408. /**
  88409. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88410. */
  88411. static readonly ROTATE_TILE: number;
  88412. /**
  88413. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88414. */
  88415. static readonly FLIP_ROW: number;
  88416. /**
  88417. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88418. */
  88419. static readonly ROTATE_ROW: number;
  88420. /**
  88421. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88422. */
  88423. static readonly FLIP_N_ROTATE_TILE: number;
  88424. /**
  88425. * Mesh pattern setting : rotate pattern and rotate
  88426. */
  88427. static readonly FLIP_N_ROTATE_ROW: number;
  88428. /**
  88429. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88430. */
  88431. static readonly CENTER: number;
  88432. /**
  88433. * Mesh tile positioning : part tiles on left
  88434. */
  88435. static readonly LEFT: number;
  88436. /**
  88437. * Mesh tile positioning : part tiles on right
  88438. */
  88439. static readonly RIGHT: number;
  88440. /**
  88441. * Mesh tile positioning : part tiles on top
  88442. */
  88443. static readonly TOP: number;
  88444. /**
  88445. * Mesh tile positioning : part tiles on bottom
  88446. */
  88447. static readonly BOTTOM: number;
  88448. /**
  88449. * Gets the default side orientation.
  88450. * @param orientation the orientation to value to attempt to get
  88451. * @returns the default orientation
  88452. * @hidden
  88453. */
  88454. static _GetDefaultSideOrientation(orientation?: number): number;
  88455. private _internalMeshDataInfo;
  88456. /**
  88457. * An event triggered before rendering the mesh
  88458. */
  88459. readonly onBeforeRenderObservable: Observable<Mesh>;
  88460. /**
  88461. * An event triggered before binding the mesh
  88462. */
  88463. readonly onBeforeBindObservable: Observable<Mesh>;
  88464. /**
  88465. * An event triggered after rendering the mesh
  88466. */
  88467. readonly onAfterRenderObservable: Observable<Mesh>;
  88468. /**
  88469. * An event triggered before drawing the mesh
  88470. */
  88471. readonly onBeforeDrawObservable: Observable<Mesh>;
  88472. private _onBeforeDrawObserver;
  88473. /**
  88474. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88475. */
  88476. onBeforeDraw: () => void;
  88477. readonly hasInstances: boolean;
  88478. /**
  88479. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88480. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88481. */
  88482. delayLoadState: number;
  88483. /**
  88484. * Gets the list of instances created from this mesh
  88485. * it is not supposed to be modified manually.
  88486. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88487. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88488. */
  88489. instances: InstancedMesh[];
  88490. /**
  88491. * Gets the file containing delay loading data for this mesh
  88492. */
  88493. delayLoadingFile: string;
  88494. /** @hidden */
  88495. _binaryInfo: any;
  88496. /**
  88497. * User defined function used to change how LOD level selection is done
  88498. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88499. */
  88500. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88501. /**
  88502. * Gets or sets the morph target manager
  88503. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88504. */
  88505. morphTargetManager: Nullable<MorphTargetManager>;
  88506. /** @hidden */
  88507. _creationDataStorage: Nullable<_CreationDataStorage>;
  88508. /** @hidden */
  88509. _geometry: Nullable<Geometry>;
  88510. /** @hidden */
  88511. _delayInfo: Array<string>;
  88512. /** @hidden */
  88513. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88514. /** @hidden */
  88515. _instanceDataStorage: _InstanceDataStorage;
  88516. private _effectiveMaterial;
  88517. /** @hidden */
  88518. _shouldGenerateFlatShading: boolean;
  88519. /** @hidden */
  88520. _originalBuilderSideOrientation: number;
  88521. /**
  88522. * Use this property to change the original side orientation defined at construction time
  88523. */
  88524. overrideMaterialSideOrientation: Nullable<number>;
  88525. /**
  88526. * Gets the source mesh (the one used to clone this one from)
  88527. */
  88528. readonly source: Nullable<Mesh>;
  88529. /**
  88530. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88531. */
  88532. isUnIndexed: boolean;
  88533. /**
  88534. * @constructor
  88535. * @param name The value used by scene.getMeshByName() to do a lookup.
  88536. * @param scene The scene to add this mesh to.
  88537. * @param parent The parent of this mesh, if it has one
  88538. * @param source An optional Mesh from which geometry is shared, cloned.
  88539. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88540. * When false, achieved by calling a clone(), also passing False.
  88541. * This will make creation of children, recursive.
  88542. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88543. */
  88544. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88545. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88546. /**
  88547. * Gets the class name
  88548. * @returns the string "Mesh".
  88549. */
  88550. getClassName(): string;
  88551. /** @hidden */
  88552. readonly _isMesh: boolean;
  88553. /**
  88554. * Returns a description of this mesh
  88555. * @param fullDetails define if full details about this mesh must be used
  88556. * @returns a descriptive string representing this mesh
  88557. */
  88558. toString(fullDetails?: boolean): string;
  88559. /** @hidden */
  88560. _unBindEffect(): void;
  88561. /**
  88562. * Gets a boolean indicating if this mesh has LOD
  88563. */
  88564. readonly hasLODLevels: boolean;
  88565. /**
  88566. * Gets the list of MeshLODLevel associated with the current mesh
  88567. * @returns an array of MeshLODLevel
  88568. */
  88569. getLODLevels(): MeshLODLevel[];
  88570. private _sortLODLevels;
  88571. /**
  88572. * Add a mesh as LOD level triggered at the given distance.
  88573. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88574. * @param distance The distance from the center of the object to show this level
  88575. * @param mesh The mesh to be added as LOD level (can be null)
  88576. * @return This mesh (for chaining)
  88577. */
  88578. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  88579. /**
  88580. * Returns the LOD level mesh at the passed distance or null if not found.
  88581. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88582. * @param distance The distance from the center of the object to show this level
  88583. * @returns a Mesh or `null`
  88584. */
  88585. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88586. /**
  88587. * Remove a mesh from the LOD array
  88588. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88589. * @param mesh defines the mesh to be removed
  88590. * @return This mesh (for chaining)
  88591. */
  88592. removeLODLevel(mesh: Mesh): Mesh;
  88593. /**
  88594. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88595. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88596. * @param camera defines the camera to use to compute distance
  88597. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88598. * @return This mesh (for chaining)
  88599. */
  88600. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88601. /**
  88602. * Gets the mesh internal Geometry object
  88603. */
  88604. readonly geometry: Nullable<Geometry>;
  88605. /**
  88606. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88607. * @returns the total number of vertices
  88608. */
  88609. getTotalVertices(): number;
  88610. /**
  88611. * Returns the content of an associated vertex buffer
  88612. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88613. * - VertexBuffer.PositionKind
  88614. * - VertexBuffer.UVKind
  88615. * - VertexBuffer.UV2Kind
  88616. * - VertexBuffer.UV3Kind
  88617. * - VertexBuffer.UV4Kind
  88618. * - VertexBuffer.UV5Kind
  88619. * - VertexBuffer.UV6Kind
  88620. * - VertexBuffer.ColorKind
  88621. * - VertexBuffer.MatricesIndicesKind
  88622. * - VertexBuffer.MatricesIndicesExtraKind
  88623. * - VertexBuffer.MatricesWeightsKind
  88624. * - VertexBuffer.MatricesWeightsExtraKind
  88625. * @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
  88626. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88627. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88628. */
  88629. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88630. /**
  88631. * Returns the mesh VertexBuffer object from the requested `kind`
  88632. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88633. * - VertexBuffer.PositionKind
  88634. * - VertexBuffer.NormalKind
  88635. * - VertexBuffer.UVKind
  88636. * - VertexBuffer.UV2Kind
  88637. * - VertexBuffer.UV3Kind
  88638. * - VertexBuffer.UV4Kind
  88639. * - VertexBuffer.UV5Kind
  88640. * - VertexBuffer.UV6Kind
  88641. * - VertexBuffer.ColorKind
  88642. * - VertexBuffer.MatricesIndicesKind
  88643. * - VertexBuffer.MatricesIndicesExtraKind
  88644. * - VertexBuffer.MatricesWeightsKind
  88645. * - VertexBuffer.MatricesWeightsExtraKind
  88646. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88647. */
  88648. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88649. /**
  88650. * Tests if a specific vertex buffer is associated with this mesh
  88651. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88652. * - VertexBuffer.PositionKind
  88653. * - VertexBuffer.NormalKind
  88654. * - VertexBuffer.UVKind
  88655. * - VertexBuffer.UV2Kind
  88656. * - VertexBuffer.UV3Kind
  88657. * - VertexBuffer.UV4Kind
  88658. * - VertexBuffer.UV5Kind
  88659. * - VertexBuffer.UV6Kind
  88660. * - VertexBuffer.ColorKind
  88661. * - VertexBuffer.MatricesIndicesKind
  88662. * - VertexBuffer.MatricesIndicesExtraKind
  88663. * - VertexBuffer.MatricesWeightsKind
  88664. * - VertexBuffer.MatricesWeightsExtraKind
  88665. * @returns a boolean
  88666. */
  88667. isVerticesDataPresent(kind: string): boolean;
  88668. /**
  88669. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88670. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88671. * - VertexBuffer.PositionKind
  88672. * - VertexBuffer.UVKind
  88673. * - VertexBuffer.UV2Kind
  88674. * - VertexBuffer.UV3Kind
  88675. * - VertexBuffer.UV4Kind
  88676. * - VertexBuffer.UV5Kind
  88677. * - VertexBuffer.UV6Kind
  88678. * - VertexBuffer.ColorKind
  88679. * - VertexBuffer.MatricesIndicesKind
  88680. * - VertexBuffer.MatricesIndicesExtraKind
  88681. * - VertexBuffer.MatricesWeightsKind
  88682. * - VertexBuffer.MatricesWeightsExtraKind
  88683. * @returns a boolean
  88684. */
  88685. isVertexBufferUpdatable(kind: string): boolean;
  88686. /**
  88687. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88688. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88689. * - VertexBuffer.PositionKind
  88690. * - VertexBuffer.NormalKind
  88691. * - VertexBuffer.UVKind
  88692. * - VertexBuffer.UV2Kind
  88693. * - VertexBuffer.UV3Kind
  88694. * - VertexBuffer.UV4Kind
  88695. * - VertexBuffer.UV5Kind
  88696. * - VertexBuffer.UV6Kind
  88697. * - VertexBuffer.ColorKind
  88698. * - VertexBuffer.MatricesIndicesKind
  88699. * - VertexBuffer.MatricesIndicesExtraKind
  88700. * - VertexBuffer.MatricesWeightsKind
  88701. * - VertexBuffer.MatricesWeightsExtraKind
  88702. * @returns an array of strings
  88703. */
  88704. getVerticesDataKinds(): string[];
  88705. /**
  88706. * Returns a positive integer : the total number of indices in this mesh geometry.
  88707. * @returns the numner of indices or zero if the mesh has no geometry.
  88708. */
  88709. getTotalIndices(): number;
  88710. /**
  88711. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88712. * @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.
  88713. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88714. * @returns the indices array or an empty array if the mesh has no geometry
  88715. */
  88716. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88717. readonly isBlocked: boolean;
  88718. /**
  88719. * Determine if the current mesh is ready to be rendered
  88720. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88721. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88722. * @returns true if all associated assets are ready (material, textures, shaders)
  88723. */
  88724. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88725. /**
  88726. * 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.
  88727. */
  88728. readonly areNormalsFrozen: boolean;
  88729. /**
  88730. * 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.
  88731. * @returns the current mesh
  88732. */
  88733. freezeNormals(): Mesh;
  88734. /**
  88735. * 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
  88736. * @returns the current mesh
  88737. */
  88738. unfreezeNormals(): Mesh;
  88739. /**
  88740. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88741. */
  88742. overridenInstanceCount: number;
  88743. /** @hidden */
  88744. _preActivate(): Mesh;
  88745. /** @hidden */
  88746. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88747. /** @hidden */
  88748. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88749. /**
  88750. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88751. * This means the mesh underlying bounding box and sphere are recomputed.
  88752. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88753. * @returns the current mesh
  88754. */
  88755. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88756. /** @hidden */
  88757. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88758. /**
  88759. * This function will subdivide the mesh into multiple submeshes
  88760. * @param count defines the expected number of submeshes
  88761. */
  88762. subdivide(count: number): void;
  88763. /**
  88764. * Copy a FloatArray into a specific associated vertex buffer
  88765. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88766. * - VertexBuffer.PositionKind
  88767. * - VertexBuffer.UVKind
  88768. * - VertexBuffer.UV2Kind
  88769. * - VertexBuffer.UV3Kind
  88770. * - VertexBuffer.UV4Kind
  88771. * - VertexBuffer.UV5Kind
  88772. * - VertexBuffer.UV6Kind
  88773. * - VertexBuffer.ColorKind
  88774. * - VertexBuffer.MatricesIndicesKind
  88775. * - VertexBuffer.MatricesIndicesExtraKind
  88776. * - VertexBuffer.MatricesWeightsKind
  88777. * - VertexBuffer.MatricesWeightsExtraKind
  88778. * @param data defines the data source
  88779. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88780. * @param stride defines the data stride size (can be null)
  88781. * @returns the current mesh
  88782. */
  88783. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88784. /**
  88785. * Flags an associated vertex buffer as updatable
  88786. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88787. * - VertexBuffer.PositionKind
  88788. * - VertexBuffer.UVKind
  88789. * - VertexBuffer.UV2Kind
  88790. * - VertexBuffer.UV3Kind
  88791. * - VertexBuffer.UV4Kind
  88792. * - VertexBuffer.UV5Kind
  88793. * - VertexBuffer.UV6Kind
  88794. * - VertexBuffer.ColorKind
  88795. * - VertexBuffer.MatricesIndicesKind
  88796. * - VertexBuffer.MatricesIndicesExtraKind
  88797. * - VertexBuffer.MatricesWeightsKind
  88798. * - VertexBuffer.MatricesWeightsExtraKind
  88799. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88800. */
  88801. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88802. /**
  88803. * Sets the mesh global Vertex Buffer
  88804. * @param buffer defines the buffer to use
  88805. * @returns the current mesh
  88806. */
  88807. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88808. /**
  88809. * Update a specific associated vertex buffer
  88810. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88811. * - VertexBuffer.PositionKind
  88812. * - VertexBuffer.UVKind
  88813. * - VertexBuffer.UV2Kind
  88814. * - VertexBuffer.UV3Kind
  88815. * - VertexBuffer.UV4Kind
  88816. * - VertexBuffer.UV5Kind
  88817. * - VertexBuffer.UV6Kind
  88818. * - VertexBuffer.ColorKind
  88819. * - VertexBuffer.MatricesIndicesKind
  88820. * - VertexBuffer.MatricesIndicesExtraKind
  88821. * - VertexBuffer.MatricesWeightsKind
  88822. * - VertexBuffer.MatricesWeightsExtraKind
  88823. * @param data defines the data source
  88824. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88825. * @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)
  88826. * @returns the current mesh
  88827. */
  88828. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  88829. /**
  88830. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88831. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88832. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88833. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88834. * @returns the current mesh
  88835. */
  88836. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88837. /**
  88838. * Creates a un-shared specific occurence of the geometry for the mesh.
  88839. * @returns the current mesh
  88840. */
  88841. makeGeometryUnique(): Mesh;
  88842. /**
  88843. * Set the index buffer of this mesh
  88844. * @param indices defines the source data
  88845. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88846. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88847. * @returns the current mesh
  88848. */
  88849. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  88850. /**
  88851. * Update the current index buffer
  88852. * @param indices defines the source data
  88853. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88854. * @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)
  88855. * @returns the current mesh
  88856. */
  88857. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88858. /**
  88859. * Invert the geometry to move from a right handed system to a left handed one.
  88860. * @returns the current mesh
  88861. */
  88862. toLeftHanded(): Mesh;
  88863. /** @hidden */
  88864. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88865. /** @hidden */
  88866. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88867. /**
  88868. * Registers for this mesh a javascript function called just before the rendering process
  88869. * @param func defines the function to call before rendering this mesh
  88870. * @returns the current mesh
  88871. */
  88872. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88873. /**
  88874. * Disposes a previously registered javascript function called before the rendering
  88875. * @param func defines the function to remove
  88876. * @returns the current mesh
  88877. */
  88878. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88879. /**
  88880. * Registers for this mesh a javascript function called just after the rendering is complete
  88881. * @param func defines the function to call after rendering this mesh
  88882. * @returns the current mesh
  88883. */
  88884. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88885. /**
  88886. * Disposes a previously registered javascript function called after the rendering.
  88887. * @param func defines the function to remove
  88888. * @returns the current mesh
  88889. */
  88890. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88891. /** @hidden */
  88892. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88893. /** @hidden */
  88894. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88895. /** @hidden */
  88896. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88897. /** @hidden */
  88898. _rebuild(): void;
  88899. /** @hidden */
  88900. _freeze(): void;
  88901. /** @hidden */
  88902. _unFreeze(): void;
  88903. /**
  88904. * 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
  88905. * @param subMesh defines the subMesh to render
  88906. * @param enableAlphaMode defines if alpha mode can be changed
  88907. * @returns the current mesh
  88908. */
  88909. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88910. private _onBeforeDraw;
  88911. /**
  88912. * Renormalize the mesh and patch it up if there are no weights
  88913. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88914. * However in the case of zero weights then we set just a single influence to 1.
  88915. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88916. */
  88917. cleanMatrixWeights(): void;
  88918. private normalizeSkinFourWeights;
  88919. private normalizeSkinWeightsAndExtra;
  88920. /**
  88921. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88922. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88923. * the user know there was an issue with importing the mesh
  88924. * @returns a validation object with skinned, valid and report string
  88925. */
  88926. validateSkinning(): {
  88927. skinned: boolean;
  88928. valid: boolean;
  88929. report: string;
  88930. };
  88931. /** @hidden */
  88932. _checkDelayState(): Mesh;
  88933. private _queueLoad;
  88934. /**
  88935. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88936. * A mesh is in the frustum if its bounding box intersects the frustum
  88937. * @param frustumPlanes defines the frustum to test
  88938. * @returns true if the mesh is in the frustum planes
  88939. */
  88940. isInFrustum(frustumPlanes: Plane[]): boolean;
  88941. /**
  88942. * Sets the mesh material by the material or multiMaterial `id` property
  88943. * @param id is a string identifying the material or the multiMaterial
  88944. * @returns the current mesh
  88945. */
  88946. setMaterialByID(id: string): Mesh;
  88947. /**
  88948. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88949. * @returns an array of IAnimatable
  88950. */
  88951. getAnimatables(): IAnimatable[];
  88952. /**
  88953. * Modifies the mesh geometry according to the passed transformation matrix.
  88954. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88955. * The mesh normals are modified using the same transformation.
  88956. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88957. * @param transform defines the transform matrix to use
  88958. * @see http://doc.babylonjs.com/resources/baking_transformations
  88959. * @returns the current mesh
  88960. */
  88961. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88962. /**
  88963. * Modifies the mesh geometry according to its own current World Matrix.
  88964. * The mesh World Matrix is then reset.
  88965. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88966. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88967. * @see http://doc.babylonjs.com/resources/baking_transformations
  88968. * @returns the current mesh
  88969. */
  88970. bakeCurrentTransformIntoVertices(): Mesh;
  88971. /** @hidden */
  88972. readonly _positions: Nullable<Vector3[]>;
  88973. /** @hidden */
  88974. _resetPointsArrayCache(): Mesh;
  88975. /** @hidden */
  88976. _generatePointsArray(): boolean;
  88977. /**
  88978. * Returns a new Mesh object generated from the current mesh properties.
  88979. * This method must not get confused with createInstance()
  88980. * @param name is a string, the name given to the new mesh
  88981. * @param newParent can be any Node object (default `null`)
  88982. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88983. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88984. * @returns a new mesh
  88985. */
  88986. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  88987. /**
  88988. * Releases resources associated with this mesh.
  88989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88991. */
  88992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88993. /**
  88994. * Modifies the mesh geometry according to a displacement map.
  88995. * 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.
  88996. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88997. * @param url is a string, the URL from the image file is to be downloaded.
  88998. * @param minHeight is the lower limit of the displacement.
  88999. * @param maxHeight is the upper limit of the displacement.
  89000. * @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.
  89001. * @param uvOffset is an optional vector2 used to offset UV.
  89002. * @param uvScale is an optional vector2 used to scale UV.
  89003. * @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.
  89004. * @returns the Mesh.
  89005. */
  89006. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89007. /**
  89008. * Modifies the mesh geometry according to a displacementMap buffer.
  89009. * 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.
  89010. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89011. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89012. * @param heightMapWidth is the width of the buffer image.
  89013. * @param heightMapHeight is the height of the buffer image.
  89014. * @param minHeight is the lower limit of the displacement.
  89015. * @param maxHeight is the upper limit of the displacement.
  89016. * @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.
  89017. * @param uvOffset is an optional vector2 used to offset UV.
  89018. * @param uvScale is an optional vector2 used to scale UV.
  89019. * @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.
  89020. * @returns the Mesh.
  89021. */
  89022. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89023. /**
  89024. * Modify the mesh to get a flat shading rendering.
  89025. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89026. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89027. * @returns current mesh
  89028. */
  89029. convertToFlatShadedMesh(): Mesh;
  89030. /**
  89031. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89032. * In other words, more vertices, no more indices and a single bigger VBO.
  89033. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89034. * @returns current mesh
  89035. */
  89036. convertToUnIndexedMesh(): Mesh;
  89037. /**
  89038. * Inverses facet orientations.
  89039. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89040. * @param flipNormals will also inverts the normals
  89041. * @returns current mesh
  89042. */
  89043. flipFaces(flipNormals?: boolean): Mesh;
  89044. /**
  89045. * Increase the number of facets and hence vertices in a mesh
  89046. * Vertex normals are interpolated from existing vertex normals
  89047. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89048. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89049. */
  89050. increaseVertices(numberPerEdge: number): void;
  89051. /**
  89052. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89053. * This will undo any application of covertToFlatShadedMesh
  89054. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89055. */
  89056. forceSharedVertices(): void;
  89057. /** @hidden */
  89058. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89059. /** @hidden */
  89060. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89061. /**
  89062. * Creates a new InstancedMesh object from the mesh model.
  89063. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89064. * @param name defines the name of the new instance
  89065. * @returns a new InstancedMesh
  89066. */
  89067. createInstance(name: string): InstancedMesh;
  89068. /**
  89069. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89070. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89071. * @returns the current mesh
  89072. */
  89073. synchronizeInstances(): Mesh;
  89074. /**
  89075. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89076. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89077. * This should be used together with the simplification to avoid disappearing triangles.
  89078. * @param successCallback an optional success callback to be called after the optimization finished.
  89079. * @returns the current mesh
  89080. */
  89081. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89082. /**
  89083. * Serialize current mesh
  89084. * @param serializationObject defines the object which will receive the serialization data
  89085. */
  89086. serialize(serializationObject: any): void;
  89087. /** @hidden */
  89088. _syncGeometryWithMorphTargetManager(): void;
  89089. /** @hidden */
  89090. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89091. /**
  89092. * Returns a new Mesh object parsed from the source provided.
  89093. * @param parsedMesh is the source
  89094. * @param scene defines the hosting scene
  89095. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89096. * @returns a new Mesh
  89097. */
  89098. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89099. /**
  89100. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89101. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89102. * @param name defines the name of the mesh to create
  89103. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89104. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89105. * @param closePath creates a seam between the first and the last points of each path of the path array
  89106. * @param offset is taken in account only if the `pathArray` is containing a single path
  89107. * @param scene defines the hosting scene
  89108. * @param updatable defines if the mesh must be flagged as updatable
  89109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89110. * @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)
  89111. * @returns a new Mesh
  89112. */
  89113. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89114. /**
  89115. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89116. * @param name defines the name of the mesh to create
  89117. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89118. * @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
  89119. * @param scene defines the hosting scene
  89120. * @param updatable defines if the mesh must be flagged as updatable
  89121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89122. * @returns a new Mesh
  89123. */
  89124. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89125. /**
  89126. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89127. * @param name defines the name of the mesh to create
  89128. * @param size sets the size (float) of each box side (default 1)
  89129. * @param scene defines the hosting scene
  89130. * @param updatable defines if the mesh must be flagged as updatable
  89131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89132. * @returns a new Mesh
  89133. */
  89134. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89135. /**
  89136. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89137. * @param name defines the name of the mesh to create
  89138. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89139. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89140. * @param scene defines the hosting scene
  89141. * @param updatable defines if the mesh must be flagged as updatable
  89142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89143. * @returns a new Mesh
  89144. */
  89145. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89146. /**
  89147. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89148. * @param name defines the name of the mesh to create
  89149. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89150. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89151. * @param scene defines the hosting scene
  89152. * @returns a new Mesh
  89153. */
  89154. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89155. /**
  89156. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89157. * @param name defines the name of the mesh to create
  89158. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89159. * @param diameterTop set the top cap diameter (floats, default 1)
  89160. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89161. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89162. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89163. * @param scene defines the hosting scene
  89164. * @param updatable defines if the mesh must be flagged as updatable
  89165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89166. * @returns a new Mesh
  89167. */
  89168. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89169. /**
  89170. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89171. * @param name defines the name of the mesh to create
  89172. * @param diameter sets the diameter size (float) of the torus (default 1)
  89173. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89174. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89175. * @param scene defines the hosting scene
  89176. * @param updatable defines if the mesh must be flagged as updatable
  89177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89178. * @returns a new Mesh
  89179. */
  89180. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89181. /**
  89182. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89183. * @param name defines the name of the mesh to create
  89184. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89185. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89186. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89187. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89188. * @param p the number of windings on X axis (positive integers, default 2)
  89189. * @param q the number of windings on Y axis (positive integers, default 3)
  89190. * @param scene defines the hosting scene
  89191. * @param updatable defines if the mesh must be flagged as updatable
  89192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89193. * @returns a new Mesh
  89194. */
  89195. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89196. /**
  89197. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89198. * @param name defines the name of the mesh to create
  89199. * @param points is an array successive Vector3
  89200. * @param scene defines the hosting scene
  89201. * @param updatable defines if the mesh must be flagged as updatable
  89202. * @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).
  89203. * @returns a new Mesh
  89204. */
  89205. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89206. /**
  89207. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89208. * @param name defines the name of the mesh to create
  89209. * @param points is an array successive Vector3
  89210. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89211. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89212. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89213. * @param scene defines the hosting scene
  89214. * @param updatable defines if the mesh must be flagged as updatable
  89215. * @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)
  89216. * @returns a new Mesh
  89217. */
  89218. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89219. /**
  89220. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89221. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89222. * 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.
  89223. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89224. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89225. * Remember you can only change the shape positions, not their number when updating a polygon.
  89226. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89227. * @param name defines the name of the mesh to create
  89228. * @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
  89229. * @param scene defines the hosting scene
  89230. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89231. * @param updatable defines if the mesh must be flagged as updatable
  89232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89233. * @param earcutInjection can be used to inject your own earcut reference
  89234. * @returns a new Mesh
  89235. */
  89236. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89237. /**
  89238. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89239. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89240. * @param name defines the name of the mesh to create
  89241. * @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
  89242. * @param depth defines the height of extrusion
  89243. * @param scene defines the hosting scene
  89244. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89245. * @param updatable defines if the mesh must be flagged as updatable
  89246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89247. * @param earcutInjection can be used to inject your own earcut reference
  89248. * @returns a new Mesh
  89249. */
  89250. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89251. /**
  89252. * Creates an extruded shape mesh.
  89253. * 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
  89254. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89255. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89256. * @param name defines the name of the mesh to create
  89257. * @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
  89258. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89259. * @param scale is the value to scale the shape
  89260. * @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
  89261. * @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
  89262. * @param scene defines the hosting scene
  89263. * @param updatable defines if the mesh must be flagged as updatable
  89264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89265. * @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)
  89266. * @returns a new Mesh
  89267. */
  89268. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89269. /**
  89270. * Creates an custom extruded shape mesh.
  89271. * The custom extrusion is a parametric shape.
  89272. * It has no predefined shape. Its final shape will depend on the input parameters.
  89273. * Please consider using the same method from the MeshBuilder class instead
  89274. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89275. * @param name defines the name of the mesh to create
  89276. * @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
  89277. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89278. * @param scaleFunction is a custom Javascript function called on each path point
  89279. * @param rotationFunction is a custom Javascript function called on each path point
  89280. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89281. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89282. * @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
  89283. * @param scene defines the hosting scene
  89284. * @param updatable defines if the mesh must be flagged as updatable
  89285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89286. * @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)
  89287. * @returns a new Mesh
  89288. */
  89289. 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;
  89290. /**
  89291. * Creates lathe mesh.
  89292. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89293. * Please consider using the same method from the MeshBuilder class instead
  89294. * @param name defines the name of the mesh to create
  89295. * @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
  89296. * @param radius is the radius value of the lathe
  89297. * @param tessellation is the side number of the lathe.
  89298. * @param scene defines the hosting scene
  89299. * @param updatable defines if the mesh must be flagged as updatable
  89300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89301. * @returns a new Mesh
  89302. */
  89303. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89304. /**
  89305. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89306. * @param name defines the name of the mesh to create
  89307. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89308. * @param scene defines the hosting scene
  89309. * @param updatable defines if the mesh must be flagged as updatable
  89310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89311. * @returns a new Mesh
  89312. */
  89313. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89314. /**
  89315. * Creates a ground mesh.
  89316. * Please consider using the same method from the MeshBuilder class instead
  89317. * @param name defines the name of the mesh to create
  89318. * @param width set the width of the ground
  89319. * @param height set the height of the ground
  89320. * @param subdivisions sets the number of subdivisions per side
  89321. * @param scene defines the hosting scene
  89322. * @param updatable defines if the mesh must be flagged as updatable
  89323. * @returns a new Mesh
  89324. */
  89325. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89326. /**
  89327. * Creates a tiled ground mesh.
  89328. * Please consider using the same method from the MeshBuilder class instead
  89329. * @param name defines the name of the mesh to create
  89330. * @param xmin set the ground minimum X coordinate
  89331. * @param zmin set the ground minimum Y coordinate
  89332. * @param xmax set the ground maximum X coordinate
  89333. * @param zmax set the ground maximum Z coordinate
  89334. * @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
  89335. * @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
  89336. * @param scene defines the hosting scene
  89337. * @param updatable defines if the mesh must be flagged as updatable
  89338. * @returns a new Mesh
  89339. */
  89340. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89341. w: number;
  89342. h: number;
  89343. }, precision: {
  89344. w: number;
  89345. h: number;
  89346. }, scene: Scene, updatable?: boolean): Mesh;
  89347. /**
  89348. * Creates a ground mesh from a height map.
  89349. * Please consider using the same method from the MeshBuilder class instead
  89350. * @see http://doc.babylonjs.com/babylon101/height_map
  89351. * @param name defines the name of the mesh to create
  89352. * @param url sets the URL of the height map image resource
  89353. * @param width set the ground width size
  89354. * @param height set the ground height size
  89355. * @param subdivisions sets the number of subdivision per side
  89356. * @param minHeight is the minimum altitude on the ground
  89357. * @param maxHeight is the maximum altitude on the ground
  89358. * @param scene defines the hosting scene
  89359. * @param updatable defines if the mesh must be flagged as updatable
  89360. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89361. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89362. * @returns a new Mesh
  89363. */
  89364. 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;
  89365. /**
  89366. * Creates a tube mesh.
  89367. * The tube is a parametric shape.
  89368. * It has no predefined shape. Its final shape will depend on the input parameters.
  89369. * Please consider using the same method from the MeshBuilder class instead
  89370. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89371. * @param name defines the name of the mesh to create
  89372. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89373. * @param radius sets the tube radius size
  89374. * @param tessellation is the number of sides on the tubular surface
  89375. * @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
  89376. * @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
  89377. * @param scene defines the hosting scene
  89378. * @param updatable defines if the mesh must be flagged as updatable
  89379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89380. * @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)
  89381. * @returns a new Mesh
  89382. */
  89383. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89384. (i: number, distance: number): number;
  89385. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89386. /**
  89387. * Creates a polyhedron mesh.
  89388. * Please consider using the same method from the MeshBuilder class instead.
  89389. * * 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
  89390. * * The parameter `size` (positive float, default 1) sets the polygon size
  89391. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89392. * * 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`
  89393. * * 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
  89394. * * 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)`)
  89395. * * 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
  89396. * * 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
  89397. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89398. * * If you create a double-sided mesh, you can choose what parts of 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
  89399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89400. * @param name defines the name of the mesh to create
  89401. * @param options defines the options used to create the mesh
  89402. * @param scene defines the hosting scene
  89403. * @returns a new Mesh
  89404. */
  89405. static CreatePolyhedron(name: string, options: {
  89406. type?: number;
  89407. size?: number;
  89408. sizeX?: number;
  89409. sizeY?: number;
  89410. sizeZ?: number;
  89411. custom?: any;
  89412. faceUV?: Vector4[];
  89413. faceColors?: Color4[];
  89414. updatable?: boolean;
  89415. sideOrientation?: number;
  89416. }, scene: Scene): Mesh;
  89417. /**
  89418. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89419. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89420. * * 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`)
  89421. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89422. * * 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
  89423. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89424. * * If you create a double-sided mesh, you can choose what parts of 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
  89425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89426. * @param name defines the name of the mesh
  89427. * @param options defines the options used to create the mesh
  89428. * @param scene defines the hosting scene
  89429. * @returns a new Mesh
  89430. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89431. */
  89432. static CreateIcoSphere(name: string, options: {
  89433. radius?: number;
  89434. flat?: boolean;
  89435. subdivisions?: number;
  89436. sideOrientation?: number;
  89437. updatable?: boolean;
  89438. }, scene: Scene): Mesh;
  89439. /**
  89440. * Creates a decal mesh.
  89441. * Please consider using the same method from the MeshBuilder class instead.
  89442. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89443. * @param name defines the name of the mesh
  89444. * @param sourceMesh defines the mesh receiving the decal
  89445. * @param position sets the position of the decal in world coordinates
  89446. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89447. * @param size sets the decal scaling
  89448. * @param angle sets the angle to rotate the decal
  89449. * @returns a new Mesh
  89450. */
  89451. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89452. /**
  89453. * Prepare internal position array for software CPU skinning
  89454. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89455. */
  89456. setPositionsForCPUSkinning(): Float32Array;
  89457. /**
  89458. * Prepare internal normal array for software CPU skinning
  89459. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89460. */
  89461. setNormalsForCPUSkinning(): Float32Array;
  89462. /**
  89463. * Updates the vertex buffer by applying transformation from the bones
  89464. * @param skeleton defines the skeleton to apply to current mesh
  89465. * @returns the current mesh
  89466. */
  89467. applySkeleton(skeleton: Skeleton): Mesh;
  89468. /**
  89469. * 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
  89470. * @param meshes defines the list of meshes to scan
  89471. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89472. */
  89473. static MinMax(meshes: AbstractMesh[]): {
  89474. min: Vector3;
  89475. max: Vector3;
  89476. };
  89477. /**
  89478. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89479. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89480. * @returns a vector3
  89481. */
  89482. static Center(meshesOrMinMaxVector: {
  89483. min: Vector3;
  89484. max: Vector3;
  89485. } | AbstractMesh[]): Vector3;
  89486. /**
  89487. * Merge the array of meshes into a single mesh for performance reasons.
  89488. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89489. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89490. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89491. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89492. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89493. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89494. * @returns a new mesh
  89495. */
  89496. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89497. /** @hidden */
  89498. addInstance(instance: InstancedMesh): void;
  89499. /** @hidden */
  89500. removeInstance(instance: InstancedMesh): void;
  89501. }
  89502. }
  89503. declare module BABYLON {
  89504. /**
  89505. * This is the base class of all the camera used in the application.
  89506. * @see http://doc.babylonjs.com/features/cameras
  89507. */
  89508. export class Camera extends Node {
  89509. /** @hidden */
  89510. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89511. /**
  89512. * This is the default projection mode used by the cameras.
  89513. * It helps recreating a feeling of perspective and better appreciate depth.
  89514. * This is the best way to simulate real life cameras.
  89515. */
  89516. static readonly PERSPECTIVE_CAMERA: number;
  89517. /**
  89518. * This helps creating camera with an orthographic mode.
  89519. * 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.
  89520. */
  89521. static readonly ORTHOGRAPHIC_CAMERA: number;
  89522. /**
  89523. * This is the default FOV mode for perspective cameras.
  89524. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89525. */
  89526. static readonly FOVMODE_VERTICAL_FIXED: number;
  89527. /**
  89528. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89529. */
  89530. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89531. /**
  89532. * This specifies ther is no need for a camera rig.
  89533. * Basically only one eye is rendered corresponding to the camera.
  89534. */
  89535. static readonly RIG_MODE_NONE: number;
  89536. /**
  89537. * Simulates a camera Rig with one blue eye and one red eye.
  89538. * This can be use with 3d blue and red glasses.
  89539. */
  89540. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89541. /**
  89542. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89543. */
  89544. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89545. /**
  89546. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89547. */
  89548. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89549. /**
  89550. * Defines that both eyes of the camera will be rendered over under each other.
  89551. */
  89552. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89553. /**
  89554. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89555. */
  89556. static readonly RIG_MODE_VR: number;
  89557. /**
  89558. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89559. */
  89560. static readonly RIG_MODE_WEBVR: number;
  89561. /**
  89562. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89563. */
  89564. static readonly RIG_MODE_CUSTOM: number;
  89565. /**
  89566. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89567. */
  89568. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89569. /**
  89570. * Define the input manager associated with the camera.
  89571. */
  89572. inputs: CameraInputsManager<Camera>;
  89573. /** @hidden */
  89574. _position: Vector3;
  89575. /**
  89576. * Define the current local position of the camera in the scene
  89577. */
  89578. position: Vector3;
  89579. /**
  89580. * The vector the camera should consider as up.
  89581. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89582. */
  89583. upVector: Vector3;
  89584. /**
  89585. * Define the current limit on the left side for an orthographic camera
  89586. * In scene unit
  89587. */
  89588. orthoLeft: Nullable<number>;
  89589. /**
  89590. * Define the current limit on the right side for an orthographic camera
  89591. * In scene unit
  89592. */
  89593. orthoRight: Nullable<number>;
  89594. /**
  89595. * Define the current limit on the bottom side for an orthographic camera
  89596. * In scene unit
  89597. */
  89598. orthoBottom: Nullable<number>;
  89599. /**
  89600. * Define the current limit on the top side for an orthographic camera
  89601. * In scene unit
  89602. */
  89603. orthoTop: Nullable<number>;
  89604. /**
  89605. * Field Of View is set in Radians. (default is 0.8)
  89606. */
  89607. fov: number;
  89608. /**
  89609. * Define the minimum distance the camera can see from.
  89610. * This is important to note that the depth buffer are not infinite and the closer it starts
  89611. * the more your scene might encounter depth fighting issue.
  89612. */
  89613. minZ: number;
  89614. /**
  89615. * Define the maximum distance the camera can see to.
  89616. * This is important to note that the depth buffer are not infinite and the further it end
  89617. * the more your scene might encounter depth fighting issue.
  89618. */
  89619. maxZ: number;
  89620. /**
  89621. * Define the default inertia of the camera.
  89622. * This helps giving a smooth feeling to the camera movement.
  89623. */
  89624. inertia: number;
  89625. /**
  89626. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89627. */
  89628. mode: number;
  89629. /**
  89630. * Define wether the camera is intermediate.
  89631. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89632. */
  89633. isIntermediate: boolean;
  89634. /**
  89635. * Define the viewport of the camera.
  89636. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89637. */
  89638. viewport: Viewport;
  89639. /**
  89640. * Restricts the camera to viewing objects with the same layerMask.
  89641. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89642. */
  89643. layerMask: number;
  89644. /**
  89645. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89646. */
  89647. fovMode: number;
  89648. /**
  89649. * Rig mode of the camera.
  89650. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89651. * This is normally controlled byt the camera themselves as internal use.
  89652. */
  89653. cameraRigMode: number;
  89654. /**
  89655. * Defines the distance between both "eyes" in case of a RIG
  89656. */
  89657. interaxialDistance: number;
  89658. /**
  89659. * Defines if stereoscopic rendering is done side by side or over under.
  89660. */
  89661. isStereoscopicSideBySide: boolean;
  89662. /**
  89663. * 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
  89664. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89665. * else in the scene. (Eg. security camera)
  89666. *
  89667. * 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)
  89668. */
  89669. customRenderTargets: RenderTargetTexture[];
  89670. /**
  89671. * When set, the camera will render to this render target instead of the default canvas
  89672. *
  89673. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89674. */
  89675. outputRenderTarget: Nullable<RenderTargetTexture>;
  89676. /**
  89677. * Observable triggered when the camera view matrix has changed.
  89678. */
  89679. onViewMatrixChangedObservable: Observable<Camera>;
  89680. /**
  89681. * Observable triggered when the camera Projection matrix has changed.
  89682. */
  89683. onProjectionMatrixChangedObservable: Observable<Camera>;
  89684. /**
  89685. * Observable triggered when the inputs have been processed.
  89686. */
  89687. onAfterCheckInputsObservable: Observable<Camera>;
  89688. /**
  89689. * Observable triggered when reset has been called and applied to the camera.
  89690. */
  89691. onRestoreStateObservable: Observable<Camera>;
  89692. /** @hidden */
  89693. _cameraRigParams: any;
  89694. /** @hidden */
  89695. _rigCameras: Camera[];
  89696. /** @hidden */
  89697. _rigPostProcess: Nullable<PostProcess>;
  89698. protected _webvrViewMatrix: Matrix;
  89699. /** @hidden */
  89700. _skipRendering: boolean;
  89701. /** @hidden */
  89702. _projectionMatrix: Matrix;
  89703. /** @hidden */
  89704. _postProcesses: Nullable<PostProcess>[];
  89705. /** @hidden */
  89706. _activeMeshes: SmartArray<AbstractMesh>;
  89707. protected _globalPosition: Vector3;
  89708. /** @hidden */
  89709. _computedViewMatrix: Matrix;
  89710. private _doNotComputeProjectionMatrix;
  89711. private _transformMatrix;
  89712. private _frustumPlanes;
  89713. private _refreshFrustumPlanes;
  89714. private _storedFov;
  89715. private _stateStored;
  89716. /**
  89717. * Instantiates a new camera object.
  89718. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89719. * @see http://doc.babylonjs.com/features/cameras
  89720. * @param name Defines the name of the camera in the scene
  89721. * @param position Defines the position of the camera
  89722. * @param scene Defines the scene the camera belongs too
  89723. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89724. */
  89725. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89726. /**
  89727. * Store current camera state (fov, position, etc..)
  89728. * @returns the camera
  89729. */
  89730. storeState(): Camera;
  89731. /**
  89732. * Restores the camera state values if it has been stored. You must call storeState() first
  89733. */
  89734. protected _restoreStateValues(): boolean;
  89735. /**
  89736. * Restored camera state. You must call storeState() first.
  89737. * @returns true if restored and false otherwise
  89738. */
  89739. restoreState(): boolean;
  89740. /**
  89741. * Gets the class name of the camera.
  89742. * @returns the class name
  89743. */
  89744. getClassName(): string;
  89745. /** @hidden */
  89746. readonly _isCamera: boolean;
  89747. /**
  89748. * Gets a string representation of the camera useful for debug purpose.
  89749. * @param fullDetails Defines that a more verboe level of logging is required
  89750. * @returns the string representation
  89751. */
  89752. toString(fullDetails?: boolean): string;
  89753. /**
  89754. * Gets the current world space position of the camera.
  89755. */
  89756. readonly globalPosition: Vector3;
  89757. /**
  89758. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89759. * @returns the active meshe list
  89760. */
  89761. getActiveMeshes(): SmartArray<AbstractMesh>;
  89762. /**
  89763. * Check wether a mesh is part of the current active mesh list of the camera
  89764. * @param mesh Defines the mesh to check
  89765. * @returns true if active, false otherwise
  89766. */
  89767. isActiveMesh(mesh: Mesh): boolean;
  89768. /**
  89769. * Is this camera ready to be used/rendered
  89770. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89771. * @return true if the camera is ready
  89772. */
  89773. isReady(completeCheck?: boolean): boolean;
  89774. /** @hidden */
  89775. _initCache(): void;
  89776. /** @hidden */
  89777. _updateCache(ignoreParentClass?: boolean): void;
  89778. /** @hidden */
  89779. _isSynchronized(): boolean;
  89780. /** @hidden */
  89781. _isSynchronizedViewMatrix(): boolean;
  89782. /** @hidden */
  89783. _isSynchronizedProjectionMatrix(): boolean;
  89784. /**
  89785. * Attach the input controls to a specific dom element to get the input from.
  89786. * @param element Defines the element the controls should be listened from
  89787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89788. */
  89789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89790. /**
  89791. * Detach the current controls from the specified dom element.
  89792. * @param element Defines the element to stop listening the inputs from
  89793. */
  89794. detachControl(element: HTMLElement): void;
  89795. /**
  89796. * Update the camera state according to the different inputs gathered during the frame.
  89797. */
  89798. update(): void;
  89799. /** @hidden */
  89800. _checkInputs(): void;
  89801. /** @hidden */
  89802. readonly rigCameras: Camera[];
  89803. /**
  89804. * Gets the post process used by the rig cameras
  89805. */
  89806. readonly rigPostProcess: Nullable<PostProcess>;
  89807. /**
  89808. * Internal, gets the first post proces.
  89809. * @returns the first post process to be run on this camera.
  89810. */
  89811. _getFirstPostProcess(): Nullable<PostProcess>;
  89812. private _cascadePostProcessesToRigCams;
  89813. /**
  89814. * Attach a post process to the camera.
  89815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89816. * @param postProcess The post process to attach to the camera
  89817. * @param insertAt The position of the post process in case several of them are in use in the scene
  89818. * @returns the position the post process has been inserted at
  89819. */
  89820. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89821. /**
  89822. * Detach a post process to the camera.
  89823. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89824. * @param postProcess The post process to detach from the camera
  89825. */
  89826. detachPostProcess(postProcess: PostProcess): void;
  89827. /**
  89828. * Gets the current world matrix of the camera
  89829. */
  89830. getWorldMatrix(): Matrix;
  89831. /** @hidden */
  89832. _getViewMatrix(): Matrix;
  89833. /**
  89834. * Gets the current view matrix of the camera.
  89835. * @param force forces the camera to recompute the matrix without looking at the cached state
  89836. * @returns the view matrix
  89837. */
  89838. getViewMatrix(force?: boolean): Matrix;
  89839. /**
  89840. * Freeze the projection matrix.
  89841. * It will prevent the cache check of the camera projection compute and can speed up perf
  89842. * if no parameter of the camera are meant to change
  89843. * @param projection Defines manually a projection if necessary
  89844. */
  89845. freezeProjectionMatrix(projection?: Matrix): void;
  89846. /**
  89847. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89848. */
  89849. unfreezeProjectionMatrix(): void;
  89850. /**
  89851. * Gets the current projection matrix of the camera.
  89852. * @param force forces the camera to recompute the matrix without looking at the cached state
  89853. * @returns the projection matrix
  89854. */
  89855. getProjectionMatrix(force?: boolean): Matrix;
  89856. /**
  89857. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89858. * @returns a Matrix
  89859. */
  89860. getTransformationMatrix(): Matrix;
  89861. private _updateFrustumPlanes;
  89862. /**
  89863. * Checks if a cullable object (mesh...) is in the camera frustum
  89864. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89865. * @param target The object to check
  89866. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89867. * @returns true if the object is in frustum otherwise false
  89868. */
  89869. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89870. /**
  89871. * Checks if a cullable object (mesh...) is in the camera frustum
  89872. * Unlike isInFrustum this cheks the full bounding box
  89873. * @param target The object to check
  89874. * @returns true if the object is in frustum otherwise false
  89875. */
  89876. isCompletelyInFrustum(target: ICullable): boolean;
  89877. /**
  89878. * Gets a ray in the forward direction from the camera.
  89879. * @param length Defines the length of the ray to create
  89880. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89881. * @param origin Defines the start point of the ray which defaults to the camera position
  89882. * @returns the forward ray
  89883. */
  89884. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89885. /**
  89886. * Releases resources associated with this node.
  89887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89889. */
  89890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89891. /** @hidden */
  89892. _isLeftCamera: boolean;
  89893. /**
  89894. * Gets the left camera of a rig setup in case of Rigged Camera
  89895. */
  89896. readonly isLeftCamera: boolean;
  89897. /** @hidden */
  89898. _isRightCamera: boolean;
  89899. /**
  89900. * Gets the right camera of a rig setup in case of Rigged Camera
  89901. */
  89902. readonly isRightCamera: boolean;
  89903. /**
  89904. * Gets the left camera of a rig setup in case of Rigged Camera
  89905. */
  89906. readonly leftCamera: Nullable<FreeCamera>;
  89907. /**
  89908. * Gets the right camera of a rig setup in case of Rigged Camera
  89909. */
  89910. readonly rightCamera: Nullable<FreeCamera>;
  89911. /**
  89912. * Gets the left camera target of a rig setup in case of Rigged Camera
  89913. * @returns the target position
  89914. */
  89915. getLeftTarget(): Nullable<Vector3>;
  89916. /**
  89917. * Gets the right camera target of a rig setup in case of Rigged Camera
  89918. * @returns the target position
  89919. */
  89920. getRightTarget(): Nullable<Vector3>;
  89921. /**
  89922. * @hidden
  89923. */
  89924. setCameraRigMode(mode: number, rigParams: any): void;
  89925. /** @hidden */
  89926. static _setStereoscopicRigMode(camera: Camera): void;
  89927. /** @hidden */
  89928. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89929. /** @hidden */
  89930. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89931. /** @hidden */
  89932. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89933. /** @hidden */
  89934. _getVRProjectionMatrix(): Matrix;
  89935. protected _updateCameraRotationMatrix(): void;
  89936. protected _updateWebVRCameraRotationMatrix(): void;
  89937. /**
  89938. * This function MUST be overwritten by the different WebVR cameras available.
  89939. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89940. * @hidden
  89941. */
  89942. _getWebVRProjectionMatrix(): Matrix;
  89943. /**
  89944. * This function MUST be overwritten by the different WebVR cameras available.
  89945. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89946. * @hidden
  89947. */
  89948. _getWebVRViewMatrix(): Matrix;
  89949. /** @hidden */
  89950. setCameraRigParameter(name: string, value: any): void;
  89951. /**
  89952. * needs to be overridden by children so sub has required properties to be copied
  89953. * @hidden
  89954. */
  89955. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89956. /**
  89957. * May need to be overridden by children
  89958. * @hidden
  89959. */
  89960. _updateRigCameras(): void;
  89961. /** @hidden */
  89962. _setupInputs(): void;
  89963. /**
  89964. * Serialiaze the camera setup to a json represention
  89965. * @returns the JSON representation
  89966. */
  89967. serialize(): any;
  89968. /**
  89969. * Clones the current camera.
  89970. * @param name The cloned camera name
  89971. * @returns the cloned camera
  89972. */
  89973. clone(name: string): Camera;
  89974. /**
  89975. * Gets the direction of the camera relative to a given local axis.
  89976. * @param localAxis Defines the reference axis to provide a relative direction.
  89977. * @return the direction
  89978. */
  89979. getDirection(localAxis: Vector3): Vector3;
  89980. /**
  89981. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89982. * @param localAxis Defines the reference axis to provide a relative direction.
  89983. * @param result Defines the vector to store the result in
  89984. */
  89985. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89986. /**
  89987. * Gets a camera constructor for a given camera type
  89988. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89989. * @param name The name of the camera the result will be able to instantiate
  89990. * @param scene The scene the result will construct the camera in
  89991. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89992. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89993. * @returns a factory method to construc the camera
  89994. */
  89995. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89996. /**
  89997. * Compute the world matrix of the camera.
  89998. * @returns the camera workd matrix
  89999. */
  90000. computeWorldMatrix(): Matrix;
  90001. /**
  90002. * Parse a JSON and creates the camera from the parsed information
  90003. * @param parsedCamera The JSON to parse
  90004. * @param scene The scene to instantiate the camera in
  90005. * @returns the newly constructed camera
  90006. */
  90007. static Parse(parsedCamera: any, scene: Scene): Camera;
  90008. }
  90009. }
  90010. declare module BABYLON {
  90011. /**
  90012. * Class containing static functions to help procedurally build meshes
  90013. */
  90014. export class DiscBuilder {
  90015. /**
  90016. * Creates a plane polygonal mesh. By default, this is a disc
  90017. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90018. * * 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
  90019. * * 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
  90020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90023. * @param name defines the name of the mesh
  90024. * @param options defines the options used to create the mesh
  90025. * @param scene defines the hosting scene
  90026. * @returns the plane polygonal mesh
  90027. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90028. */
  90029. static CreateDisc(name: string, options: {
  90030. radius?: number;
  90031. tessellation?: number;
  90032. arc?: number;
  90033. updatable?: boolean;
  90034. sideOrientation?: number;
  90035. frontUVs?: Vector4;
  90036. backUVs?: Vector4;
  90037. }, scene?: Nullable<Scene>): Mesh;
  90038. }
  90039. }
  90040. declare module BABYLON {
  90041. /**
  90042. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90043. *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.
  90044. * The SPS is also a particle system. It provides some methods to manage the particles.
  90045. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90046. *
  90047. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90048. */
  90049. export class SolidParticleSystem implements IDisposable {
  90050. /**
  90051. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90052. * Example : var p = SPS.particles[i];
  90053. */
  90054. particles: SolidParticle[];
  90055. /**
  90056. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90057. */
  90058. nbParticles: number;
  90059. /**
  90060. * If the particles must ever face the camera (default false). Useful for planar particles.
  90061. */
  90062. billboard: boolean;
  90063. /**
  90064. * Recompute normals when adding a shape
  90065. */
  90066. recomputeNormals: boolean;
  90067. /**
  90068. * This a counter ofr your own usage. It's not set by any SPS functions.
  90069. */
  90070. counter: number;
  90071. /**
  90072. * The SPS name. This name is also given to the underlying mesh.
  90073. */
  90074. name: string;
  90075. /**
  90076. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90077. */
  90078. mesh: Mesh;
  90079. /**
  90080. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90081. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90082. */
  90083. vars: any;
  90084. /**
  90085. * This array is populated when the SPS is set as 'pickable'.
  90086. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90087. * Each element of this array is an object `{idx: int, faceId: int}`.
  90088. * `idx` is the picked particle index in the `SPS.particles` array
  90089. * `faceId` is the picked face index counted within this particle.
  90090. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90091. */
  90092. pickedParticles: {
  90093. idx: number;
  90094. faceId: number;
  90095. }[];
  90096. /**
  90097. * This array is populated when `enableDepthSort` is set to true.
  90098. * Each element of this array is an instance of the class DepthSortedParticle.
  90099. */
  90100. depthSortedParticles: DepthSortedParticle[];
  90101. /**
  90102. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90103. * @hidden
  90104. */
  90105. _bSphereOnly: boolean;
  90106. /**
  90107. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90108. * @hidden
  90109. */
  90110. _bSphereRadiusFactor: number;
  90111. private _scene;
  90112. private _positions;
  90113. private _indices;
  90114. private _normals;
  90115. private _colors;
  90116. private _uvs;
  90117. private _indices32;
  90118. private _positions32;
  90119. private _normals32;
  90120. private _fixedNormal32;
  90121. private _colors32;
  90122. private _uvs32;
  90123. private _index;
  90124. private _updatable;
  90125. private _pickable;
  90126. private _isVisibilityBoxLocked;
  90127. private _alwaysVisible;
  90128. private _depthSort;
  90129. private _shapeCounter;
  90130. private _copy;
  90131. private _color;
  90132. private _computeParticleColor;
  90133. private _computeParticleTexture;
  90134. private _computeParticleRotation;
  90135. private _computeParticleVertex;
  90136. private _computeBoundingBox;
  90137. private _depthSortParticles;
  90138. private _camera;
  90139. private _mustUnrotateFixedNormals;
  90140. private _particlesIntersect;
  90141. private _needs32Bits;
  90142. /**
  90143. * Creates a SPS (Solid Particle System) object.
  90144. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90145. * @param scene (Scene) is the scene in which the SPS is added.
  90146. * @param options defines the options of the sps e.g.
  90147. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90148. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90149. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90150. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90151. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90152. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90153. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90154. */
  90155. constructor(name: string, scene: Scene, options?: {
  90156. updatable?: boolean;
  90157. isPickable?: boolean;
  90158. enableDepthSort?: boolean;
  90159. particleIntersection?: boolean;
  90160. boundingSphereOnly?: boolean;
  90161. bSphereRadiusFactor?: number;
  90162. });
  90163. /**
  90164. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90165. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90166. * @returns the created mesh
  90167. */
  90168. buildMesh(): Mesh;
  90169. /**
  90170. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90171. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90172. * Thus the particles generated from `digest()` have their property `position` set yet.
  90173. * @param mesh ( Mesh ) is the mesh to be digested
  90174. * @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
  90175. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90176. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90177. * @returns the current SPS
  90178. */
  90179. digest(mesh: Mesh, options?: {
  90180. facetNb?: number;
  90181. number?: number;
  90182. delta?: number;
  90183. }): SolidParticleSystem;
  90184. private _unrotateFixedNormals;
  90185. private _resetCopy;
  90186. private _meshBuilder;
  90187. private _posToShape;
  90188. private _uvsToShapeUV;
  90189. private _addParticle;
  90190. /**
  90191. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90192. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90193. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90194. * @param nb (positive integer) the number of particles to be created from this model
  90195. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90196. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90197. * @returns the number of shapes in the system
  90198. */
  90199. addShape(mesh: Mesh, nb: number, options?: {
  90200. positionFunction?: any;
  90201. vertexFunction?: any;
  90202. }): number;
  90203. private _rebuildParticle;
  90204. /**
  90205. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90206. * @returns the SPS.
  90207. */
  90208. rebuildMesh(): SolidParticleSystem;
  90209. /**
  90210. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90211. * This method calls `updateParticle()` for each particle of the SPS.
  90212. * For an animated SPS, it is usually called within the render loop.
  90213. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90214. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90215. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90216. * @returns the SPS.
  90217. */
  90218. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90219. /**
  90220. * Disposes the SPS.
  90221. */
  90222. dispose(): void;
  90223. /**
  90224. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90226. * @returns the SPS.
  90227. */
  90228. refreshVisibleSize(): SolidParticleSystem;
  90229. /**
  90230. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90231. * @param size the size (float) of the visibility box
  90232. * note : this doesn't lock the SPS mesh bounding box.
  90233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90234. */
  90235. setVisibilityBox(size: number): void;
  90236. /**
  90237. * Gets whether the SPS as always visible or not
  90238. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90239. */
  90240. /**
  90241. * Sets the SPS as always visible or not
  90242. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90243. */
  90244. isAlwaysVisible: boolean;
  90245. /**
  90246. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90247. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90248. */
  90249. /**
  90250. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90252. */
  90253. isVisibilityBoxLocked: boolean;
  90254. /**
  90255. * Tells to `setParticles()` to compute the particle rotations or not.
  90256. * Default value : true. The SPS is faster when it's set to false.
  90257. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90258. */
  90259. /**
  90260. * Gets if `setParticles()` computes the particle rotations or not.
  90261. * Default value : true. The SPS is faster when it's set to false.
  90262. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90263. */
  90264. computeParticleRotation: boolean;
  90265. /**
  90266. * Tells to `setParticles()` to compute the particle colors or not.
  90267. * Default value : true. The SPS is faster when it's set to false.
  90268. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90269. */
  90270. /**
  90271. * Gets if `setParticles()` computes the particle colors or not.
  90272. * Default value : true. The SPS is faster when it's set to false.
  90273. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90274. */
  90275. computeParticleColor: boolean;
  90276. /**
  90277. * Gets if `setParticles()` computes the particle textures or not.
  90278. * Default value : true. The SPS is faster when it's set to false.
  90279. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90280. */
  90281. computeParticleTexture: boolean;
  90282. /**
  90283. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90284. * Default value : false. The SPS is faster when it's set to false.
  90285. * Note : the particle custom vertex positions aren't stored values.
  90286. */
  90287. /**
  90288. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90289. * Default value : false. The SPS is faster when it's set to false.
  90290. * Note : the particle custom vertex positions aren't stored values.
  90291. */
  90292. computeParticleVertex: boolean;
  90293. /**
  90294. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90295. */
  90296. /**
  90297. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90298. */
  90299. computeBoundingBox: boolean;
  90300. /**
  90301. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90302. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90303. * Default : `true`
  90304. */
  90305. /**
  90306. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90307. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90308. * Default : `true`
  90309. */
  90310. depthSortParticles: boolean;
  90311. /**
  90312. * This function does nothing. It may be overwritten to set all the particle first values.
  90313. * The SPS doesn't call this function, you may have to call it by your own.
  90314. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90315. */
  90316. initParticles(): void;
  90317. /**
  90318. * This function does nothing. It may be overwritten to recycle a particle.
  90319. * The SPS doesn't call this function, you may have to call it by your own.
  90320. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90321. * @param particle The particle to recycle
  90322. * @returns the recycled particle
  90323. */
  90324. recycleParticle(particle: SolidParticle): SolidParticle;
  90325. /**
  90326. * Updates a particle : this function should be overwritten by the user.
  90327. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90328. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90329. * @example : just set a particle position or velocity and recycle conditions
  90330. * @param particle The particle to update
  90331. * @returns the updated particle
  90332. */
  90333. updateParticle(particle: SolidParticle): SolidParticle;
  90334. /**
  90335. * Updates a vertex of a particle : it can be overwritten by the user.
  90336. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90337. * @param particle the current particle
  90338. * @param vertex the current index of the current particle
  90339. * @param pt the index of the current vertex in the particle shape
  90340. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90341. * @example : just set a vertex particle position
  90342. * @returns the updated vertex
  90343. */
  90344. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90345. /**
  90346. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90347. * This does nothing and may be overwritten by the user.
  90348. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90349. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90350. * @param update the boolean update value actually passed to setParticles()
  90351. */
  90352. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90353. /**
  90354. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90355. * This will be passed three parameters.
  90356. * This does nothing and may be overwritten by the user.
  90357. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90358. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90359. * @param update the boolean update value actually passed to setParticles()
  90360. */
  90361. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90362. }
  90363. }
  90364. declare module BABYLON {
  90365. /**
  90366. * Represents one particle of a solid particle system.
  90367. */
  90368. export class SolidParticle {
  90369. /**
  90370. * particle global index
  90371. */
  90372. idx: number;
  90373. /**
  90374. * The color of the particle
  90375. */
  90376. color: Nullable<Color4>;
  90377. /**
  90378. * The world space position of the particle.
  90379. */
  90380. position: Vector3;
  90381. /**
  90382. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90383. */
  90384. rotation: Vector3;
  90385. /**
  90386. * The world space rotation quaternion of the particle.
  90387. */
  90388. rotationQuaternion: Nullable<Quaternion>;
  90389. /**
  90390. * The scaling of the particle.
  90391. */
  90392. scaling: Vector3;
  90393. /**
  90394. * The uvs of the particle.
  90395. */
  90396. uvs: Vector4;
  90397. /**
  90398. * The current speed of the particle.
  90399. */
  90400. velocity: Vector3;
  90401. /**
  90402. * The pivot point in the particle local space.
  90403. */
  90404. pivot: Vector3;
  90405. /**
  90406. * Must the particle be translated from its pivot point in its local space ?
  90407. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90408. * Default : false
  90409. */
  90410. translateFromPivot: boolean;
  90411. /**
  90412. * Is the particle active or not ?
  90413. */
  90414. alive: boolean;
  90415. /**
  90416. * Is the particle visible or not ?
  90417. */
  90418. isVisible: boolean;
  90419. /**
  90420. * Index of this particle in the global "positions" array (Internal use)
  90421. * @hidden
  90422. */
  90423. _pos: number;
  90424. /**
  90425. * @hidden Index of this particle in the global "indices" array (Internal use)
  90426. */
  90427. _ind: number;
  90428. /**
  90429. * @hidden ModelShape of this particle (Internal use)
  90430. */
  90431. _model: ModelShape;
  90432. /**
  90433. * ModelShape id of this particle
  90434. */
  90435. shapeId: number;
  90436. /**
  90437. * Index of the particle in its shape id
  90438. */
  90439. idxInShape: number;
  90440. /**
  90441. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90442. */
  90443. _modelBoundingInfo: BoundingInfo;
  90444. /**
  90445. * @hidden Particle BoundingInfo object (Internal use)
  90446. */
  90447. _boundingInfo: BoundingInfo;
  90448. /**
  90449. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90450. */
  90451. _sps: SolidParticleSystem;
  90452. /**
  90453. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90454. */
  90455. _stillInvisible: boolean;
  90456. /**
  90457. * @hidden Last computed particle rotation matrix
  90458. */
  90459. _rotationMatrix: number[];
  90460. /**
  90461. * Parent particle Id, if any.
  90462. * Default null.
  90463. */
  90464. parentId: Nullable<number>;
  90465. /**
  90466. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90467. * The possible values are :
  90468. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90469. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90470. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90471. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90472. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90473. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90474. * */
  90475. cullingStrategy: number;
  90476. /**
  90477. * @hidden Internal global position in the SPS.
  90478. */
  90479. _globalPosition: Vector3;
  90480. /**
  90481. * Creates a Solid Particle object.
  90482. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90483. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90484. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90485. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90486. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90487. * @param shapeId (integer) is the model shape identifier in the SPS.
  90488. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90489. * @param sps defines the sps it is associated to
  90490. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90491. */
  90492. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90493. /**
  90494. * Legacy support, changed scale to scaling
  90495. */
  90496. /**
  90497. * Legacy support, changed scale to scaling
  90498. */
  90499. scale: Vector3;
  90500. /**
  90501. * Legacy support, changed quaternion to rotationQuaternion
  90502. */
  90503. /**
  90504. * Legacy support, changed quaternion to rotationQuaternion
  90505. */
  90506. quaternion: Nullable<Quaternion>;
  90507. /**
  90508. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90509. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90510. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90511. * @returns true if it intersects
  90512. */
  90513. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90514. /**
  90515. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90516. * A particle is in the frustum if its bounding box intersects the frustum
  90517. * @param frustumPlanes defines the frustum to test
  90518. * @returns true if the particle is in the frustum planes
  90519. */
  90520. isInFrustum(frustumPlanes: Plane[]): boolean;
  90521. /**
  90522. * get the rotation matrix of the particle
  90523. * @hidden
  90524. */
  90525. getRotationMatrix(m: Matrix): void;
  90526. }
  90527. /**
  90528. * Represents the shape of the model used by one particle of a solid particle system.
  90529. * SPS internal tool, don't use it manually.
  90530. */
  90531. export class ModelShape {
  90532. /**
  90533. * The shape id
  90534. * @hidden
  90535. */
  90536. shapeID: number;
  90537. /**
  90538. * flat array of model positions (internal use)
  90539. * @hidden
  90540. */
  90541. _shape: Vector3[];
  90542. /**
  90543. * flat array of model UVs (internal use)
  90544. * @hidden
  90545. */
  90546. _shapeUV: number[];
  90547. /**
  90548. * length of the shape in the model indices array (internal use)
  90549. * @hidden
  90550. */
  90551. _indicesLength: number;
  90552. /**
  90553. * Custom position function (internal use)
  90554. * @hidden
  90555. */
  90556. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90557. /**
  90558. * Custom vertex function (internal use)
  90559. * @hidden
  90560. */
  90561. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90562. /**
  90563. * 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.
  90564. * SPS internal tool, don't use it manually.
  90565. * @hidden
  90566. */
  90567. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  90568. }
  90569. /**
  90570. * Represents a Depth Sorted Particle in the solid particle system.
  90571. */
  90572. export class DepthSortedParticle {
  90573. /**
  90574. * Index of the particle in the "indices" array
  90575. */
  90576. ind: number;
  90577. /**
  90578. * Length of the particle shape in the "indices" array
  90579. */
  90580. indicesLength: number;
  90581. /**
  90582. * Squared distance from the particle to the camera
  90583. */
  90584. sqDistance: number;
  90585. }
  90586. }
  90587. declare module BABYLON {
  90588. /**
  90589. * @hidden
  90590. */
  90591. export class _MeshCollisionData {
  90592. _checkCollisions: boolean;
  90593. _collisionMask: number;
  90594. _collisionGroup: number;
  90595. _collider: Nullable<Collider>;
  90596. _oldPositionForCollisions: Vector3;
  90597. _diffPositionForCollisions: Vector3;
  90598. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90599. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90600. }
  90601. }
  90602. declare module BABYLON {
  90603. /** @hidden */
  90604. class _FacetDataStorage {
  90605. facetPositions: Vector3[];
  90606. facetNormals: Vector3[];
  90607. facetPartitioning: number[][];
  90608. facetNb: number;
  90609. partitioningSubdivisions: number;
  90610. partitioningBBoxRatio: number;
  90611. facetDataEnabled: boolean;
  90612. facetParameters: any;
  90613. bbSize: Vector3;
  90614. subDiv: {
  90615. max: number;
  90616. X: number;
  90617. Y: number;
  90618. Z: number;
  90619. };
  90620. facetDepthSort: boolean;
  90621. facetDepthSortEnabled: boolean;
  90622. depthSortedIndices: IndicesArray;
  90623. depthSortedFacets: {
  90624. ind: number;
  90625. sqDistance: number;
  90626. }[];
  90627. facetDepthSortFunction: (f1: {
  90628. ind: number;
  90629. sqDistance: number;
  90630. }, f2: {
  90631. ind: number;
  90632. sqDistance: number;
  90633. }) => number;
  90634. facetDepthSortFrom: Vector3;
  90635. facetDepthSortOrigin: Vector3;
  90636. invertedMatrix: Matrix;
  90637. }
  90638. /**
  90639. * @hidden
  90640. **/
  90641. class _InternalAbstractMeshDataInfo {
  90642. _hasVertexAlpha: boolean;
  90643. _useVertexColors: boolean;
  90644. _numBoneInfluencers: number;
  90645. _applyFog: boolean;
  90646. _receiveShadows: boolean;
  90647. _facetData: _FacetDataStorage;
  90648. _visibility: number;
  90649. _skeleton: Nullable<Skeleton>;
  90650. _layerMask: number;
  90651. _computeBonesUsingShaders: boolean;
  90652. _isActive: boolean;
  90653. _onlyForInstances: boolean;
  90654. _isActiveIntermediate: boolean;
  90655. _onlyForInstancesIntermediate: boolean;
  90656. }
  90657. /**
  90658. * Class used to store all common mesh properties
  90659. */
  90660. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90661. /** No occlusion */
  90662. static OCCLUSION_TYPE_NONE: number;
  90663. /** Occlusion set to optimisitic */
  90664. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90665. /** Occlusion set to strict */
  90666. static OCCLUSION_TYPE_STRICT: number;
  90667. /** Use an accurante occlusion algorithm */
  90668. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90669. /** Use a conservative occlusion algorithm */
  90670. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90671. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90672. * Test order :
  90673. * Is the bounding sphere outside the frustum ?
  90674. * If not, are the bounding box vertices outside the frustum ?
  90675. * It not, then the cullable object is in the frustum.
  90676. */
  90677. static readonly CULLINGSTRATEGY_STANDARD: number;
  90678. /** Culling strategy : Bounding Sphere Only.
  90679. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90680. * It's also less accurate than the standard because some not visible objects can still be selected.
  90681. * Test : is the bounding sphere outside the frustum ?
  90682. * If not, then the cullable object is in the frustum.
  90683. */
  90684. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90685. /** Culling strategy : Optimistic Inclusion.
  90686. * This in an inclusion test first, then the standard exclusion test.
  90687. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90688. * 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.
  90689. * Anyway, it's as accurate as the standard strategy.
  90690. * Test :
  90691. * Is the cullable object bounding sphere center in the frustum ?
  90692. * If not, apply the default culling strategy.
  90693. */
  90694. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90695. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90696. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90697. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90698. * 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.
  90699. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90700. * Test :
  90701. * Is the cullable object bounding sphere center in the frustum ?
  90702. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90703. */
  90704. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90705. /**
  90706. * No billboard
  90707. */
  90708. static readonly BILLBOARDMODE_NONE: number;
  90709. /** Billboard on X axis */
  90710. static readonly BILLBOARDMODE_X: number;
  90711. /** Billboard on Y axis */
  90712. static readonly BILLBOARDMODE_Y: number;
  90713. /** Billboard on Z axis */
  90714. static readonly BILLBOARDMODE_Z: number;
  90715. /** Billboard on all axes */
  90716. static readonly BILLBOARDMODE_ALL: number;
  90717. /** Billboard on using position instead of orientation */
  90718. static readonly BILLBOARDMODE_USE_POSITION: number;
  90719. /** @hidden */
  90720. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90721. /**
  90722. * The culling strategy to use to check whether the mesh must be rendered or not.
  90723. * This value can be changed at any time and will be used on the next render mesh selection.
  90724. * The possible values are :
  90725. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90726. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90727. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90728. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90729. * Please read each static variable documentation to get details about the culling process.
  90730. * */
  90731. cullingStrategy: number;
  90732. /**
  90733. * Gets the number of facets in the mesh
  90734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90735. */
  90736. readonly facetNb: number;
  90737. /**
  90738. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90740. */
  90741. partitioningSubdivisions: number;
  90742. /**
  90743. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90744. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90746. */
  90747. partitioningBBoxRatio: number;
  90748. /**
  90749. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90750. * Works only for updatable meshes.
  90751. * Doesn't work with multi-materials
  90752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90753. */
  90754. mustDepthSortFacets: boolean;
  90755. /**
  90756. * The location (Vector3) where the facet depth sort must be computed from.
  90757. * By default, the active camera position.
  90758. * Used only when facet depth sort is enabled
  90759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90760. */
  90761. facetDepthSortFrom: Vector3;
  90762. /**
  90763. * gets a boolean indicating if facetData is enabled
  90764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90765. */
  90766. readonly isFacetDataEnabled: boolean;
  90767. /** @hidden */
  90768. _updateNonUniformScalingState(value: boolean): boolean;
  90769. /**
  90770. * An event triggered when this mesh collides with another one
  90771. */
  90772. onCollideObservable: Observable<AbstractMesh>;
  90773. /** Set a function to call when this mesh collides with another one */
  90774. onCollide: () => void;
  90775. /**
  90776. * An event triggered when the collision's position changes
  90777. */
  90778. onCollisionPositionChangeObservable: Observable<Vector3>;
  90779. /** Set a function to call when the collision's position changes */
  90780. onCollisionPositionChange: () => void;
  90781. /**
  90782. * An event triggered when material is changed
  90783. */
  90784. onMaterialChangedObservable: Observable<AbstractMesh>;
  90785. /**
  90786. * Gets or sets the orientation for POV movement & rotation
  90787. */
  90788. definedFacingForward: boolean;
  90789. /** @hidden */
  90790. _occlusionQuery: Nullable<WebGLQuery>;
  90791. /** @hidden */
  90792. _renderingGroup: Nullable<RenderingGroup>;
  90793. /**
  90794. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90795. */
  90796. /**
  90797. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90798. */
  90799. visibility: number;
  90800. /** Gets or sets the alpha index used to sort transparent meshes
  90801. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90802. */
  90803. alphaIndex: number;
  90804. /**
  90805. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90806. */
  90807. isVisible: boolean;
  90808. /**
  90809. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90810. */
  90811. isPickable: boolean;
  90812. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90813. showSubMeshesBoundingBox: boolean;
  90814. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90815. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90816. */
  90817. isBlocker: boolean;
  90818. /**
  90819. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90820. */
  90821. enablePointerMoveEvents: boolean;
  90822. /**
  90823. * Specifies the rendering group id for this mesh (0 by default)
  90824. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90825. */
  90826. renderingGroupId: number;
  90827. private _material;
  90828. /** Gets or sets current material */
  90829. material: Nullable<Material>;
  90830. /**
  90831. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90832. * @see http://doc.babylonjs.com/babylon101/shadows
  90833. */
  90834. receiveShadows: boolean;
  90835. /** Defines color to use when rendering outline */
  90836. outlineColor: Color3;
  90837. /** Define width to use when rendering outline */
  90838. outlineWidth: number;
  90839. /** Defines color to use when rendering overlay */
  90840. overlayColor: Color3;
  90841. /** Defines alpha to use when rendering overlay */
  90842. overlayAlpha: number;
  90843. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90844. hasVertexAlpha: boolean;
  90845. /** 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) */
  90846. useVertexColors: boolean;
  90847. /**
  90848. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90849. */
  90850. computeBonesUsingShaders: boolean;
  90851. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90852. numBoneInfluencers: number;
  90853. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90854. applyFog: boolean;
  90855. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90856. useOctreeForRenderingSelection: boolean;
  90857. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90858. useOctreeForPicking: boolean;
  90859. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90860. useOctreeForCollisions: boolean;
  90861. /**
  90862. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90863. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90864. */
  90865. layerMask: number;
  90866. /**
  90867. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90868. */
  90869. alwaysSelectAsActiveMesh: boolean;
  90870. /**
  90871. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90872. */
  90873. doNotSyncBoundingInfo: boolean;
  90874. /**
  90875. * Gets or sets the current action manager
  90876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90877. */
  90878. actionManager: Nullable<AbstractActionManager>;
  90879. private _meshCollisionData;
  90880. /**
  90881. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90882. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90883. */
  90884. ellipsoid: Vector3;
  90885. /**
  90886. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90888. */
  90889. ellipsoidOffset: Vector3;
  90890. /**
  90891. * Gets or sets a collision mask used to mask collisions (default is -1).
  90892. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90893. */
  90894. collisionMask: number;
  90895. /**
  90896. * Gets or sets the current collision group mask (-1 by default).
  90897. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90898. */
  90899. collisionGroup: number;
  90900. /**
  90901. * Defines edge width used when edgesRenderer is enabled
  90902. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90903. */
  90904. edgesWidth: number;
  90905. /**
  90906. * Defines edge color used when edgesRenderer is enabled
  90907. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90908. */
  90909. edgesColor: Color4;
  90910. /** @hidden */
  90911. _edgesRenderer: Nullable<IEdgesRenderer>;
  90912. /** @hidden */
  90913. _masterMesh: Nullable<AbstractMesh>;
  90914. /** @hidden */
  90915. _boundingInfo: Nullable<BoundingInfo>;
  90916. /** @hidden */
  90917. _renderId: number;
  90918. /**
  90919. * Gets or sets the list of subMeshes
  90920. * @see http://doc.babylonjs.com/how_to/multi_materials
  90921. */
  90922. subMeshes: SubMesh[];
  90923. /** @hidden */
  90924. _intersectionsInProgress: AbstractMesh[];
  90925. /** @hidden */
  90926. _unIndexed: boolean;
  90927. /** @hidden */
  90928. _lightSources: Light[];
  90929. /** Gets the list of lights affecting that mesh */
  90930. readonly lightSources: Light[];
  90931. /** @hidden */
  90932. readonly _positions: Nullable<Vector3[]>;
  90933. /** @hidden */
  90934. _waitingData: {
  90935. lods: Nullable<any>;
  90936. actions: Nullable<any>;
  90937. freezeWorldMatrix: Nullable<boolean>;
  90938. };
  90939. /** @hidden */
  90940. _bonesTransformMatrices: Nullable<Float32Array>;
  90941. /** @hidden */
  90942. _transformMatrixTexture: Nullable<RawTexture>;
  90943. /**
  90944. * Gets or sets a skeleton to apply skining transformations
  90945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90946. */
  90947. skeleton: Nullable<Skeleton>;
  90948. /**
  90949. * An event triggered when the mesh is rebuilt.
  90950. */
  90951. onRebuildObservable: Observable<AbstractMesh>;
  90952. /**
  90953. * Creates a new AbstractMesh
  90954. * @param name defines the name of the mesh
  90955. * @param scene defines the hosting scene
  90956. */
  90957. constructor(name: string, scene?: Nullable<Scene>);
  90958. /**
  90959. * Returns the string "AbstractMesh"
  90960. * @returns "AbstractMesh"
  90961. */
  90962. getClassName(): string;
  90963. /**
  90964. * Gets a string representation of the current mesh
  90965. * @param fullDetails defines a boolean indicating if full details must be included
  90966. * @returns a string representation of the current mesh
  90967. */
  90968. toString(fullDetails?: boolean): string;
  90969. /**
  90970. * @hidden
  90971. */
  90972. protected _getEffectiveParent(): Nullable<Node>;
  90973. /** @hidden */
  90974. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90975. /** @hidden */
  90976. _rebuild(): void;
  90977. /** @hidden */
  90978. _resyncLightSources(): void;
  90979. /** @hidden */
  90980. _resyncLighSource(light: Light): void;
  90981. /** @hidden */
  90982. _unBindEffect(): void;
  90983. /** @hidden */
  90984. _removeLightSource(light: Light, dispose: boolean): void;
  90985. private _markSubMeshesAsDirty;
  90986. /** @hidden */
  90987. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  90988. /** @hidden */
  90989. _markSubMeshesAsAttributesDirty(): void;
  90990. /** @hidden */
  90991. _markSubMeshesAsMiscDirty(): void;
  90992. /**
  90993. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90994. */
  90995. scaling: Vector3;
  90996. /**
  90997. * Returns true if the mesh is blocked. Implemented by child classes
  90998. */
  90999. readonly isBlocked: boolean;
  91000. /**
  91001. * Returns the mesh itself by default. Implemented by child classes
  91002. * @param camera defines the camera to use to pick the right LOD level
  91003. * @returns the currentAbstractMesh
  91004. */
  91005. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91006. /**
  91007. * Returns 0 by default. Implemented by child classes
  91008. * @returns an integer
  91009. */
  91010. getTotalVertices(): number;
  91011. /**
  91012. * Returns a positive integer : the total number of indices in this mesh geometry.
  91013. * @returns the numner of indices or zero if the mesh has no geometry.
  91014. */
  91015. getTotalIndices(): number;
  91016. /**
  91017. * Returns null by default. Implemented by child classes
  91018. * @returns null
  91019. */
  91020. getIndices(): Nullable<IndicesArray>;
  91021. /**
  91022. * Returns the array of the requested vertex data kind. Implemented by child classes
  91023. * @param kind defines the vertex data kind to use
  91024. * @returns null
  91025. */
  91026. getVerticesData(kind: string): Nullable<FloatArray>;
  91027. /**
  91028. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91029. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91030. * Note that a new underlying VertexBuffer object is created each call.
  91031. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91032. * @param kind defines vertex data kind:
  91033. * * VertexBuffer.PositionKind
  91034. * * VertexBuffer.UVKind
  91035. * * VertexBuffer.UV2Kind
  91036. * * VertexBuffer.UV3Kind
  91037. * * VertexBuffer.UV4Kind
  91038. * * VertexBuffer.UV5Kind
  91039. * * VertexBuffer.UV6Kind
  91040. * * VertexBuffer.ColorKind
  91041. * * VertexBuffer.MatricesIndicesKind
  91042. * * VertexBuffer.MatricesIndicesExtraKind
  91043. * * VertexBuffer.MatricesWeightsKind
  91044. * * VertexBuffer.MatricesWeightsExtraKind
  91045. * @param data defines the data source
  91046. * @param updatable defines if the data must be flagged as updatable (or static)
  91047. * @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
  91048. * @returns the current mesh
  91049. */
  91050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91051. /**
  91052. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91053. * If the mesh has no geometry, it is simply returned as it is.
  91054. * @param kind defines vertex data kind:
  91055. * * VertexBuffer.PositionKind
  91056. * * VertexBuffer.UVKind
  91057. * * VertexBuffer.UV2Kind
  91058. * * VertexBuffer.UV3Kind
  91059. * * VertexBuffer.UV4Kind
  91060. * * VertexBuffer.UV5Kind
  91061. * * VertexBuffer.UV6Kind
  91062. * * VertexBuffer.ColorKind
  91063. * * VertexBuffer.MatricesIndicesKind
  91064. * * VertexBuffer.MatricesIndicesExtraKind
  91065. * * VertexBuffer.MatricesWeightsKind
  91066. * * VertexBuffer.MatricesWeightsExtraKind
  91067. * @param data defines the data source
  91068. * @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
  91069. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91070. * @returns the current mesh
  91071. */
  91072. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91073. /**
  91074. * Sets the mesh indices,
  91075. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91076. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91077. * @param totalVertices Defines the total number of vertices
  91078. * @returns the current mesh
  91079. */
  91080. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91081. /**
  91082. * Gets a boolean indicating if specific vertex data is present
  91083. * @param kind defines the vertex data kind to use
  91084. * @returns true is data kind is present
  91085. */
  91086. isVerticesDataPresent(kind: string): boolean;
  91087. /**
  91088. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91089. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91090. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91091. * @returns a BoundingInfo
  91092. */
  91093. getBoundingInfo(): BoundingInfo;
  91094. /**
  91095. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91096. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91097. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91098. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91099. * @returns the current mesh
  91100. */
  91101. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91102. /**
  91103. * Overwrite the current bounding info
  91104. * @param boundingInfo defines the new bounding info
  91105. * @returns the current mesh
  91106. */
  91107. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91108. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91109. readonly useBones: boolean;
  91110. /** @hidden */
  91111. _preActivate(): void;
  91112. /** @hidden */
  91113. _preActivateForIntermediateRendering(renderId: number): void;
  91114. /** @hidden */
  91115. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91116. /** @hidden */
  91117. _postActivate(): void;
  91118. /** @hidden */
  91119. _freeze(): void;
  91120. /** @hidden */
  91121. _unFreeze(): void;
  91122. /**
  91123. * Gets the current world matrix
  91124. * @returns a Matrix
  91125. */
  91126. getWorldMatrix(): Matrix;
  91127. /** @hidden */
  91128. _getWorldMatrixDeterminant(): number;
  91129. /**
  91130. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91131. */
  91132. readonly isAnInstance: boolean;
  91133. /**
  91134. * Gets a boolean indicating if this mesh has instances
  91135. */
  91136. readonly hasInstances: boolean;
  91137. /**
  91138. * Perform relative position change from the point of view of behind the front of the mesh.
  91139. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91140. * Supports definition of mesh facing forward or backward
  91141. * @param amountRight defines the distance on the right axis
  91142. * @param amountUp defines the distance on the up axis
  91143. * @param amountForward defines the distance on the forward axis
  91144. * @returns the current mesh
  91145. */
  91146. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91147. /**
  91148. * Calculate relative position change from the point of view of behind the front of the mesh.
  91149. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91150. * Supports definition of mesh facing forward or backward
  91151. * @param amountRight defines the distance on the right axis
  91152. * @param amountUp defines the distance on the up axis
  91153. * @param amountForward defines the distance on the forward axis
  91154. * @returns the new displacement vector
  91155. */
  91156. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91157. /**
  91158. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91159. * Supports definition of mesh facing forward or backward
  91160. * @param flipBack defines the flip
  91161. * @param twirlClockwise defines the twirl
  91162. * @param tiltRight defines the tilt
  91163. * @returns the current mesh
  91164. */
  91165. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91166. /**
  91167. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91168. * Supports definition of mesh facing forward or backward.
  91169. * @param flipBack defines the flip
  91170. * @param twirlClockwise defines the twirl
  91171. * @param tiltRight defines the tilt
  91172. * @returns the new rotation vector
  91173. */
  91174. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91175. /**
  91176. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91177. * This means the mesh underlying bounding box and sphere are recomputed.
  91178. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91179. * @returns the current mesh
  91180. */
  91181. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91182. /** @hidden */
  91183. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91184. /** @hidden */
  91185. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91186. /** @hidden */
  91187. _updateBoundingInfo(): AbstractMesh;
  91188. /** @hidden */
  91189. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91190. /** @hidden */
  91191. protected _afterComputeWorldMatrix(): void;
  91192. /** @hidden */
  91193. readonly _effectiveMesh: AbstractMesh;
  91194. /**
  91195. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91196. * A mesh is in the frustum if its bounding box intersects the frustum
  91197. * @param frustumPlanes defines the frustum to test
  91198. * @returns true if the mesh is in the frustum planes
  91199. */
  91200. isInFrustum(frustumPlanes: Plane[]): boolean;
  91201. /**
  91202. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91203. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91204. * @param frustumPlanes defines the frustum to test
  91205. * @returns true if the mesh is completely in the frustum planes
  91206. */
  91207. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91208. /**
  91209. * True if the mesh intersects another mesh or a SolidParticle object
  91210. * @param mesh defines a target mesh or SolidParticle to test
  91211. * @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)
  91212. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91213. * @returns true if there is an intersection
  91214. */
  91215. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91216. /**
  91217. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91218. * @param point defines the point to test
  91219. * @returns true if there is an intersection
  91220. */
  91221. intersectsPoint(point: Vector3): boolean;
  91222. /**
  91223. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91225. */
  91226. checkCollisions: boolean;
  91227. /**
  91228. * Gets Collider object used to compute collisions (not physics)
  91229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91230. */
  91231. readonly collider: Nullable<Collider>;
  91232. /**
  91233. * Move the mesh using collision engine
  91234. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91235. * @param displacement defines the requested displacement vector
  91236. * @returns the current mesh
  91237. */
  91238. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91239. private _onCollisionPositionChange;
  91240. /** @hidden */
  91241. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91242. /** @hidden */
  91243. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91244. /** @hidden */
  91245. _checkCollision(collider: Collider): AbstractMesh;
  91246. /** @hidden */
  91247. _generatePointsArray(): boolean;
  91248. /**
  91249. * Checks if the passed Ray intersects with the mesh
  91250. * @param ray defines the ray to use
  91251. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91252. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91253. * @returns the picking info
  91254. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91255. */
  91256. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91257. /**
  91258. * Clones the current mesh
  91259. * @param name defines the mesh name
  91260. * @param newParent defines the new mesh parent
  91261. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91262. * @returns the new mesh
  91263. */
  91264. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91265. /**
  91266. * Disposes all the submeshes of the current meshnp
  91267. * @returns the current mesh
  91268. */
  91269. releaseSubMeshes(): AbstractMesh;
  91270. /**
  91271. * Releases resources associated with this abstract mesh.
  91272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91274. */
  91275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91276. /**
  91277. * Adds the passed mesh as a child to the current mesh
  91278. * @param mesh defines the child mesh
  91279. * @returns the current mesh
  91280. */
  91281. addChild(mesh: AbstractMesh): AbstractMesh;
  91282. /**
  91283. * Removes the passed mesh from the current mesh children list
  91284. * @param mesh defines the child mesh
  91285. * @returns the current mesh
  91286. */
  91287. removeChild(mesh: AbstractMesh): AbstractMesh;
  91288. /** @hidden */
  91289. private _initFacetData;
  91290. /**
  91291. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91292. * This method can be called within the render loop.
  91293. * 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
  91294. * @returns the current mesh
  91295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91296. */
  91297. updateFacetData(): AbstractMesh;
  91298. /**
  91299. * Returns the facetLocalNormals array.
  91300. * The normals are expressed in the mesh local spac
  91301. * @returns an array of Vector3
  91302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91303. */
  91304. getFacetLocalNormals(): Vector3[];
  91305. /**
  91306. * Returns the facetLocalPositions array.
  91307. * The facet positions are expressed in the mesh local space
  91308. * @returns an array of Vector3
  91309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91310. */
  91311. getFacetLocalPositions(): Vector3[];
  91312. /**
  91313. * Returns the facetLocalPartioning array
  91314. * @returns an array of array of numbers
  91315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91316. */
  91317. getFacetLocalPartitioning(): number[][];
  91318. /**
  91319. * Returns the i-th facet position in the world system.
  91320. * This method allocates a new Vector3 per call
  91321. * @param i defines the facet index
  91322. * @returns a new Vector3
  91323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91324. */
  91325. getFacetPosition(i: number): Vector3;
  91326. /**
  91327. * Sets the reference Vector3 with the i-th facet position in the world system
  91328. * @param i defines the facet index
  91329. * @param ref defines the target vector
  91330. * @returns the current mesh
  91331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91332. */
  91333. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91334. /**
  91335. * Returns the i-th facet normal in the world system.
  91336. * This method allocates a new Vector3 per call
  91337. * @param i defines the facet index
  91338. * @returns a new Vector3
  91339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91340. */
  91341. getFacetNormal(i: number): Vector3;
  91342. /**
  91343. * Sets the reference Vector3 with the i-th facet normal in the world system
  91344. * @param i defines the facet index
  91345. * @param ref defines the target vector
  91346. * @returns the current mesh
  91347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91348. */
  91349. getFacetNormalToRef(i: number, ref: Vector3): this;
  91350. /**
  91351. * 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)
  91352. * @param x defines x coordinate
  91353. * @param y defines y coordinate
  91354. * @param z defines z coordinate
  91355. * @returns the array of facet indexes
  91356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91357. */
  91358. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91359. /**
  91360. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91361. * @param projected sets as the (x,y,z) world projection on the facet
  91362. * @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
  91363. * @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
  91364. * @param x defines x coordinate
  91365. * @param y defines y coordinate
  91366. * @param z defines z coordinate
  91367. * @returns the face index if found (or null instead)
  91368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91369. */
  91370. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91371. /**
  91372. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91373. * @param projected sets as the (x,y,z) local projection on the facet
  91374. * @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
  91375. * @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
  91376. * @param x defines x coordinate
  91377. * @param y defines y coordinate
  91378. * @param z defines z coordinate
  91379. * @returns the face index if found (or null instead)
  91380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91381. */
  91382. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91383. /**
  91384. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91385. * @returns the parameters
  91386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91387. */
  91388. getFacetDataParameters(): any;
  91389. /**
  91390. * Disables the feature FacetData and frees the related memory
  91391. * @returns the current mesh
  91392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91393. */
  91394. disableFacetData(): AbstractMesh;
  91395. /**
  91396. * Updates the AbstractMesh indices array
  91397. * @param indices defines the data source
  91398. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91399. * @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)
  91400. * @returns the current mesh
  91401. */
  91402. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91403. /**
  91404. * Creates new normals data for the mesh
  91405. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91406. * @returns the current mesh
  91407. */
  91408. createNormals(updatable: boolean): AbstractMesh;
  91409. /**
  91410. * Align the mesh with a normal
  91411. * @param normal defines the normal to use
  91412. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91413. * @returns the current mesh
  91414. */
  91415. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91416. /** @hidden */
  91417. _checkOcclusionQuery(): boolean;
  91418. /**
  91419. * Disables the mesh edge rendering mode
  91420. * @returns the currentAbstractMesh
  91421. */
  91422. disableEdgesRendering(): AbstractMesh;
  91423. /**
  91424. * Enables the edge rendering mode on the mesh.
  91425. * This mode makes the mesh edges visible
  91426. * @param epsilon defines the maximal distance between two angles to detect a face
  91427. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91428. * @returns the currentAbstractMesh
  91429. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91430. */
  91431. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91432. }
  91433. }
  91434. declare module BABYLON {
  91435. /**
  91436. * Interface used to define ActionEvent
  91437. */
  91438. export interface IActionEvent {
  91439. /** The mesh or sprite that triggered the action */
  91440. source: any;
  91441. /** The X mouse cursor position at the time of the event */
  91442. pointerX: number;
  91443. /** The Y mouse cursor position at the time of the event */
  91444. pointerY: number;
  91445. /** The mesh that is currently pointed at (can be null) */
  91446. meshUnderPointer: Nullable<AbstractMesh>;
  91447. /** the original (browser) event that triggered the ActionEvent */
  91448. sourceEvent?: any;
  91449. /** additional data for the event */
  91450. additionalData?: any;
  91451. }
  91452. /**
  91453. * ActionEvent is the event being sent when an action is triggered.
  91454. */
  91455. export class ActionEvent implements IActionEvent {
  91456. /** The mesh or sprite that triggered the action */
  91457. source: any;
  91458. /** The X mouse cursor position at the time of the event */
  91459. pointerX: number;
  91460. /** The Y mouse cursor position at the time of the event */
  91461. pointerY: number;
  91462. /** The mesh that is currently pointed at (can be null) */
  91463. meshUnderPointer: Nullable<AbstractMesh>;
  91464. /** the original (browser) event that triggered the ActionEvent */
  91465. sourceEvent?: any;
  91466. /** additional data for the event */
  91467. additionalData?: any;
  91468. /**
  91469. * Creates a new ActionEvent
  91470. * @param source The mesh or sprite that triggered the action
  91471. * @param pointerX The X mouse cursor position at the time of the event
  91472. * @param pointerY The Y mouse cursor position at the time of the event
  91473. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91474. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91475. * @param additionalData additional data for the event
  91476. */
  91477. constructor(
  91478. /** The mesh or sprite that triggered the action */
  91479. source: any,
  91480. /** The X mouse cursor position at the time of the event */
  91481. pointerX: number,
  91482. /** The Y mouse cursor position at the time of the event */
  91483. pointerY: number,
  91484. /** The mesh that is currently pointed at (can be null) */
  91485. meshUnderPointer: Nullable<AbstractMesh>,
  91486. /** the original (browser) event that triggered the ActionEvent */
  91487. sourceEvent?: any,
  91488. /** additional data for the event */
  91489. additionalData?: any);
  91490. /**
  91491. * Helper function to auto-create an ActionEvent from a source mesh.
  91492. * @param source The source mesh that triggered the event
  91493. * @param evt The original (browser) event
  91494. * @param additionalData additional data for the event
  91495. * @returns the new ActionEvent
  91496. */
  91497. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91498. /**
  91499. * Helper function to auto-create an ActionEvent from a source sprite
  91500. * @param source The source sprite that triggered the event
  91501. * @param scene Scene associated with the sprite
  91502. * @param evt The original (browser) event
  91503. * @param additionalData additional data for the event
  91504. * @returns the new ActionEvent
  91505. */
  91506. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91507. /**
  91508. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91509. * @param scene the scene where the event occurred
  91510. * @param evt The original (browser) event
  91511. * @returns the new ActionEvent
  91512. */
  91513. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91514. /**
  91515. * Helper function to auto-create an ActionEvent from a primitive
  91516. * @param prim defines the target primitive
  91517. * @param pointerPos defines the pointer position
  91518. * @param evt The original (browser) event
  91519. * @param additionalData additional data for the event
  91520. * @returns the new ActionEvent
  91521. */
  91522. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91523. }
  91524. }
  91525. declare module BABYLON {
  91526. /**
  91527. * Abstract class used to decouple action Manager from scene and meshes.
  91528. * Do not instantiate.
  91529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91530. */
  91531. export abstract class AbstractActionManager implements IDisposable {
  91532. /** Gets the list of active triggers */
  91533. static Triggers: {
  91534. [key: string]: number;
  91535. };
  91536. /** Gets the cursor to use when hovering items */
  91537. hoverCursor: string;
  91538. /** Gets the list of actions */
  91539. actions: IAction[];
  91540. /**
  91541. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91542. */
  91543. isRecursive: boolean;
  91544. /**
  91545. * Releases all associated resources
  91546. */
  91547. abstract dispose(): void;
  91548. /**
  91549. * Does this action manager has pointer triggers
  91550. */
  91551. abstract readonly hasPointerTriggers: boolean;
  91552. /**
  91553. * Does this action manager has pick triggers
  91554. */
  91555. abstract readonly hasPickTriggers: boolean;
  91556. /**
  91557. * Process a specific trigger
  91558. * @param trigger defines the trigger to process
  91559. * @param evt defines the event details to be processed
  91560. */
  91561. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91562. /**
  91563. * Does this action manager handles actions of any of the given triggers
  91564. * @param triggers defines the triggers to be tested
  91565. * @return a boolean indicating whether one (or more) of the triggers is handled
  91566. */
  91567. abstract hasSpecificTriggers(triggers: number[]): boolean;
  91568. /**
  91569. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91570. * speed.
  91571. * @param triggerA defines the trigger to be tested
  91572. * @param triggerB defines the trigger to be tested
  91573. * @return a boolean indicating whether one (or more) of the triggers is handled
  91574. */
  91575. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91576. /**
  91577. * Does this action manager handles actions of a given trigger
  91578. * @param trigger defines the trigger to be tested
  91579. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91580. * @return whether the trigger is handled
  91581. */
  91582. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91583. /**
  91584. * Serialize this manager to a JSON object
  91585. * @param name defines the property name to store this manager
  91586. * @returns a JSON representation of this manager
  91587. */
  91588. abstract serialize(name: string): any;
  91589. /**
  91590. * Registers an action to this action manager
  91591. * @param action defines the action to be registered
  91592. * @return the action amended (prepared) after registration
  91593. */
  91594. abstract registerAction(action: IAction): Nullable<IAction>;
  91595. /**
  91596. * Unregisters an action to this action manager
  91597. * @param action defines the action to be unregistered
  91598. * @return a boolean indicating whether the action has been unregistered
  91599. */
  91600. abstract unregisterAction(action: IAction): Boolean;
  91601. /**
  91602. * Does exist one action manager with at least one trigger
  91603. **/
  91604. static readonly HasTriggers: boolean;
  91605. /**
  91606. * Does exist one action manager with at least one pick trigger
  91607. **/
  91608. static readonly HasPickTriggers: boolean;
  91609. /**
  91610. * Does exist one action manager that handles actions of a given trigger
  91611. * @param trigger defines the trigger to be tested
  91612. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91613. **/
  91614. static HasSpecificTrigger(trigger: number): boolean;
  91615. }
  91616. }
  91617. declare module BABYLON {
  91618. /**
  91619. * Defines how a node can be built from a string name.
  91620. */
  91621. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91622. /**
  91623. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91624. */
  91625. export class Node implements IBehaviorAware<Node> {
  91626. /** @hidden */
  91627. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91628. private static _NodeConstructors;
  91629. /**
  91630. * Add a new node constructor
  91631. * @param type defines the type name of the node to construct
  91632. * @param constructorFunc defines the constructor function
  91633. */
  91634. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91635. /**
  91636. * Returns a node constructor based on type name
  91637. * @param type defines the type name
  91638. * @param name defines the new node name
  91639. * @param scene defines the hosting scene
  91640. * @param options defines optional options to transmit to constructors
  91641. * @returns the new constructor or null
  91642. */
  91643. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91644. /**
  91645. * Gets or sets the name of the node
  91646. */
  91647. name: string;
  91648. /**
  91649. * Gets or sets the id of the node
  91650. */
  91651. id: string;
  91652. /**
  91653. * Gets or sets the unique id of the node
  91654. */
  91655. uniqueId: number;
  91656. /**
  91657. * Gets or sets a string used to store user defined state for the node
  91658. */
  91659. state: string;
  91660. /**
  91661. * Gets or sets an object used to store user defined information for the node
  91662. */
  91663. metadata: any;
  91664. /**
  91665. * For internal use only. Please do not use.
  91666. */
  91667. reservedDataStore: any;
  91668. /**
  91669. * List of inspectable custom properties (used by the Inspector)
  91670. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91671. */
  91672. inspectableCustomProperties: IInspectable[];
  91673. /**
  91674. * Gets or sets a boolean used to define if the node must be serialized
  91675. */
  91676. doNotSerialize: boolean;
  91677. /** @hidden */
  91678. _isDisposed: boolean;
  91679. /**
  91680. * Gets a list of Animations associated with the node
  91681. */
  91682. animations: Animation[];
  91683. protected _ranges: {
  91684. [name: string]: Nullable<AnimationRange>;
  91685. };
  91686. /**
  91687. * Callback raised when the node is ready to be used
  91688. */
  91689. onReady: Nullable<(node: Node) => void>;
  91690. private _isEnabled;
  91691. private _isParentEnabled;
  91692. private _isReady;
  91693. /** @hidden */
  91694. _currentRenderId: number;
  91695. private _parentUpdateId;
  91696. /** @hidden */
  91697. _childUpdateId: number;
  91698. /** @hidden */
  91699. _waitingParentId: Nullable<string>;
  91700. /** @hidden */
  91701. _scene: Scene;
  91702. /** @hidden */
  91703. _cache: any;
  91704. private _parentNode;
  91705. private _children;
  91706. /** @hidden */
  91707. _worldMatrix: Matrix;
  91708. /** @hidden */
  91709. _worldMatrixDeterminant: number;
  91710. /** @hidden */
  91711. _worldMatrixDeterminantIsDirty: boolean;
  91712. /** @hidden */
  91713. private _sceneRootNodesIndex;
  91714. /**
  91715. * Gets a boolean indicating if the node has been disposed
  91716. * @returns true if the node was disposed
  91717. */
  91718. isDisposed(): boolean;
  91719. /**
  91720. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91721. * @see https://doc.babylonjs.com/how_to/parenting
  91722. */
  91723. parent: Nullable<Node>;
  91724. private addToSceneRootNodes;
  91725. private removeFromSceneRootNodes;
  91726. private _animationPropertiesOverride;
  91727. /**
  91728. * Gets or sets the animation properties override
  91729. */
  91730. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91731. /**
  91732. * Gets a string idenfifying the name of the class
  91733. * @returns "Node" string
  91734. */
  91735. getClassName(): string;
  91736. /** @hidden */
  91737. readonly _isNode: boolean;
  91738. /**
  91739. * An event triggered when the mesh is disposed
  91740. */
  91741. onDisposeObservable: Observable<Node>;
  91742. private _onDisposeObserver;
  91743. /**
  91744. * Sets a callback that will be raised when the node will be disposed
  91745. */
  91746. onDispose: () => void;
  91747. /**
  91748. * Creates a new Node
  91749. * @param name the name and id to be given to this node
  91750. * @param scene the scene this node will be added to
  91751. * @param addToRootNodes the node will be added to scene.rootNodes
  91752. */
  91753. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91754. /**
  91755. * Gets the scene of the node
  91756. * @returns a scene
  91757. */
  91758. getScene(): Scene;
  91759. /**
  91760. * Gets the engine of the node
  91761. * @returns a Engine
  91762. */
  91763. getEngine(): Engine;
  91764. private _behaviors;
  91765. /**
  91766. * Attach a behavior to the node
  91767. * @see http://doc.babylonjs.com/features/behaviour
  91768. * @param behavior defines the behavior to attach
  91769. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91770. * @returns the current Node
  91771. */
  91772. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91773. /**
  91774. * Remove an attached behavior
  91775. * @see http://doc.babylonjs.com/features/behaviour
  91776. * @param behavior defines the behavior to attach
  91777. * @returns the current Node
  91778. */
  91779. removeBehavior(behavior: Behavior<Node>): Node;
  91780. /**
  91781. * Gets the list of attached behaviors
  91782. * @see http://doc.babylonjs.com/features/behaviour
  91783. */
  91784. readonly behaviors: Behavior<Node>[];
  91785. /**
  91786. * Gets an attached behavior by name
  91787. * @param name defines the name of the behavior to look for
  91788. * @see http://doc.babylonjs.com/features/behaviour
  91789. * @returns null if behavior was not found else the requested behavior
  91790. */
  91791. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91792. /**
  91793. * Returns the latest update of the World matrix
  91794. * @returns a Matrix
  91795. */
  91796. getWorldMatrix(): Matrix;
  91797. /** @hidden */
  91798. _getWorldMatrixDeterminant(): number;
  91799. /**
  91800. * Returns directly the latest state of the mesh World matrix.
  91801. * A Matrix is returned.
  91802. */
  91803. readonly worldMatrixFromCache: Matrix;
  91804. /** @hidden */
  91805. _initCache(): void;
  91806. /** @hidden */
  91807. updateCache(force?: boolean): void;
  91808. /** @hidden */
  91809. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91810. /** @hidden */
  91811. _updateCache(ignoreParentClass?: boolean): void;
  91812. /** @hidden */
  91813. _isSynchronized(): boolean;
  91814. /** @hidden */
  91815. _markSyncedWithParent(): void;
  91816. /** @hidden */
  91817. isSynchronizedWithParent(): boolean;
  91818. /** @hidden */
  91819. isSynchronized(): boolean;
  91820. /**
  91821. * Is this node ready to be used/rendered
  91822. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91823. * @return true if the node is ready
  91824. */
  91825. isReady(completeCheck?: boolean): boolean;
  91826. /**
  91827. * Is this node enabled?
  91828. * 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
  91829. * @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
  91830. * @return whether this node (and its parent) is enabled
  91831. */
  91832. isEnabled(checkAncestors?: boolean): boolean;
  91833. /** @hidden */
  91834. protected _syncParentEnabledState(): void;
  91835. /**
  91836. * Set the enabled state of this node
  91837. * @param value defines the new enabled state
  91838. */
  91839. setEnabled(value: boolean): void;
  91840. /**
  91841. * Is this node a descendant of the given node?
  91842. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91843. * @param ancestor defines the parent node to inspect
  91844. * @returns a boolean indicating if this node is a descendant of the given node
  91845. */
  91846. isDescendantOf(ancestor: Node): boolean;
  91847. /** @hidden */
  91848. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91849. /**
  91850. * Will return all nodes that have this node as ascendant
  91851. * @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
  91852. * @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
  91853. * @return all children nodes of all types
  91854. */
  91855. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91856. /**
  91857. * Get all child-meshes of this node
  91858. * @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)
  91859. * @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
  91860. * @returns an array of AbstractMesh
  91861. */
  91862. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91863. /**
  91864. * Get all direct children of this node
  91865. * @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
  91866. * @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)
  91867. * @returns an array of Node
  91868. */
  91869. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91870. /** @hidden */
  91871. _setReady(state: boolean): void;
  91872. /**
  91873. * Get an animation by name
  91874. * @param name defines the name of the animation to look for
  91875. * @returns null if not found else the requested animation
  91876. */
  91877. getAnimationByName(name: string): Nullable<Animation>;
  91878. /**
  91879. * Creates an animation range for this node
  91880. * @param name defines the name of the range
  91881. * @param from defines the starting key
  91882. * @param to defines the end key
  91883. */
  91884. createAnimationRange(name: string, from: number, to: number): void;
  91885. /**
  91886. * Delete a specific animation range
  91887. * @param name defines the name of the range to delete
  91888. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91889. */
  91890. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91891. /**
  91892. * Get an animation range by name
  91893. * @param name defines the name of the animation range to look for
  91894. * @returns null if not found else the requested animation range
  91895. */
  91896. getAnimationRange(name: string): Nullable<AnimationRange>;
  91897. /**
  91898. * Gets the list of all animation ranges defined on this node
  91899. * @returns an array
  91900. */
  91901. getAnimationRanges(): Nullable<AnimationRange>[];
  91902. /**
  91903. * Will start the animation sequence
  91904. * @param name defines the range frames for animation sequence
  91905. * @param loop defines if the animation should loop (false by default)
  91906. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91907. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91908. * @returns the object created for this animation. If range does not exist, it will return null
  91909. */
  91910. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91911. /**
  91912. * Serialize animation ranges into a JSON compatible object
  91913. * @returns serialization object
  91914. */
  91915. serializeAnimationRanges(): any;
  91916. /**
  91917. * Computes the world matrix of the node
  91918. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91919. * @returns the world matrix
  91920. */
  91921. computeWorldMatrix(force?: boolean): Matrix;
  91922. /**
  91923. * Releases resources associated with this node.
  91924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91926. */
  91927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91928. /**
  91929. * Parse animation range data from a serialization object and store them into a given node
  91930. * @param node defines where to store the animation ranges
  91931. * @param parsedNode defines the serialization object to read data from
  91932. * @param scene defines the hosting scene
  91933. */
  91934. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91935. /**
  91936. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91937. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91938. * @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
  91939. * @returns the new bounding vectors
  91940. */
  91941. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91942. min: Vector3;
  91943. max: Vector3;
  91944. };
  91945. }
  91946. }
  91947. declare module BABYLON {
  91948. /**
  91949. * @hidden
  91950. */
  91951. export class _IAnimationState {
  91952. key: number;
  91953. repeatCount: number;
  91954. workValue?: any;
  91955. loopMode?: number;
  91956. offsetValue?: any;
  91957. highLimitValue?: any;
  91958. }
  91959. /**
  91960. * Class used to store any kind of animation
  91961. */
  91962. export class Animation {
  91963. /**Name of the animation */
  91964. name: string;
  91965. /**Property to animate */
  91966. targetProperty: string;
  91967. /**The frames per second of the animation */
  91968. framePerSecond: number;
  91969. /**The data type of the animation */
  91970. dataType: number;
  91971. /**The loop mode of the animation */
  91972. loopMode?: number | undefined;
  91973. /**Specifies if blending should be enabled */
  91974. enableBlending?: boolean | undefined;
  91975. /**
  91976. * Use matrix interpolation instead of using direct key value when animating matrices
  91977. */
  91978. static AllowMatricesInterpolation: boolean;
  91979. /**
  91980. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91981. */
  91982. static AllowMatrixDecomposeForInterpolation: boolean;
  91983. /**
  91984. * Stores the key frames of the animation
  91985. */
  91986. private _keys;
  91987. /**
  91988. * Stores the easing function of the animation
  91989. */
  91990. private _easingFunction;
  91991. /**
  91992. * @hidden Internal use only
  91993. */
  91994. _runtimeAnimations: RuntimeAnimation[];
  91995. /**
  91996. * The set of event that will be linked to this animation
  91997. */
  91998. private _events;
  91999. /**
  92000. * Stores an array of target property paths
  92001. */
  92002. targetPropertyPath: string[];
  92003. /**
  92004. * Stores the blending speed of the animation
  92005. */
  92006. blendingSpeed: number;
  92007. /**
  92008. * Stores the animation ranges for the animation
  92009. */
  92010. private _ranges;
  92011. /**
  92012. * @hidden Internal use
  92013. */
  92014. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92015. /**
  92016. * Sets up an animation
  92017. * @param property The property to animate
  92018. * @param animationType The animation type to apply
  92019. * @param framePerSecond The frames per second of the animation
  92020. * @param easingFunction The easing function used in the animation
  92021. * @returns The created animation
  92022. */
  92023. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92024. /**
  92025. * Create and start an animation on a node
  92026. * @param name defines the name of the global animation that will be run on all nodes
  92027. * @param node defines the root node where the animation will take place
  92028. * @param targetProperty defines property to animate
  92029. * @param framePerSecond defines the number of frame per second yo use
  92030. * @param totalFrame defines the number of frames in total
  92031. * @param from defines the initial value
  92032. * @param to defines the final value
  92033. * @param loopMode defines which loop mode you want to use (off by default)
  92034. * @param easingFunction defines the easing function to use (linear by default)
  92035. * @param onAnimationEnd defines the callback to call when animation end
  92036. * @returns the animatable created for this animation
  92037. */
  92038. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92039. /**
  92040. * Create and start an animation on a node and its descendants
  92041. * @param name defines the name of the global animation that will be run on all nodes
  92042. * @param node defines the root node where the animation will take place
  92043. * @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
  92044. * @param targetProperty defines property to animate
  92045. * @param framePerSecond defines the number of frame per second to use
  92046. * @param totalFrame defines the number of frames in total
  92047. * @param from defines the initial value
  92048. * @param to defines the final value
  92049. * @param loopMode defines which loop mode you want to use (off by default)
  92050. * @param easingFunction defines the easing function to use (linear by default)
  92051. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92052. * @returns the list of animatables created for all nodes
  92053. * @example https://www.babylonjs-playground.com/#MH0VLI
  92054. */
  92055. 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[]>;
  92056. /**
  92057. * Creates a new animation, merges it with the existing animations and starts it
  92058. * @param name Name of the animation
  92059. * @param node Node which contains the scene that begins the animations
  92060. * @param targetProperty Specifies which property to animate
  92061. * @param framePerSecond The frames per second of the animation
  92062. * @param totalFrame The total number of frames
  92063. * @param from The frame at the beginning of the animation
  92064. * @param to The frame at the end of the animation
  92065. * @param loopMode Specifies the loop mode of the animation
  92066. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92067. * @param onAnimationEnd Callback to run once the animation is complete
  92068. * @returns Nullable animation
  92069. */
  92070. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92071. /**
  92072. * Transition property of an host to the target Value
  92073. * @param property The property to transition
  92074. * @param targetValue The target Value of the property
  92075. * @param host The object where the property to animate belongs
  92076. * @param scene Scene used to run the animation
  92077. * @param frameRate Framerate (in frame/s) to use
  92078. * @param transition The transition type we want to use
  92079. * @param duration The duration of the animation, in milliseconds
  92080. * @param onAnimationEnd Callback trigger at the end of the animation
  92081. * @returns Nullable animation
  92082. */
  92083. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92084. /**
  92085. * Return the array of runtime animations currently using this animation
  92086. */
  92087. readonly runtimeAnimations: RuntimeAnimation[];
  92088. /**
  92089. * Specifies if any of the runtime animations are currently running
  92090. */
  92091. readonly hasRunningRuntimeAnimations: boolean;
  92092. /**
  92093. * Initializes the animation
  92094. * @param name Name of the animation
  92095. * @param targetProperty Property to animate
  92096. * @param framePerSecond The frames per second of the animation
  92097. * @param dataType The data type of the animation
  92098. * @param loopMode The loop mode of the animation
  92099. * @param enableBlending Specifies if blending should be enabled
  92100. */
  92101. constructor(
  92102. /**Name of the animation */
  92103. name: string,
  92104. /**Property to animate */
  92105. targetProperty: string,
  92106. /**The frames per second of the animation */
  92107. framePerSecond: number,
  92108. /**The data type of the animation */
  92109. dataType: number,
  92110. /**The loop mode of the animation */
  92111. loopMode?: number | undefined,
  92112. /**Specifies if blending should be enabled */
  92113. enableBlending?: boolean | undefined);
  92114. /**
  92115. * Converts the animation to a string
  92116. * @param fullDetails support for multiple levels of logging within scene loading
  92117. * @returns String form of the animation
  92118. */
  92119. toString(fullDetails?: boolean): string;
  92120. /**
  92121. * Add an event to this animation
  92122. * @param event Event to add
  92123. */
  92124. addEvent(event: AnimationEvent): void;
  92125. /**
  92126. * Remove all events found at the given frame
  92127. * @param frame The frame to remove events from
  92128. */
  92129. removeEvents(frame: number): void;
  92130. /**
  92131. * Retrieves all the events from the animation
  92132. * @returns Events from the animation
  92133. */
  92134. getEvents(): AnimationEvent[];
  92135. /**
  92136. * Creates an animation range
  92137. * @param name Name of the animation range
  92138. * @param from Starting frame of the animation range
  92139. * @param to Ending frame of the animation
  92140. */
  92141. createRange(name: string, from: number, to: number): void;
  92142. /**
  92143. * Deletes an animation range by name
  92144. * @param name Name of the animation range to delete
  92145. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92146. */
  92147. deleteRange(name: string, deleteFrames?: boolean): void;
  92148. /**
  92149. * Gets the animation range by name, or null if not defined
  92150. * @param name Name of the animation range
  92151. * @returns Nullable animation range
  92152. */
  92153. getRange(name: string): Nullable<AnimationRange>;
  92154. /**
  92155. * Gets the key frames from the animation
  92156. * @returns The key frames of the animation
  92157. */
  92158. getKeys(): Array<IAnimationKey>;
  92159. /**
  92160. * Gets the highest frame rate of the animation
  92161. * @returns Highest frame rate of the animation
  92162. */
  92163. getHighestFrame(): number;
  92164. /**
  92165. * Gets the easing function of the animation
  92166. * @returns Easing function of the animation
  92167. */
  92168. getEasingFunction(): IEasingFunction;
  92169. /**
  92170. * Sets the easing function of the animation
  92171. * @param easingFunction A custom mathematical formula for animation
  92172. */
  92173. setEasingFunction(easingFunction: EasingFunction): void;
  92174. /**
  92175. * Interpolates a scalar linearly
  92176. * @param startValue Start value of the animation curve
  92177. * @param endValue End value of the animation curve
  92178. * @param gradient Scalar amount to interpolate
  92179. * @returns Interpolated scalar value
  92180. */
  92181. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92182. /**
  92183. * Interpolates a scalar cubically
  92184. * @param startValue Start value of the animation curve
  92185. * @param outTangent End tangent of the animation
  92186. * @param endValue End value of the animation curve
  92187. * @param inTangent Start tangent of the animation curve
  92188. * @param gradient Scalar amount to interpolate
  92189. * @returns Interpolated scalar value
  92190. */
  92191. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92192. /**
  92193. * Interpolates a quaternion using a spherical linear interpolation
  92194. * @param startValue Start value of the animation curve
  92195. * @param endValue End value of the animation curve
  92196. * @param gradient Scalar amount to interpolate
  92197. * @returns Interpolated quaternion value
  92198. */
  92199. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92200. /**
  92201. * Interpolates a quaternion cubically
  92202. * @param startValue Start value of the animation curve
  92203. * @param outTangent End tangent of the animation curve
  92204. * @param endValue End value of the animation curve
  92205. * @param inTangent Start tangent of the animation curve
  92206. * @param gradient Scalar amount to interpolate
  92207. * @returns Interpolated quaternion value
  92208. */
  92209. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92210. /**
  92211. * Interpolates a Vector3 linearl
  92212. * @param startValue Start value of the animation curve
  92213. * @param endValue End value of the animation curve
  92214. * @param gradient Scalar amount to interpolate
  92215. * @returns Interpolated scalar value
  92216. */
  92217. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92218. /**
  92219. * Interpolates a Vector3 cubically
  92220. * @param startValue Start value of the animation curve
  92221. * @param outTangent End tangent of the animation
  92222. * @param endValue End value of the animation curve
  92223. * @param inTangent Start tangent of the animation curve
  92224. * @param gradient Scalar amount to interpolate
  92225. * @returns InterpolatedVector3 value
  92226. */
  92227. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92228. /**
  92229. * Interpolates a Vector2 linearly
  92230. * @param startValue Start value of the animation curve
  92231. * @param endValue End value of the animation curve
  92232. * @param gradient Scalar amount to interpolate
  92233. * @returns Interpolated Vector2 value
  92234. */
  92235. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92236. /**
  92237. * Interpolates a Vector2 cubically
  92238. * @param startValue Start value of the animation curve
  92239. * @param outTangent End tangent of the animation
  92240. * @param endValue End value of the animation curve
  92241. * @param inTangent Start tangent of the animation curve
  92242. * @param gradient Scalar amount to interpolate
  92243. * @returns Interpolated Vector2 value
  92244. */
  92245. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92246. /**
  92247. * Interpolates a size linearly
  92248. * @param startValue Start value of the animation curve
  92249. * @param endValue End value of the animation curve
  92250. * @param gradient Scalar amount to interpolate
  92251. * @returns Interpolated Size value
  92252. */
  92253. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92254. /**
  92255. * Interpolates a Color3 linearly
  92256. * @param startValue Start value of the animation curve
  92257. * @param endValue End value of the animation curve
  92258. * @param gradient Scalar amount to interpolate
  92259. * @returns Interpolated Color3 value
  92260. */
  92261. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92262. /**
  92263. * @hidden Internal use only
  92264. */
  92265. _getKeyValue(value: any): any;
  92266. /**
  92267. * @hidden Internal use only
  92268. */
  92269. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92270. /**
  92271. * Defines the function to use to interpolate matrices
  92272. * @param startValue defines the start matrix
  92273. * @param endValue defines the end matrix
  92274. * @param gradient defines the gradient between both matrices
  92275. * @param result defines an optional target matrix where to store the interpolation
  92276. * @returns the interpolated matrix
  92277. */
  92278. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92279. /**
  92280. * Makes a copy of the animation
  92281. * @returns Cloned animation
  92282. */
  92283. clone(): Animation;
  92284. /**
  92285. * Sets the key frames of the animation
  92286. * @param values The animation key frames to set
  92287. */
  92288. setKeys(values: Array<IAnimationKey>): void;
  92289. /**
  92290. * Serializes the animation to an object
  92291. * @returns Serialized object
  92292. */
  92293. serialize(): any;
  92294. /**
  92295. * Float animation type
  92296. */
  92297. private static _ANIMATIONTYPE_FLOAT;
  92298. /**
  92299. * Vector3 animation type
  92300. */
  92301. private static _ANIMATIONTYPE_VECTOR3;
  92302. /**
  92303. * Quaternion animation type
  92304. */
  92305. private static _ANIMATIONTYPE_QUATERNION;
  92306. /**
  92307. * Matrix animation type
  92308. */
  92309. private static _ANIMATIONTYPE_MATRIX;
  92310. /**
  92311. * Color3 animation type
  92312. */
  92313. private static _ANIMATIONTYPE_COLOR3;
  92314. /**
  92315. * Vector2 animation type
  92316. */
  92317. private static _ANIMATIONTYPE_VECTOR2;
  92318. /**
  92319. * Size animation type
  92320. */
  92321. private static _ANIMATIONTYPE_SIZE;
  92322. /**
  92323. * Relative Loop Mode
  92324. */
  92325. private static _ANIMATIONLOOPMODE_RELATIVE;
  92326. /**
  92327. * Cycle Loop Mode
  92328. */
  92329. private static _ANIMATIONLOOPMODE_CYCLE;
  92330. /**
  92331. * Constant Loop Mode
  92332. */
  92333. private static _ANIMATIONLOOPMODE_CONSTANT;
  92334. /**
  92335. * Get the float animation type
  92336. */
  92337. static readonly ANIMATIONTYPE_FLOAT: number;
  92338. /**
  92339. * Get the Vector3 animation type
  92340. */
  92341. static readonly ANIMATIONTYPE_VECTOR3: number;
  92342. /**
  92343. * Get the Vector2 animation type
  92344. */
  92345. static readonly ANIMATIONTYPE_VECTOR2: number;
  92346. /**
  92347. * Get the Size animation type
  92348. */
  92349. static readonly ANIMATIONTYPE_SIZE: number;
  92350. /**
  92351. * Get the Quaternion animation type
  92352. */
  92353. static readonly ANIMATIONTYPE_QUATERNION: number;
  92354. /**
  92355. * Get the Matrix animation type
  92356. */
  92357. static readonly ANIMATIONTYPE_MATRIX: number;
  92358. /**
  92359. * Get the Color3 animation type
  92360. */
  92361. static readonly ANIMATIONTYPE_COLOR3: number;
  92362. /**
  92363. * Get the Relative Loop Mode
  92364. */
  92365. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92366. /**
  92367. * Get the Cycle Loop Mode
  92368. */
  92369. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92370. /**
  92371. * Get the Constant Loop Mode
  92372. */
  92373. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92374. /** @hidden */
  92375. static _UniversalLerp(left: any, right: any, amount: number): any;
  92376. /**
  92377. * Parses an animation object and creates an animation
  92378. * @param parsedAnimation Parsed animation object
  92379. * @returns Animation object
  92380. */
  92381. static Parse(parsedAnimation: any): Animation;
  92382. /**
  92383. * Appends the serialized animations from the source animations
  92384. * @param source Source containing the animations
  92385. * @param destination Target to store the animations
  92386. */
  92387. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92388. }
  92389. }
  92390. declare module BABYLON {
  92391. /**
  92392. * Interface containing an array of animations
  92393. */
  92394. export interface IAnimatable {
  92395. /**
  92396. * Array of animations
  92397. */
  92398. animations: Nullable<Array<Animation>>;
  92399. }
  92400. }
  92401. declare module BABYLON {
  92402. /**
  92403. * This represents all the required information to add a fresnel effect on a material:
  92404. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92405. */
  92406. export class FresnelParameters {
  92407. private _isEnabled;
  92408. /**
  92409. * Define if the fresnel effect is enable or not.
  92410. */
  92411. isEnabled: boolean;
  92412. /**
  92413. * Define the color used on edges (grazing angle)
  92414. */
  92415. leftColor: Color3;
  92416. /**
  92417. * Define the color used on center
  92418. */
  92419. rightColor: Color3;
  92420. /**
  92421. * Define bias applied to computed fresnel term
  92422. */
  92423. bias: number;
  92424. /**
  92425. * Defined the power exponent applied to fresnel term
  92426. */
  92427. power: number;
  92428. /**
  92429. * Clones the current fresnel and its valuues
  92430. * @returns a clone fresnel configuration
  92431. */
  92432. clone(): FresnelParameters;
  92433. /**
  92434. * Serializes the current fresnel parameters to a JSON representation.
  92435. * @return the JSON serialization
  92436. */
  92437. serialize(): any;
  92438. /**
  92439. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92440. * @param parsedFresnelParameters Define the JSON representation
  92441. * @returns the parsed parameters
  92442. */
  92443. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92444. }
  92445. }
  92446. declare module BABYLON {
  92447. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92448. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92449. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92450. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92451. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92452. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92453. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92454. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92455. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92456. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92457. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92458. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92459. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92460. /**
  92461. * Decorator used to define property that can be serialized as reference to a camera
  92462. * @param sourceName defines the name of the property to decorate
  92463. */
  92464. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92465. /**
  92466. * Class used to help serialization objects
  92467. */
  92468. export class SerializationHelper {
  92469. /** @hidden */
  92470. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92471. /** @hidden */
  92472. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92473. /** @hidden */
  92474. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92475. /** @hidden */
  92476. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92477. /**
  92478. * Appends the serialized animations from the source animations
  92479. * @param source Source containing the animations
  92480. * @param destination Target to store the animations
  92481. */
  92482. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92483. /**
  92484. * Static function used to serialized a specific entity
  92485. * @param entity defines the entity to serialize
  92486. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92487. * @returns a JSON compatible object representing the serialization of the entity
  92488. */
  92489. static Serialize<T>(entity: T, serializationObject?: any): any;
  92490. /**
  92491. * Creates a new entity from a serialization data object
  92492. * @param creationFunction defines a function used to instanciated the new entity
  92493. * @param source defines the source serialization data
  92494. * @param scene defines the hosting scene
  92495. * @param rootUrl defines the root url for resources
  92496. * @returns a new entity
  92497. */
  92498. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92499. /**
  92500. * Clones an object
  92501. * @param creationFunction defines the function used to instanciate the new object
  92502. * @param source defines the source object
  92503. * @returns the cloned object
  92504. */
  92505. static Clone<T>(creationFunction: () => T, source: T): T;
  92506. /**
  92507. * Instanciates a new object based on a source one (some data will be shared between both object)
  92508. * @param creationFunction defines the function used to instanciate the new object
  92509. * @param source defines the source object
  92510. * @returns the new object
  92511. */
  92512. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92513. }
  92514. }
  92515. declare module BABYLON {
  92516. /**
  92517. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92518. */
  92519. export interface CubeMapInfo {
  92520. /**
  92521. * The pixel array for the front face.
  92522. * This is stored in format, left to right, up to down format.
  92523. */
  92524. front: Nullable<ArrayBufferView>;
  92525. /**
  92526. * The pixel array for the back face.
  92527. * This is stored in format, left to right, up to down format.
  92528. */
  92529. back: Nullable<ArrayBufferView>;
  92530. /**
  92531. * The pixel array for the left face.
  92532. * This is stored in format, left to right, up to down format.
  92533. */
  92534. left: Nullable<ArrayBufferView>;
  92535. /**
  92536. * The pixel array for the right face.
  92537. * This is stored in format, left to right, up to down format.
  92538. */
  92539. right: Nullable<ArrayBufferView>;
  92540. /**
  92541. * The pixel array for the up face.
  92542. * This is stored in format, left to right, up to down format.
  92543. */
  92544. up: Nullable<ArrayBufferView>;
  92545. /**
  92546. * The pixel array for the down face.
  92547. * This is stored in format, left to right, up to down format.
  92548. */
  92549. down: Nullable<ArrayBufferView>;
  92550. /**
  92551. * The size of the cubemap stored.
  92552. *
  92553. * Each faces will be size * size pixels.
  92554. */
  92555. size: number;
  92556. /**
  92557. * The format of the texture.
  92558. *
  92559. * RGBA, RGB.
  92560. */
  92561. format: number;
  92562. /**
  92563. * The type of the texture data.
  92564. *
  92565. * UNSIGNED_INT, FLOAT.
  92566. */
  92567. type: number;
  92568. /**
  92569. * Specifies whether the texture is in gamma space.
  92570. */
  92571. gammaSpace: boolean;
  92572. }
  92573. /**
  92574. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  92575. */
  92576. export class PanoramaToCubeMapTools {
  92577. private static FACE_FRONT;
  92578. private static FACE_BACK;
  92579. private static FACE_RIGHT;
  92580. private static FACE_LEFT;
  92581. private static FACE_DOWN;
  92582. private static FACE_UP;
  92583. /**
  92584. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92585. *
  92586. * @param float32Array The source data.
  92587. * @param inputWidth The width of the input panorama.
  92588. * @param inputHeight The height of the input panorama.
  92589. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92590. * @return The cubemap data
  92591. */
  92592. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92593. private static CreateCubemapTexture;
  92594. private static CalcProjectionSpherical;
  92595. }
  92596. }
  92597. declare module BABYLON {
  92598. /**
  92599. * Helper class dealing with the extraction of spherical polynomial dataArray
  92600. * from a cube map.
  92601. */
  92602. export class CubeMapToSphericalPolynomialTools {
  92603. private static FileFaces;
  92604. /**
  92605. * Converts a texture to the according Spherical Polynomial data.
  92606. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92607. *
  92608. * @param texture The texture to extract the information from.
  92609. * @return The Spherical Polynomial data.
  92610. */
  92611. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92612. /**
  92613. * Converts a cubemap to the according Spherical Polynomial data.
  92614. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92615. *
  92616. * @param cubeInfo The Cube map to extract the information from.
  92617. * @return The Spherical Polynomial data.
  92618. */
  92619. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92620. }
  92621. }
  92622. declare module BABYLON {
  92623. /**
  92624. * Class used to manipulate GUIDs
  92625. */
  92626. export class GUID {
  92627. /**
  92628. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92629. * Be aware Math.random() could cause collisions, but:
  92630. * "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"
  92631. * @returns a pseudo random id
  92632. */
  92633. static RandomId(): string;
  92634. }
  92635. }
  92636. declare module BABYLON {
  92637. /**
  92638. * Base class of all the textures in babylon.
  92639. * It groups all the common properties the materials, post process, lights... might need
  92640. * in order to make a correct use of the texture.
  92641. */
  92642. export class BaseTexture implements IAnimatable {
  92643. /**
  92644. * Default anisotropic filtering level for the application.
  92645. * It is set to 4 as a good tradeoff between perf and quality.
  92646. */
  92647. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92648. /**
  92649. * Gets or sets the unique id of the texture
  92650. */
  92651. uniqueId: number;
  92652. /**
  92653. * Define the name of the texture.
  92654. */
  92655. name: string;
  92656. /**
  92657. * Gets or sets an object used to store user defined information.
  92658. */
  92659. metadata: any;
  92660. /**
  92661. * For internal use only. Please do not use.
  92662. */
  92663. reservedDataStore: any;
  92664. private _hasAlpha;
  92665. /**
  92666. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92667. */
  92668. hasAlpha: boolean;
  92669. /**
  92670. * Defines if the alpha value should be determined via the rgb values.
  92671. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92672. */
  92673. getAlphaFromRGB: boolean;
  92674. /**
  92675. * Intensity or strength of the texture.
  92676. * It is commonly used by materials to fine tune the intensity of the texture
  92677. */
  92678. level: number;
  92679. /**
  92680. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92681. * This is part of the texture as textures usually maps to one uv set.
  92682. */
  92683. coordinatesIndex: number;
  92684. private _coordinatesMode;
  92685. /**
  92686. * How a texture is mapped.
  92687. *
  92688. * | Value | Type | Description |
  92689. * | ----- | ----------------------------------- | ----------- |
  92690. * | 0 | EXPLICIT_MODE | |
  92691. * | 1 | SPHERICAL_MODE | |
  92692. * | 2 | PLANAR_MODE | |
  92693. * | 3 | CUBIC_MODE | |
  92694. * | 4 | PROJECTION_MODE | |
  92695. * | 5 | SKYBOX_MODE | |
  92696. * | 6 | INVCUBIC_MODE | |
  92697. * | 7 | EQUIRECTANGULAR_MODE | |
  92698. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92699. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92700. */
  92701. coordinatesMode: number;
  92702. /**
  92703. * | Value | Type | Description |
  92704. * | ----- | ------------------ | ----------- |
  92705. * | 0 | CLAMP_ADDRESSMODE | |
  92706. * | 1 | WRAP_ADDRESSMODE | |
  92707. * | 2 | MIRROR_ADDRESSMODE | |
  92708. */
  92709. wrapU: number;
  92710. /**
  92711. * | Value | Type | Description |
  92712. * | ----- | ------------------ | ----------- |
  92713. * | 0 | CLAMP_ADDRESSMODE | |
  92714. * | 1 | WRAP_ADDRESSMODE | |
  92715. * | 2 | MIRROR_ADDRESSMODE | |
  92716. */
  92717. wrapV: number;
  92718. /**
  92719. * | Value | Type | Description |
  92720. * | ----- | ------------------ | ----------- |
  92721. * | 0 | CLAMP_ADDRESSMODE | |
  92722. * | 1 | WRAP_ADDRESSMODE | |
  92723. * | 2 | MIRROR_ADDRESSMODE | |
  92724. */
  92725. wrapR: number;
  92726. /**
  92727. * With compliant hardware and browser (supporting anisotropic filtering)
  92728. * this defines the level of anisotropic filtering in the texture.
  92729. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92730. */
  92731. anisotropicFilteringLevel: number;
  92732. /**
  92733. * Define if the texture is a cube texture or if false a 2d texture.
  92734. */
  92735. isCube: boolean;
  92736. /**
  92737. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92738. */
  92739. is3D: boolean;
  92740. /**
  92741. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92742. * HDR texture are usually stored in linear space.
  92743. * This only impacts the PBR and Background materials
  92744. */
  92745. gammaSpace: boolean;
  92746. /**
  92747. * Gets whether or not the texture contains RGBD data.
  92748. */
  92749. readonly isRGBD: boolean;
  92750. /**
  92751. * Is Z inverted in the texture (useful in a cube texture).
  92752. */
  92753. invertZ: boolean;
  92754. /**
  92755. * Are mip maps generated for this texture or not.
  92756. */
  92757. readonly noMipmap: boolean;
  92758. /**
  92759. * @hidden
  92760. */
  92761. lodLevelInAlpha: boolean;
  92762. /**
  92763. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92764. */
  92765. lodGenerationOffset: number;
  92766. /**
  92767. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92768. */
  92769. lodGenerationScale: number;
  92770. /**
  92771. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92772. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92773. * average roughness values.
  92774. */
  92775. linearSpecularLOD: boolean;
  92776. /**
  92777. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92778. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92779. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92780. */
  92781. irradianceTexture: Nullable<BaseTexture>;
  92782. /**
  92783. * Define if the texture is a render target.
  92784. */
  92785. isRenderTarget: boolean;
  92786. /**
  92787. * Define the unique id of the texture in the scene.
  92788. */
  92789. readonly uid: string;
  92790. /**
  92791. * Return a string representation of the texture.
  92792. * @returns the texture as a string
  92793. */
  92794. toString(): string;
  92795. /**
  92796. * Get the class name of the texture.
  92797. * @returns "BaseTexture"
  92798. */
  92799. getClassName(): string;
  92800. /**
  92801. * Define the list of animation attached to the texture.
  92802. */
  92803. animations: Animation[];
  92804. /**
  92805. * An event triggered when the texture is disposed.
  92806. */
  92807. onDisposeObservable: Observable<BaseTexture>;
  92808. private _onDisposeObserver;
  92809. /**
  92810. * Callback triggered when the texture has been disposed.
  92811. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92812. */
  92813. onDispose: () => void;
  92814. /**
  92815. * Define the current state of the loading sequence when in delayed load mode.
  92816. */
  92817. delayLoadState: number;
  92818. private _scene;
  92819. /** @hidden */
  92820. _texture: Nullable<InternalTexture>;
  92821. private _uid;
  92822. /**
  92823. * Define if the texture is preventinga material to render or not.
  92824. * If not and the texture is not ready, the engine will use a default black texture instead.
  92825. */
  92826. readonly isBlocking: boolean;
  92827. /**
  92828. * Instantiates a new BaseTexture.
  92829. * Base class of all the textures in babylon.
  92830. * It groups all the common properties the materials, post process, lights... might need
  92831. * in order to make a correct use of the texture.
  92832. * @param scene Define the scene the texture blongs to
  92833. */
  92834. constructor(scene: Nullable<Scene>);
  92835. /**
  92836. * Get the scene the texture belongs to.
  92837. * @returns the scene or null if undefined
  92838. */
  92839. getScene(): Nullable<Scene>;
  92840. /**
  92841. * Get the texture transform matrix used to offset tile the texture for istance.
  92842. * @returns the transformation matrix
  92843. */
  92844. getTextureMatrix(): Matrix;
  92845. /**
  92846. * Get the texture reflection matrix used to rotate/transform the reflection.
  92847. * @returns the reflection matrix
  92848. */
  92849. getReflectionTextureMatrix(): Matrix;
  92850. /**
  92851. * Get the underlying lower level texture from Babylon.
  92852. * @returns the insternal texture
  92853. */
  92854. getInternalTexture(): Nullable<InternalTexture>;
  92855. /**
  92856. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92857. * @returns true if ready or not blocking
  92858. */
  92859. isReadyOrNotBlocking(): boolean;
  92860. /**
  92861. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92862. * @returns true if fully ready
  92863. */
  92864. isReady(): boolean;
  92865. private _cachedSize;
  92866. /**
  92867. * Get the size of the texture.
  92868. * @returns the texture size.
  92869. */
  92870. getSize(): ISize;
  92871. /**
  92872. * Get the base size of the texture.
  92873. * It can be different from the size if the texture has been resized for POT for instance
  92874. * @returns the base size
  92875. */
  92876. getBaseSize(): ISize;
  92877. /**
  92878. * Update the sampling mode of the texture.
  92879. * Default is Trilinear mode.
  92880. *
  92881. * | Value | Type | Description |
  92882. * | ----- | ------------------ | ----------- |
  92883. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92884. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92885. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92886. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92887. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92888. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92889. * | 7 | NEAREST_LINEAR | |
  92890. * | 8 | NEAREST_NEAREST | |
  92891. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92892. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92893. * | 11 | LINEAR_LINEAR | |
  92894. * | 12 | LINEAR_NEAREST | |
  92895. *
  92896. * > _mag_: magnification filter (close to the viewer)
  92897. * > _min_: minification filter (far from the viewer)
  92898. * > _mip_: filter used between mip map levels
  92899. *@param samplingMode Define the new sampling mode of the texture
  92900. */
  92901. updateSamplingMode(samplingMode: number): void;
  92902. /**
  92903. * Scales the texture if is `canRescale()`
  92904. * @param ratio the resize factor we want to use to rescale
  92905. */
  92906. scale(ratio: number): void;
  92907. /**
  92908. * Get if the texture can rescale.
  92909. */
  92910. readonly canRescale: boolean;
  92911. /** @hidden */
  92912. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92913. /** @hidden */
  92914. _rebuild(): void;
  92915. /**
  92916. * Triggers the load sequence in delayed load mode.
  92917. */
  92918. delayLoad(): void;
  92919. /**
  92920. * Clones the texture.
  92921. * @returns the cloned texture
  92922. */
  92923. clone(): Nullable<BaseTexture>;
  92924. /**
  92925. * Get the texture underlying type (INT, FLOAT...)
  92926. */
  92927. readonly textureType: number;
  92928. /**
  92929. * Get the texture underlying format (RGB, RGBA...)
  92930. */
  92931. readonly textureFormat: number;
  92932. /**
  92933. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92934. * This will returns an RGBA array buffer containing either in values (0-255) or
  92935. * float values (0-1) depending of the underlying buffer type.
  92936. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92937. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92938. * @param buffer defines a user defined buffer to fill with data (can be null)
  92939. * @returns The Array buffer containing the pixels data.
  92940. */
  92941. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92942. /**
  92943. * Release and destroy the underlying lower level texture aka internalTexture.
  92944. */
  92945. releaseInternalTexture(): void;
  92946. /**
  92947. * Get the polynomial representation of the texture data.
  92948. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92949. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92950. */
  92951. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92952. /** @hidden */
  92953. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92954. /** @hidden */
  92955. readonly _lodTextureMid: Nullable<BaseTexture>;
  92956. /** @hidden */
  92957. readonly _lodTextureLow: Nullable<BaseTexture>;
  92958. /**
  92959. * Dispose the texture and release its associated resources.
  92960. */
  92961. dispose(): void;
  92962. /**
  92963. * Serialize the texture into a JSON representation that can be parsed later on.
  92964. * @returns the JSON representation of the texture
  92965. */
  92966. serialize(): any;
  92967. /**
  92968. * Helper function to be called back once a list of texture contains only ready textures.
  92969. * @param textures Define the list of textures to wait for
  92970. * @param callback Define the callback triggered once the entire list will be ready
  92971. */
  92972. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92973. }
  92974. }
  92975. declare module BABYLON {
  92976. /**
  92977. * Class used to store data associated with WebGL texture data for the engine
  92978. * This class should not be used directly
  92979. */
  92980. export class InternalTexture {
  92981. /** @hidden */
  92982. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92983. /**
  92984. * The source of the texture data is unknown
  92985. */
  92986. static DATASOURCE_UNKNOWN: number;
  92987. /**
  92988. * Texture data comes from an URL
  92989. */
  92990. static DATASOURCE_URL: number;
  92991. /**
  92992. * Texture data is only used for temporary storage
  92993. */
  92994. static DATASOURCE_TEMP: number;
  92995. /**
  92996. * Texture data comes from raw data (ArrayBuffer)
  92997. */
  92998. static DATASOURCE_RAW: number;
  92999. /**
  93000. * Texture content is dynamic (video or dynamic texture)
  93001. */
  93002. static DATASOURCE_DYNAMIC: number;
  93003. /**
  93004. * Texture content is generated by rendering to it
  93005. */
  93006. static DATASOURCE_RENDERTARGET: number;
  93007. /**
  93008. * Texture content is part of a multi render target process
  93009. */
  93010. static DATASOURCE_MULTIRENDERTARGET: number;
  93011. /**
  93012. * Texture data comes from a cube data file
  93013. */
  93014. static DATASOURCE_CUBE: number;
  93015. /**
  93016. * Texture data comes from a raw cube data
  93017. */
  93018. static DATASOURCE_CUBERAW: number;
  93019. /**
  93020. * Texture data come from a prefiltered cube data file
  93021. */
  93022. static DATASOURCE_CUBEPREFILTERED: number;
  93023. /**
  93024. * Texture content is raw 3D data
  93025. */
  93026. static DATASOURCE_RAW3D: number;
  93027. /**
  93028. * Texture content is a depth texture
  93029. */
  93030. static DATASOURCE_DEPTHTEXTURE: number;
  93031. /**
  93032. * Texture data comes from a raw cube data encoded with RGBD
  93033. */
  93034. static DATASOURCE_CUBERAW_RGBD: number;
  93035. /**
  93036. * Defines if the texture is ready
  93037. */
  93038. isReady: boolean;
  93039. /**
  93040. * Defines if the texture is a cube texture
  93041. */
  93042. isCube: boolean;
  93043. /**
  93044. * Defines if the texture contains 3D data
  93045. */
  93046. is3D: boolean;
  93047. /**
  93048. * Defines if the texture contains multiview data
  93049. */
  93050. isMultiview: boolean;
  93051. /**
  93052. * Gets the URL used to load this texture
  93053. */
  93054. url: string;
  93055. /**
  93056. * Gets the sampling mode of the texture
  93057. */
  93058. samplingMode: number;
  93059. /**
  93060. * Gets a boolean indicating if the texture needs mipmaps generation
  93061. */
  93062. generateMipMaps: boolean;
  93063. /**
  93064. * Gets the number of samples used by the texture (WebGL2+ only)
  93065. */
  93066. samples: number;
  93067. /**
  93068. * Gets the type of the texture (int, float...)
  93069. */
  93070. type: number;
  93071. /**
  93072. * Gets the format of the texture (RGB, RGBA...)
  93073. */
  93074. format: number;
  93075. /**
  93076. * Observable called when the texture is loaded
  93077. */
  93078. onLoadedObservable: Observable<InternalTexture>;
  93079. /**
  93080. * Gets the width of the texture
  93081. */
  93082. width: number;
  93083. /**
  93084. * Gets the height of the texture
  93085. */
  93086. height: number;
  93087. /**
  93088. * Gets the depth of the texture
  93089. */
  93090. depth: number;
  93091. /**
  93092. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93093. */
  93094. baseWidth: number;
  93095. /**
  93096. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93097. */
  93098. baseHeight: number;
  93099. /**
  93100. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93101. */
  93102. baseDepth: number;
  93103. /**
  93104. * Gets a boolean indicating if the texture is inverted on Y axis
  93105. */
  93106. invertY: boolean;
  93107. /** @hidden */
  93108. _invertVScale: boolean;
  93109. /** @hidden */
  93110. _associatedChannel: number;
  93111. /** @hidden */
  93112. _dataSource: number;
  93113. /** @hidden */
  93114. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  93115. /** @hidden */
  93116. _bufferView: Nullable<ArrayBufferView>;
  93117. /** @hidden */
  93118. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93119. /** @hidden */
  93120. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93121. /** @hidden */
  93122. _size: number;
  93123. /** @hidden */
  93124. _extension: string;
  93125. /** @hidden */
  93126. _files: Nullable<string[]>;
  93127. /** @hidden */
  93128. _workingCanvas: Nullable<HTMLCanvasElement>;
  93129. /** @hidden */
  93130. _workingContext: Nullable<CanvasRenderingContext2D>;
  93131. /** @hidden */
  93132. _framebuffer: Nullable<WebGLFramebuffer>;
  93133. /** @hidden */
  93134. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93135. /** @hidden */
  93136. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93137. /** @hidden */
  93138. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93139. /** @hidden */
  93140. _attachments: Nullable<number[]>;
  93141. /** @hidden */
  93142. _cachedCoordinatesMode: Nullable<number>;
  93143. /** @hidden */
  93144. _cachedWrapU: Nullable<number>;
  93145. /** @hidden */
  93146. _cachedWrapV: Nullable<number>;
  93147. /** @hidden */
  93148. _cachedWrapR: Nullable<number>;
  93149. /** @hidden */
  93150. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93151. /** @hidden */
  93152. _isDisabled: boolean;
  93153. /** @hidden */
  93154. _compression: Nullable<string>;
  93155. /** @hidden */
  93156. _generateStencilBuffer: boolean;
  93157. /** @hidden */
  93158. _generateDepthBuffer: boolean;
  93159. /** @hidden */
  93160. _comparisonFunction: number;
  93161. /** @hidden */
  93162. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93163. /** @hidden */
  93164. _lodGenerationScale: number;
  93165. /** @hidden */
  93166. _lodGenerationOffset: number;
  93167. /** @hidden */
  93168. _colorTextureArray: Nullable<WebGLTexture>;
  93169. /** @hidden */
  93170. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93171. /** @hidden */
  93172. _lodTextureHigh: Nullable<BaseTexture>;
  93173. /** @hidden */
  93174. _lodTextureMid: Nullable<BaseTexture>;
  93175. /** @hidden */
  93176. _lodTextureLow: Nullable<BaseTexture>;
  93177. /** @hidden */
  93178. _isRGBD: boolean;
  93179. /** @hidden */
  93180. _linearSpecularLOD: boolean;
  93181. /** @hidden */
  93182. _irradianceTexture: Nullable<BaseTexture>;
  93183. /** @hidden */
  93184. _webGLTexture: Nullable<WebGLTexture>;
  93185. /** @hidden */
  93186. _references: number;
  93187. private _engine;
  93188. /**
  93189. * Gets the Engine the texture belongs to.
  93190. * @returns The babylon engine
  93191. */
  93192. getEngine(): Engine;
  93193. /**
  93194. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93195. */
  93196. readonly dataSource: number;
  93197. /**
  93198. * Creates a new InternalTexture
  93199. * @param engine defines the engine to use
  93200. * @param dataSource defines the type of data that will be used
  93201. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93202. */
  93203. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93204. /**
  93205. * Increments the number of references (ie. the number of Texture that point to it)
  93206. */
  93207. incrementReferences(): void;
  93208. /**
  93209. * Change the size of the texture (not the size of the content)
  93210. * @param width defines the new width
  93211. * @param height defines the new height
  93212. * @param depth defines the new depth (1 by default)
  93213. */
  93214. updateSize(width: int, height: int, depth?: int): void;
  93215. /** @hidden */
  93216. _rebuild(): void;
  93217. /** @hidden */
  93218. _swapAndDie(target: InternalTexture): void;
  93219. /**
  93220. * Dispose the current allocated resources
  93221. */
  93222. dispose(): void;
  93223. }
  93224. }
  93225. declare module BABYLON {
  93226. /**
  93227. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93228. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93229. */
  93230. export class EffectFallbacks {
  93231. private _defines;
  93232. private _currentRank;
  93233. private _maxRank;
  93234. private _mesh;
  93235. /**
  93236. * Removes the fallback from the bound mesh.
  93237. */
  93238. unBindMesh(): void;
  93239. /**
  93240. * Adds a fallback on the specified property.
  93241. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93242. * @param define The name of the define in the shader
  93243. */
  93244. addFallback(rank: number, define: string): void;
  93245. /**
  93246. * Sets the mesh to use CPU skinning when needing to fallback.
  93247. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93248. * @param mesh The mesh to use the fallbacks.
  93249. */
  93250. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93251. /**
  93252. * Checks to see if more fallbacks are still availible.
  93253. */
  93254. readonly hasMoreFallbacks: boolean;
  93255. /**
  93256. * Removes the defines that should be removed when falling back.
  93257. * @param currentDefines defines the current define statements for the shader.
  93258. * @param effect defines the current effect we try to compile
  93259. * @returns The resulting defines with defines of the current rank removed.
  93260. */
  93261. reduce(currentDefines: string, effect: Effect): string;
  93262. }
  93263. /**
  93264. * Options to be used when creating an effect.
  93265. */
  93266. export class EffectCreationOptions {
  93267. /**
  93268. * Atrributes that will be used in the shader.
  93269. */
  93270. attributes: string[];
  93271. /**
  93272. * Uniform varible names that will be set in the shader.
  93273. */
  93274. uniformsNames: string[];
  93275. /**
  93276. * Uniform buffer varible names that will be set in the shader.
  93277. */
  93278. uniformBuffersNames: string[];
  93279. /**
  93280. * Sampler texture variable names that will be set in the shader.
  93281. */
  93282. samplers: string[];
  93283. /**
  93284. * Define statements that will be set in the shader.
  93285. */
  93286. defines: any;
  93287. /**
  93288. * Possible fallbacks for this effect to improve performance when needed.
  93289. */
  93290. fallbacks: Nullable<EffectFallbacks>;
  93291. /**
  93292. * Callback that will be called when the shader is compiled.
  93293. */
  93294. onCompiled: Nullable<(effect: Effect) => void>;
  93295. /**
  93296. * Callback that will be called if an error occurs during shader compilation.
  93297. */
  93298. onError: Nullable<(effect: Effect, errors: string) => void>;
  93299. /**
  93300. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93301. */
  93302. indexParameters: any;
  93303. /**
  93304. * Max number of lights that can be used in the shader.
  93305. */
  93306. maxSimultaneousLights: number;
  93307. /**
  93308. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93309. */
  93310. transformFeedbackVaryings: Nullable<string[]>;
  93311. }
  93312. /**
  93313. * Effect containing vertex and fragment shader that can be executed on an object.
  93314. */
  93315. export class Effect implements IDisposable {
  93316. /**
  93317. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93318. */
  93319. static ShadersRepository: string;
  93320. /**
  93321. * Name of the effect.
  93322. */
  93323. name: any;
  93324. /**
  93325. * String container all the define statements that should be set on the shader.
  93326. */
  93327. defines: string;
  93328. /**
  93329. * Callback that will be called when the shader is compiled.
  93330. */
  93331. onCompiled: Nullable<(effect: Effect) => void>;
  93332. /**
  93333. * Callback that will be called if an error occurs during shader compilation.
  93334. */
  93335. onError: Nullable<(effect: Effect, errors: string) => void>;
  93336. /**
  93337. * Callback that will be called when effect is bound.
  93338. */
  93339. onBind: Nullable<(effect: Effect) => void>;
  93340. /**
  93341. * Unique ID of the effect.
  93342. */
  93343. uniqueId: number;
  93344. /**
  93345. * Observable that will be called when the shader is compiled.
  93346. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93347. */
  93348. onCompileObservable: Observable<Effect>;
  93349. /**
  93350. * Observable that will be called if an error occurs during shader compilation.
  93351. */
  93352. onErrorObservable: Observable<Effect>;
  93353. /** @hidden */
  93354. _onBindObservable: Nullable<Observable<Effect>>;
  93355. /**
  93356. * Observable that will be called when effect is bound.
  93357. */
  93358. readonly onBindObservable: Observable<Effect>;
  93359. /** @hidden */
  93360. _bonesComputationForcedToCPU: boolean;
  93361. private static _uniqueIdSeed;
  93362. private _engine;
  93363. private _uniformBuffersNames;
  93364. private _uniformsNames;
  93365. private _samplerList;
  93366. private _samplers;
  93367. private _isReady;
  93368. private _compilationError;
  93369. private _attributesNames;
  93370. private _attributes;
  93371. private _uniforms;
  93372. /**
  93373. * Key for the effect.
  93374. * @hidden
  93375. */
  93376. _key: string;
  93377. private _indexParameters;
  93378. private _fallbacks;
  93379. private _vertexSourceCode;
  93380. private _fragmentSourceCode;
  93381. private _vertexSourceCodeOverride;
  93382. private _fragmentSourceCodeOverride;
  93383. private _transformFeedbackVaryings;
  93384. /**
  93385. * Compiled shader to webGL program.
  93386. * @hidden
  93387. */
  93388. _pipelineContext: Nullable<IPipelineContext>;
  93389. private _valueCache;
  93390. private static _baseCache;
  93391. /**
  93392. * Instantiates an effect.
  93393. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93394. * @param baseName Name of the effect.
  93395. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93396. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93397. * @param samplers List of sampler variables that will be passed to the shader.
  93398. * @param engine Engine to be used to render the effect
  93399. * @param defines Define statements to be added to the shader.
  93400. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93401. * @param onCompiled Callback that will be called when the shader is compiled.
  93402. * @param onError Callback that will be called if an error occurs during shader compilation.
  93403. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93404. */
  93405. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  93406. private _useFinalCode;
  93407. /**
  93408. * Unique key for this effect
  93409. */
  93410. readonly key: string;
  93411. /**
  93412. * If the effect has been compiled and prepared.
  93413. * @returns if the effect is compiled and prepared.
  93414. */
  93415. isReady(): boolean;
  93416. private _isReadyInternal;
  93417. /**
  93418. * The engine the effect was initialized with.
  93419. * @returns the engine.
  93420. */
  93421. getEngine(): Engine;
  93422. /**
  93423. * The pipeline context for this effect
  93424. * @returns the associated pipeline context
  93425. */
  93426. getPipelineContext(): Nullable<IPipelineContext>;
  93427. /**
  93428. * The set of names of attribute variables for the shader.
  93429. * @returns An array of attribute names.
  93430. */
  93431. getAttributesNames(): string[];
  93432. /**
  93433. * Returns the attribute at the given index.
  93434. * @param index The index of the attribute.
  93435. * @returns The location of the attribute.
  93436. */
  93437. getAttributeLocation(index: number): number;
  93438. /**
  93439. * Returns the attribute based on the name of the variable.
  93440. * @param name of the attribute to look up.
  93441. * @returns the attribute location.
  93442. */
  93443. getAttributeLocationByName(name: string): number;
  93444. /**
  93445. * The number of attributes.
  93446. * @returns the numnber of attributes.
  93447. */
  93448. getAttributesCount(): number;
  93449. /**
  93450. * Gets the index of a uniform variable.
  93451. * @param uniformName of the uniform to look up.
  93452. * @returns the index.
  93453. */
  93454. getUniformIndex(uniformName: string): number;
  93455. /**
  93456. * Returns the attribute based on the name of the variable.
  93457. * @param uniformName of the uniform to look up.
  93458. * @returns the location of the uniform.
  93459. */
  93460. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93461. /**
  93462. * Returns an array of sampler variable names
  93463. * @returns The array of sampler variable neames.
  93464. */
  93465. getSamplers(): string[];
  93466. /**
  93467. * The error from the last compilation.
  93468. * @returns the error string.
  93469. */
  93470. getCompilationError(): string;
  93471. /**
  93472. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93473. * @param func The callback to be used.
  93474. */
  93475. executeWhenCompiled(func: (effect: Effect) => void): void;
  93476. private _checkIsReady;
  93477. /** @hidden */
  93478. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93479. /** @hidden */
  93480. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93481. /** @hidden */
  93482. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93483. /**
  93484. * Recompiles the webGL program
  93485. * @param vertexSourceCode The source code for the vertex shader.
  93486. * @param fragmentSourceCode The source code for the fragment shader.
  93487. * @param onCompiled Callback called when completed.
  93488. * @param onError Callback called on error.
  93489. * @hidden
  93490. */
  93491. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93492. /**
  93493. * Prepares the effect
  93494. * @hidden
  93495. */
  93496. _prepareEffect(): void;
  93497. private _processCompilationErrors;
  93498. /**
  93499. * Checks if the effect is supported. (Must be called after compilation)
  93500. */
  93501. readonly isSupported: boolean;
  93502. /**
  93503. * Binds a texture to the engine to be used as output of the shader.
  93504. * @param channel Name of the output variable.
  93505. * @param texture Texture to bind.
  93506. * @hidden
  93507. */
  93508. _bindTexture(channel: string, texture: InternalTexture): void;
  93509. /**
  93510. * Sets a texture on the engine to be used in the shader.
  93511. * @param channel Name of the sampler variable.
  93512. * @param texture Texture to set.
  93513. */
  93514. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93515. /**
  93516. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93517. * @param channel Name of the sampler variable.
  93518. * @param texture Texture to set.
  93519. */
  93520. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93521. /**
  93522. * Sets an array of textures on the engine to be used in the shader.
  93523. * @param channel Name of the variable.
  93524. * @param textures Textures to set.
  93525. */
  93526. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93527. /**
  93528. * 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)
  93529. * @param channel Name of the sampler variable.
  93530. * @param postProcess Post process to get the input texture from.
  93531. */
  93532. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93533. /**
  93534. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93535. * 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)
  93536. * @param channel Name of the sampler variable.
  93537. * @param postProcess Post process to get the output texture from.
  93538. */
  93539. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93540. /** @hidden */
  93541. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93542. /** @hidden */
  93543. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93544. /** @hidden */
  93545. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93546. /** @hidden */
  93547. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93548. /**
  93549. * Binds a buffer to a uniform.
  93550. * @param buffer Buffer to bind.
  93551. * @param name Name of the uniform variable to bind to.
  93552. */
  93553. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93554. /**
  93555. * Binds block to a uniform.
  93556. * @param blockName Name of the block to bind.
  93557. * @param index Index to bind.
  93558. */
  93559. bindUniformBlock(blockName: string, index: number): void;
  93560. /**
  93561. * Sets an interger value on a uniform variable.
  93562. * @param uniformName Name of the variable.
  93563. * @param value Value to be set.
  93564. * @returns this effect.
  93565. */
  93566. setInt(uniformName: string, value: number): Effect;
  93567. /**
  93568. * Sets an int array on a uniform variable.
  93569. * @param uniformName Name of the variable.
  93570. * @param array array to be set.
  93571. * @returns this effect.
  93572. */
  93573. setIntArray(uniformName: string, array: Int32Array): Effect;
  93574. /**
  93575. * 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)
  93576. * @param uniformName Name of the variable.
  93577. * @param array array to be set.
  93578. * @returns this effect.
  93579. */
  93580. setIntArray2(uniformName: string, array: Int32Array): Effect;
  93581. /**
  93582. * 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)
  93583. * @param uniformName Name of the variable.
  93584. * @param array array to be set.
  93585. * @returns this effect.
  93586. */
  93587. setIntArray3(uniformName: string, array: Int32Array): Effect;
  93588. /**
  93589. * 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)
  93590. * @param uniformName Name of the variable.
  93591. * @param array array to be set.
  93592. * @returns this effect.
  93593. */
  93594. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93595. /**
  93596. * Sets an float array on a uniform variable.
  93597. * @param uniformName Name of the variable.
  93598. * @param array array to be set.
  93599. * @returns this effect.
  93600. */
  93601. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93602. /**
  93603. * 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)
  93604. * @param uniformName Name of the variable.
  93605. * @param array array to be set.
  93606. * @returns this effect.
  93607. */
  93608. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93609. /**
  93610. * 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)
  93611. * @param uniformName Name of the variable.
  93612. * @param array array to be set.
  93613. * @returns this effect.
  93614. */
  93615. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93616. /**
  93617. * 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)
  93618. * @param uniformName Name of the variable.
  93619. * @param array array to be set.
  93620. * @returns this effect.
  93621. */
  93622. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93623. /**
  93624. * Sets an array on a uniform variable.
  93625. * @param uniformName Name of the variable.
  93626. * @param array array to be set.
  93627. * @returns this effect.
  93628. */
  93629. setArray(uniformName: string, array: number[]): Effect;
  93630. /**
  93631. * 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)
  93632. * @param uniformName Name of the variable.
  93633. * @param array array to be set.
  93634. * @returns this effect.
  93635. */
  93636. setArray2(uniformName: string, array: number[]): Effect;
  93637. /**
  93638. * 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)
  93639. * @param uniformName Name of the variable.
  93640. * @param array array to be set.
  93641. * @returns this effect.
  93642. */
  93643. setArray3(uniformName: string, array: number[]): Effect;
  93644. /**
  93645. * 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)
  93646. * @param uniformName Name of the variable.
  93647. * @param array array to be set.
  93648. * @returns this effect.
  93649. */
  93650. setArray4(uniformName: string, array: number[]): Effect;
  93651. /**
  93652. * Sets matrices on a uniform variable.
  93653. * @param uniformName Name of the variable.
  93654. * @param matrices matrices to be set.
  93655. * @returns this effect.
  93656. */
  93657. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93658. /**
  93659. * Sets matrix on a uniform variable.
  93660. * @param uniformName Name of the variable.
  93661. * @param matrix matrix to be set.
  93662. * @returns this effect.
  93663. */
  93664. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93665. /**
  93666. * 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)
  93667. * @param uniformName Name of the variable.
  93668. * @param matrix matrix to be set.
  93669. * @returns this effect.
  93670. */
  93671. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93672. /**
  93673. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93674. * @param uniformName Name of the variable.
  93675. * @param matrix matrix to be set.
  93676. * @returns this effect.
  93677. */
  93678. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93679. /**
  93680. * Sets a float on a uniform variable.
  93681. * @param uniformName Name of the variable.
  93682. * @param value value to be set.
  93683. * @returns this effect.
  93684. */
  93685. setFloat(uniformName: string, value: number): Effect;
  93686. /**
  93687. * Sets a boolean on a uniform variable.
  93688. * @param uniformName Name of the variable.
  93689. * @param bool value to be set.
  93690. * @returns this effect.
  93691. */
  93692. setBool(uniformName: string, bool: boolean): Effect;
  93693. /**
  93694. * Sets a Vector2 on a uniform variable.
  93695. * @param uniformName Name of the variable.
  93696. * @param vector2 vector2 to be set.
  93697. * @returns this effect.
  93698. */
  93699. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93700. /**
  93701. * Sets a float2 on a uniform variable.
  93702. * @param uniformName Name of the variable.
  93703. * @param x First float in float2.
  93704. * @param y Second float in float2.
  93705. * @returns this effect.
  93706. */
  93707. setFloat2(uniformName: string, x: number, y: number): Effect;
  93708. /**
  93709. * Sets a Vector3 on a uniform variable.
  93710. * @param uniformName Name of the variable.
  93711. * @param vector3 Value to be set.
  93712. * @returns this effect.
  93713. */
  93714. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93715. /**
  93716. * Sets a float3 on a uniform variable.
  93717. * @param uniformName Name of the variable.
  93718. * @param x First float in float3.
  93719. * @param y Second float in float3.
  93720. * @param z Third float in float3.
  93721. * @returns this effect.
  93722. */
  93723. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93724. /**
  93725. * Sets a Vector4 on a uniform variable.
  93726. * @param uniformName Name of the variable.
  93727. * @param vector4 Value to be set.
  93728. * @returns this effect.
  93729. */
  93730. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93731. /**
  93732. * Sets a float4 on a uniform variable.
  93733. * @param uniformName Name of the variable.
  93734. * @param x First float in float4.
  93735. * @param y Second float in float4.
  93736. * @param z Third float in float4.
  93737. * @param w Fourth float in float4.
  93738. * @returns this effect.
  93739. */
  93740. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93741. /**
  93742. * Sets a Color3 on a uniform variable.
  93743. * @param uniformName Name of the variable.
  93744. * @param color3 Value to be set.
  93745. * @returns this effect.
  93746. */
  93747. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93748. /**
  93749. * Sets a Color4 on a uniform variable.
  93750. * @param uniformName Name of the variable.
  93751. * @param color3 Value to be set.
  93752. * @param alpha Alpha value to be set.
  93753. * @returns this effect.
  93754. */
  93755. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93756. /**
  93757. * Sets a Color4 on a uniform variable
  93758. * @param uniformName defines the name of the variable
  93759. * @param color4 defines the value to be set
  93760. * @returns this effect.
  93761. */
  93762. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93763. /** Release all associated resources */
  93764. dispose(): void;
  93765. /**
  93766. * This function will add a new shader to the shader store
  93767. * @param name the name of the shader
  93768. * @param pixelShader optional pixel shader content
  93769. * @param vertexShader optional vertex shader content
  93770. */
  93771. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93772. /**
  93773. * Store of each shader (The can be looked up using effect.key)
  93774. */
  93775. static ShadersStore: {
  93776. [key: string]: string;
  93777. };
  93778. /**
  93779. * Store of each included file for a shader (The can be looked up using effect.key)
  93780. */
  93781. static IncludesShadersStore: {
  93782. [key: string]: string;
  93783. };
  93784. /**
  93785. * Resets the cache of effects.
  93786. */
  93787. static ResetCache(): void;
  93788. }
  93789. }
  93790. declare module BABYLON {
  93791. /**
  93792. * Uniform buffer objects.
  93793. *
  93794. * Handles blocks of uniform on the GPU.
  93795. *
  93796. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93797. *
  93798. * For more information, please refer to :
  93799. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93800. */
  93801. export class UniformBuffer {
  93802. private _engine;
  93803. private _buffer;
  93804. private _data;
  93805. private _bufferData;
  93806. private _dynamic?;
  93807. private _uniformLocations;
  93808. private _uniformSizes;
  93809. private _uniformLocationPointer;
  93810. private _needSync;
  93811. private _noUBO;
  93812. private _currentEffect;
  93813. private static _MAX_UNIFORM_SIZE;
  93814. private static _tempBuffer;
  93815. /**
  93816. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93817. * This is dynamic to allow compat with webgl 1 and 2.
  93818. * You will need to pass the name of the uniform as well as the value.
  93819. */
  93820. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93821. /**
  93822. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93823. * This is dynamic to allow compat with webgl 1 and 2.
  93824. * You will need to pass the name of the uniform as well as the value.
  93825. */
  93826. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93827. /**
  93828. * Lambda to Update a single float in a uniform buffer.
  93829. * This is dynamic to allow compat with webgl 1 and 2.
  93830. * You will need to pass the name of the uniform as well as the value.
  93831. */
  93832. updateFloat: (name: string, x: number) => void;
  93833. /**
  93834. * Lambda to Update a vec2 of float in a uniform buffer.
  93835. * This is dynamic to allow compat with webgl 1 and 2.
  93836. * You will need to pass the name of the uniform as well as the value.
  93837. */
  93838. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93839. /**
  93840. * Lambda to Update a vec3 of float in a uniform buffer.
  93841. * This is dynamic to allow compat with webgl 1 and 2.
  93842. * You will need to pass the name of the uniform as well as the value.
  93843. */
  93844. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93845. /**
  93846. * Lambda to Update a vec4 of float in a uniform buffer.
  93847. * This is dynamic to allow compat with webgl 1 and 2.
  93848. * You will need to pass the name of the uniform as well as the value.
  93849. */
  93850. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93851. /**
  93852. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93853. * This is dynamic to allow compat with webgl 1 and 2.
  93854. * You will need to pass the name of the uniform as well as the value.
  93855. */
  93856. updateMatrix: (name: string, mat: Matrix) => void;
  93857. /**
  93858. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93859. * This is dynamic to allow compat with webgl 1 and 2.
  93860. * You will need to pass the name of the uniform as well as the value.
  93861. */
  93862. updateVector3: (name: string, vector: Vector3) => void;
  93863. /**
  93864. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93865. * This is dynamic to allow compat with webgl 1 and 2.
  93866. * You will need to pass the name of the uniform as well as the value.
  93867. */
  93868. updateVector4: (name: string, vector: Vector4) => void;
  93869. /**
  93870. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93871. * This is dynamic to allow compat with webgl 1 and 2.
  93872. * You will need to pass the name of the uniform as well as the value.
  93873. */
  93874. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93875. /**
  93876. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93877. * This is dynamic to allow compat with webgl 1 and 2.
  93878. * You will need to pass the name of the uniform as well as the value.
  93879. */
  93880. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93881. /**
  93882. * Instantiates a new Uniform buffer objects.
  93883. *
  93884. * Handles blocks of uniform on the GPU.
  93885. *
  93886. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93887. *
  93888. * For more information, please refer to :
  93889. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93890. * @param engine Define the engine the buffer is associated with
  93891. * @param data Define the data contained in the buffer
  93892. * @param dynamic Define if the buffer is updatable
  93893. */
  93894. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93895. /**
  93896. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93897. * or just falling back on setUniformXXX calls.
  93898. */
  93899. readonly useUbo: boolean;
  93900. /**
  93901. * Indicates if the WebGL underlying uniform buffer is in sync
  93902. * with the javascript cache data.
  93903. */
  93904. readonly isSync: boolean;
  93905. /**
  93906. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93907. * Also, a dynamic UniformBuffer will disable cache verification and always
  93908. * update the underlying WebGL uniform buffer to the GPU.
  93909. * @returns if Dynamic, otherwise false
  93910. */
  93911. isDynamic(): boolean;
  93912. /**
  93913. * The data cache on JS side.
  93914. * @returns the underlying data as a float array
  93915. */
  93916. getData(): Float32Array;
  93917. /**
  93918. * The underlying WebGL Uniform buffer.
  93919. * @returns the webgl buffer
  93920. */
  93921. getBuffer(): Nullable<DataBuffer>;
  93922. /**
  93923. * std140 layout specifies how to align data within an UBO structure.
  93924. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93925. * for specs.
  93926. */
  93927. private _fillAlignment;
  93928. /**
  93929. * Adds an uniform in the buffer.
  93930. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93931. * for the layout to be correct !
  93932. * @param name Name of the uniform, as used in the uniform block in the shader.
  93933. * @param size Data size, or data directly.
  93934. */
  93935. addUniform(name: string, size: number | number[]): void;
  93936. /**
  93937. * Adds a Matrix 4x4 to the uniform buffer.
  93938. * @param name Name of the uniform, as used in the uniform block in the shader.
  93939. * @param mat A 4x4 matrix.
  93940. */
  93941. addMatrix(name: string, mat: Matrix): void;
  93942. /**
  93943. * Adds a vec2 to the uniform buffer.
  93944. * @param name Name of the uniform, as used in the uniform block in the shader.
  93945. * @param x Define the x component value of the vec2
  93946. * @param y Define the y component value of the vec2
  93947. */
  93948. addFloat2(name: string, x: number, y: number): void;
  93949. /**
  93950. * Adds a vec3 to the uniform buffer.
  93951. * @param name Name of the uniform, as used in the uniform block in the shader.
  93952. * @param x Define the x component value of the vec3
  93953. * @param y Define the y component value of the vec3
  93954. * @param z Define the z component value of the vec3
  93955. */
  93956. addFloat3(name: string, x: number, y: number, z: number): void;
  93957. /**
  93958. * Adds a vec3 to the uniform buffer.
  93959. * @param name Name of the uniform, as used in the uniform block in the shader.
  93960. * @param color Define the vec3 from a Color
  93961. */
  93962. addColor3(name: string, color: Color3): void;
  93963. /**
  93964. * Adds a vec4 to the uniform buffer.
  93965. * @param name Name of the uniform, as used in the uniform block in the shader.
  93966. * @param color Define the rgb components from a Color
  93967. * @param alpha Define the a component of the vec4
  93968. */
  93969. addColor4(name: string, color: Color3, alpha: number): void;
  93970. /**
  93971. * Adds a vec3 to the uniform buffer.
  93972. * @param name Name of the uniform, as used in the uniform block in the shader.
  93973. * @param vector Define the vec3 components from a Vector
  93974. */
  93975. addVector3(name: string, vector: Vector3): void;
  93976. /**
  93977. * Adds a Matrix 3x3 to the uniform buffer.
  93978. * @param name Name of the uniform, as used in the uniform block in the shader.
  93979. */
  93980. addMatrix3x3(name: string): void;
  93981. /**
  93982. * Adds a Matrix 2x2 to the uniform buffer.
  93983. * @param name Name of the uniform, as used in the uniform block in the shader.
  93984. */
  93985. addMatrix2x2(name: string): void;
  93986. /**
  93987. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93988. */
  93989. create(): void;
  93990. /** @hidden */
  93991. _rebuild(): void;
  93992. /**
  93993. * Updates the WebGL Uniform Buffer on the GPU.
  93994. * If the `dynamic` flag is set to true, no cache comparison is done.
  93995. * Otherwise, the buffer will be updated only if the cache differs.
  93996. */
  93997. update(): void;
  93998. /**
  93999. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94000. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94001. * @param data Define the flattened data
  94002. * @param size Define the size of the data.
  94003. */
  94004. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94005. private _valueCache;
  94006. private _cacheMatrix;
  94007. private _updateMatrix3x3ForUniform;
  94008. private _updateMatrix3x3ForEffect;
  94009. private _updateMatrix2x2ForEffect;
  94010. private _updateMatrix2x2ForUniform;
  94011. private _updateFloatForEffect;
  94012. private _updateFloatForUniform;
  94013. private _updateFloat2ForEffect;
  94014. private _updateFloat2ForUniform;
  94015. private _updateFloat3ForEffect;
  94016. private _updateFloat3ForUniform;
  94017. private _updateFloat4ForEffect;
  94018. private _updateFloat4ForUniform;
  94019. private _updateMatrixForEffect;
  94020. private _updateMatrixForUniform;
  94021. private _updateVector3ForEffect;
  94022. private _updateVector3ForUniform;
  94023. private _updateVector4ForEffect;
  94024. private _updateVector4ForUniform;
  94025. private _updateColor3ForEffect;
  94026. private _updateColor3ForUniform;
  94027. private _updateColor4ForEffect;
  94028. private _updateColor4ForUniform;
  94029. /**
  94030. * Sets a sampler uniform on the effect.
  94031. * @param name Define the name of the sampler.
  94032. * @param texture Define the texture to set in the sampler
  94033. */
  94034. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94035. /**
  94036. * Directly updates the value of the uniform in the cache AND on the GPU.
  94037. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94038. * @param data Define the flattened data
  94039. */
  94040. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94041. /**
  94042. * Binds this uniform buffer to an effect.
  94043. * @param effect Define the effect to bind the buffer to
  94044. * @param name Name of the uniform block in the shader.
  94045. */
  94046. bindToEffect(effect: Effect, name: string): void;
  94047. /**
  94048. * Disposes the uniform buffer.
  94049. */
  94050. dispose(): void;
  94051. }
  94052. }
  94053. declare module BABYLON {
  94054. /**
  94055. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94057. */
  94058. export class Analyser {
  94059. /**
  94060. * Gets or sets the smoothing
  94061. * @ignorenaming
  94062. */
  94063. SMOOTHING: number;
  94064. /**
  94065. * Gets or sets the FFT table size
  94066. * @ignorenaming
  94067. */
  94068. FFT_SIZE: number;
  94069. /**
  94070. * Gets or sets the bar graph amplitude
  94071. * @ignorenaming
  94072. */
  94073. BARGRAPHAMPLITUDE: number;
  94074. /**
  94075. * Gets or sets the position of the debug canvas
  94076. * @ignorenaming
  94077. */
  94078. DEBUGCANVASPOS: {
  94079. x: number;
  94080. y: number;
  94081. };
  94082. /**
  94083. * Gets or sets the debug canvas size
  94084. * @ignorenaming
  94085. */
  94086. DEBUGCANVASSIZE: {
  94087. width: number;
  94088. height: number;
  94089. };
  94090. private _byteFreqs;
  94091. private _byteTime;
  94092. private _floatFreqs;
  94093. private _webAudioAnalyser;
  94094. private _debugCanvas;
  94095. private _debugCanvasContext;
  94096. private _scene;
  94097. private _registerFunc;
  94098. private _audioEngine;
  94099. /**
  94100. * Creates a new analyser
  94101. * @param scene defines hosting scene
  94102. */
  94103. constructor(scene: Scene);
  94104. /**
  94105. * Get the number of data values you will have to play with for the visualization
  94106. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94107. * @returns a number
  94108. */
  94109. getFrequencyBinCount(): number;
  94110. /**
  94111. * Gets the current frequency data as a byte array
  94112. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94113. * @returns a Uint8Array
  94114. */
  94115. getByteFrequencyData(): Uint8Array;
  94116. /**
  94117. * Gets the current waveform as a byte array
  94118. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94119. * @returns a Uint8Array
  94120. */
  94121. getByteTimeDomainData(): Uint8Array;
  94122. /**
  94123. * Gets the current frequency data as a float array
  94124. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94125. * @returns a Float32Array
  94126. */
  94127. getFloatFrequencyData(): Float32Array;
  94128. /**
  94129. * Renders the debug canvas
  94130. */
  94131. drawDebugCanvas(): void;
  94132. /**
  94133. * Stops rendering the debug canvas and removes it
  94134. */
  94135. stopDebugCanvas(): void;
  94136. /**
  94137. * Connects two audio nodes
  94138. * @param inputAudioNode defines first node to connect
  94139. * @param outputAudioNode defines second node to connect
  94140. */
  94141. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94142. /**
  94143. * Releases all associated resources
  94144. */
  94145. dispose(): void;
  94146. }
  94147. }
  94148. declare module BABYLON {
  94149. /**
  94150. * This represents an audio engine and it is responsible
  94151. * to play, synchronize and analyse sounds throughout the application.
  94152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94153. */
  94154. export interface IAudioEngine extends IDisposable {
  94155. /**
  94156. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94157. */
  94158. readonly canUseWebAudio: boolean;
  94159. /**
  94160. * Gets the current AudioContext if available.
  94161. */
  94162. readonly audioContext: Nullable<AudioContext>;
  94163. /**
  94164. * The master gain node defines the global audio volume of your audio engine.
  94165. */
  94166. readonly masterGain: GainNode;
  94167. /**
  94168. * Gets whether or not mp3 are supported by your browser.
  94169. */
  94170. readonly isMP3supported: boolean;
  94171. /**
  94172. * Gets whether or not ogg are supported by your browser.
  94173. */
  94174. readonly isOGGsupported: boolean;
  94175. /**
  94176. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94177. * @ignoreNaming
  94178. */
  94179. WarnedWebAudioUnsupported: boolean;
  94180. /**
  94181. * Defines if the audio engine relies on a custom unlocked button.
  94182. * In this case, the embedded button will not be displayed.
  94183. */
  94184. useCustomUnlockedButton: boolean;
  94185. /**
  94186. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94187. */
  94188. readonly unlocked: boolean;
  94189. /**
  94190. * Event raised when audio has been unlocked on the browser.
  94191. */
  94192. onAudioUnlockedObservable: Observable<AudioEngine>;
  94193. /**
  94194. * Event raised when audio has been locked on the browser.
  94195. */
  94196. onAudioLockedObservable: Observable<AudioEngine>;
  94197. /**
  94198. * Flags the audio engine in Locked state.
  94199. * This happens due to new browser policies preventing audio to autoplay.
  94200. */
  94201. lock(): void;
  94202. /**
  94203. * Unlocks the audio engine once a user action has been done on the dom.
  94204. * This is helpful to resume play once browser policies have been satisfied.
  94205. */
  94206. unlock(): void;
  94207. }
  94208. /**
  94209. * This represents the default audio engine used in babylon.
  94210. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94212. */
  94213. export class AudioEngine implements IAudioEngine {
  94214. private _audioContext;
  94215. private _audioContextInitialized;
  94216. private _muteButton;
  94217. private _hostElement;
  94218. /**
  94219. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94220. */
  94221. canUseWebAudio: boolean;
  94222. /**
  94223. * The master gain node defines the global audio volume of your audio engine.
  94224. */
  94225. masterGain: GainNode;
  94226. /**
  94227. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94228. * @ignoreNaming
  94229. */
  94230. WarnedWebAudioUnsupported: boolean;
  94231. /**
  94232. * Gets whether or not mp3 are supported by your browser.
  94233. */
  94234. isMP3supported: boolean;
  94235. /**
  94236. * Gets whether or not ogg are supported by your browser.
  94237. */
  94238. isOGGsupported: boolean;
  94239. /**
  94240. * Gets whether audio has been unlocked on the device.
  94241. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94242. * a user interaction has happened.
  94243. */
  94244. unlocked: boolean;
  94245. /**
  94246. * Defines if the audio engine relies on a custom unlocked button.
  94247. * In this case, the embedded button will not be displayed.
  94248. */
  94249. useCustomUnlockedButton: boolean;
  94250. /**
  94251. * Event raised when audio has been unlocked on the browser.
  94252. */
  94253. onAudioUnlockedObservable: Observable<AudioEngine>;
  94254. /**
  94255. * Event raised when audio has been locked on the browser.
  94256. */
  94257. onAudioLockedObservable: Observable<AudioEngine>;
  94258. /**
  94259. * Gets the current AudioContext if available.
  94260. */
  94261. readonly audioContext: Nullable<AudioContext>;
  94262. private _connectedAnalyser;
  94263. /**
  94264. * Instantiates a new audio engine.
  94265. *
  94266. * There should be only one per page as some browsers restrict the number
  94267. * of audio contexts you can create.
  94268. * @param hostElement defines the host element where to display the mute icon if necessary
  94269. */
  94270. constructor(hostElement?: Nullable<HTMLElement>);
  94271. /**
  94272. * Flags the audio engine in Locked state.
  94273. * This happens due to new browser policies preventing audio to autoplay.
  94274. */
  94275. lock(): void;
  94276. /**
  94277. * Unlocks the audio engine once a user action has been done on the dom.
  94278. * This is helpful to resume play once browser policies have been satisfied.
  94279. */
  94280. unlock(): void;
  94281. private _resumeAudioContext;
  94282. private _initializeAudioContext;
  94283. private _tryToRun;
  94284. private _triggerRunningState;
  94285. private _triggerSuspendedState;
  94286. private _displayMuteButton;
  94287. private _moveButtonToTopLeft;
  94288. private _onResize;
  94289. private _hideMuteButton;
  94290. /**
  94291. * Destroy and release the resources associated with the audio ccontext.
  94292. */
  94293. dispose(): void;
  94294. /**
  94295. * Gets the global volume sets on the master gain.
  94296. * @returns the global volume if set or -1 otherwise
  94297. */
  94298. getGlobalVolume(): number;
  94299. /**
  94300. * Sets the global volume of your experience (sets on the master gain).
  94301. * @param newVolume Defines the new global volume of the application
  94302. */
  94303. setGlobalVolume(newVolume: number): void;
  94304. /**
  94305. * Connect the audio engine to an audio analyser allowing some amazing
  94306. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94308. * @param analyser The analyser to connect to the engine
  94309. */
  94310. connectToAnalyser(analyser: Analyser): void;
  94311. }
  94312. }
  94313. declare module BABYLON {
  94314. /**
  94315. * Interface used to present a loading screen while loading a scene
  94316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94317. */
  94318. export interface ILoadingScreen {
  94319. /**
  94320. * Function called to display the loading screen
  94321. */
  94322. displayLoadingUI: () => void;
  94323. /**
  94324. * Function called to hide the loading screen
  94325. */
  94326. hideLoadingUI: () => void;
  94327. /**
  94328. * Gets or sets the color to use for the background
  94329. */
  94330. loadingUIBackgroundColor: string;
  94331. /**
  94332. * Gets or sets the text to display while loading
  94333. */
  94334. loadingUIText: string;
  94335. }
  94336. /**
  94337. * Class used for the default loading screen
  94338. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94339. */
  94340. export class DefaultLoadingScreen implements ILoadingScreen {
  94341. private _renderingCanvas;
  94342. private _loadingText;
  94343. private _loadingDivBackgroundColor;
  94344. private _loadingDiv;
  94345. private _loadingTextDiv;
  94346. /** Gets or sets the logo url to use for the default loading screen */
  94347. static DefaultLogoUrl: string;
  94348. /** Gets or sets the spinner url to use for the default loading screen */
  94349. static DefaultSpinnerUrl: string;
  94350. /**
  94351. * Creates a new default loading screen
  94352. * @param _renderingCanvas defines the canvas used to render the scene
  94353. * @param _loadingText defines the default text to display
  94354. * @param _loadingDivBackgroundColor defines the default background color
  94355. */
  94356. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94357. /**
  94358. * Function called to display the loading screen
  94359. */
  94360. displayLoadingUI(): void;
  94361. /**
  94362. * Function called to hide the loading screen
  94363. */
  94364. hideLoadingUI(): void;
  94365. /**
  94366. * Gets or sets the text to display while loading
  94367. */
  94368. loadingUIText: string;
  94369. /**
  94370. * Gets or sets the color to use for the background
  94371. */
  94372. loadingUIBackgroundColor: string;
  94373. private _resizeLoadingUI;
  94374. }
  94375. }
  94376. declare module BABYLON {
  94377. /** @hidden */
  94378. export class WebGLPipelineContext implements IPipelineContext {
  94379. engine: Engine;
  94380. program: Nullable<WebGLProgram>;
  94381. context?: WebGLRenderingContext;
  94382. vertexShader?: WebGLShader;
  94383. fragmentShader?: WebGLShader;
  94384. isParallelCompiled: boolean;
  94385. onCompiled?: () => void;
  94386. transformFeedback?: WebGLTransformFeedback | null;
  94387. readonly isAsync: boolean;
  94388. readonly isReady: boolean;
  94389. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94390. }
  94391. }
  94392. declare module BABYLON {
  94393. /** @hidden */
  94394. export class WebGLDataBuffer extends DataBuffer {
  94395. private _buffer;
  94396. constructor(resource: WebGLBuffer);
  94397. readonly underlyingResource: any;
  94398. }
  94399. }
  94400. declare module BABYLON {
  94401. /** @hidden */
  94402. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94403. attributeProcessor(attribute: string): string;
  94404. varyingProcessor(varying: string, isFragment: boolean): string;
  94405. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94406. }
  94407. }
  94408. declare module BABYLON {
  94409. /**
  94410. * This class is used to track a performance counter which is number based.
  94411. * The user has access to many properties which give statistics of different nature.
  94412. *
  94413. * The implementer can track two kinds of Performance Counter: time and count.
  94414. * 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.
  94415. * 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.
  94416. */
  94417. export class PerfCounter {
  94418. /**
  94419. * Gets or sets a global boolean to turn on and off all the counters
  94420. */
  94421. static Enabled: boolean;
  94422. /**
  94423. * Returns the smallest value ever
  94424. */
  94425. readonly min: number;
  94426. /**
  94427. * Returns the biggest value ever
  94428. */
  94429. readonly max: number;
  94430. /**
  94431. * Returns the average value since the performance counter is running
  94432. */
  94433. readonly average: number;
  94434. /**
  94435. * Returns the average value of the last second the counter was monitored
  94436. */
  94437. readonly lastSecAverage: number;
  94438. /**
  94439. * Returns the current value
  94440. */
  94441. readonly current: number;
  94442. /**
  94443. * Gets the accumulated total
  94444. */
  94445. readonly total: number;
  94446. /**
  94447. * Gets the total value count
  94448. */
  94449. readonly count: number;
  94450. /**
  94451. * Creates a new counter
  94452. */
  94453. constructor();
  94454. /**
  94455. * Call this method to start monitoring a new frame.
  94456. * 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.
  94457. */
  94458. fetchNewFrame(): void;
  94459. /**
  94460. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94461. * @param newCount the count value to add to the monitored count
  94462. * @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.
  94463. */
  94464. addCount(newCount: number, fetchResult: boolean): void;
  94465. /**
  94466. * Start monitoring this performance counter
  94467. */
  94468. beginMonitoring(): void;
  94469. /**
  94470. * Compute the time lapsed since the previous beginMonitoring() call.
  94471. * @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
  94472. */
  94473. endMonitoring(newFrame?: boolean): void;
  94474. private _fetchResult;
  94475. private _startMonitoringTime;
  94476. private _min;
  94477. private _max;
  94478. private _average;
  94479. private _current;
  94480. private _totalValueCount;
  94481. private _totalAccumulated;
  94482. private _lastSecAverage;
  94483. private _lastSecAccumulated;
  94484. private _lastSecTime;
  94485. private _lastSecValueCount;
  94486. }
  94487. }
  94488. declare module BABYLON {
  94489. /**
  94490. * Interface for any object that can request an animation frame
  94491. */
  94492. export interface ICustomAnimationFrameRequester {
  94493. /**
  94494. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94495. */
  94496. renderFunction?: Function;
  94497. /**
  94498. * Called to request the next frame to render to
  94499. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94500. */
  94501. requestAnimationFrame: Function;
  94502. /**
  94503. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94504. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94505. */
  94506. requestID?: number;
  94507. }
  94508. }
  94509. declare module BABYLON {
  94510. /**
  94511. * Settings for finer control over video usage
  94512. */
  94513. export interface VideoTextureSettings {
  94514. /**
  94515. * Applies `autoplay` to video, if specified
  94516. */
  94517. autoPlay?: boolean;
  94518. /**
  94519. * Applies `loop` to video, if specified
  94520. */
  94521. loop?: boolean;
  94522. /**
  94523. * Automatically updates internal texture from video at every frame in the render loop
  94524. */
  94525. autoUpdateTexture: boolean;
  94526. /**
  94527. * Image src displayed during the video loading or until the user interacts with the video.
  94528. */
  94529. poster?: string;
  94530. }
  94531. /**
  94532. * If you want to display a video in your scene, this is the special texture for that.
  94533. * This special texture works similar to other textures, with the exception of a few parameters.
  94534. * @see https://doc.babylonjs.com/how_to/video_texture
  94535. */
  94536. export class VideoTexture extends Texture {
  94537. /**
  94538. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94539. */
  94540. readonly autoUpdateTexture: boolean;
  94541. /**
  94542. * The video instance used by the texture internally
  94543. */
  94544. readonly video: HTMLVideoElement;
  94545. private _onUserActionRequestedObservable;
  94546. /**
  94547. * Event triggerd when a dom action is required by the user to play the video.
  94548. * This happens due to recent changes in browser policies preventing video to auto start.
  94549. */
  94550. readonly onUserActionRequestedObservable: Observable<Texture>;
  94551. private _generateMipMaps;
  94552. private _engine;
  94553. private _stillImageCaptured;
  94554. private _displayingPosterTexture;
  94555. private _settings;
  94556. private _createInternalTextureOnEvent;
  94557. private _frameId;
  94558. /**
  94559. * Creates a video texture.
  94560. * If you want to display a video in your scene, this is the special texture for that.
  94561. * This special texture works similar to other textures, with the exception of a few parameters.
  94562. * @see https://doc.babylonjs.com/how_to/video_texture
  94563. * @param name optional name, will detect from video source, if not defined
  94564. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94565. * @param scene is obviously the current scene.
  94566. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94567. * @param invertY is false by default but can be used to invert video on Y axis
  94568. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  94569. * @param settings allows finer control over video usage
  94570. */
  94571. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  94572. private _getName;
  94573. private _getVideo;
  94574. private _createInternalTexture;
  94575. private reset;
  94576. /**
  94577. * @hidden Internal method to initiate `update`.
  94578. */
  94579. _rebuild(): void;
  94580. /**
  94581. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  94582. */
  94583. update(): void;
  94584. /**
  94585. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  94586. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  94587. */
  94588. updateTexture(isVisible: boolean): void;
  94589. protected _updateInternalTexture: () => void;
  94590. /**
  94591. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  94592. * @param url New url.
  94593. */
  94594. updateURL(url: string): void;
  94595. /**
  94596. * Dispose the texture and release its associated resources.
  94597. */
  94598. dispose(): void;
  94599. /**
  94600. * Creates a video texture straight from a stream.
  94601. * @param scene Define the scene the texture should be created in
  94602. * @param stream Define the stream the texture should be created from
  94603. * @returns The created video texture as a promise
  94604. */
  94605. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94606. /**
  94607. * Creates a video texture straight from your WebCam video feed.
  94608. * @param scene Define the scene the texture should be created in
  94609. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94610. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94611. * @returns The created video texture as a promise
  94612. */
  94613. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94614. minWidth: number;
  94615. maxWidth: number;
  94616. minHeight: number;
  94617. maxHeight: number;
  94618. deviceId: string;
  94619. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94620. /**
  94621. * Creates a video texture straight from your WebCam video feed.
  94622. * @param scene Define the scene the texture should be created in
  94623. * @param onReady Define a callback to triggered once the texture will be ready
  94624. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94625. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94626. */
  94627. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94628. minWidth: number;
  94629. maxWidth: number;
  94630. minHeight: number;
  94631. maxHeight: number;
  94632. deviceId: string;
  94633. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94634. }
  94635. }
  94636. declare module BABYLON {
  94637. /**
  94638. * Defines the interface used by objects containing a viewport (like a camera)
  94639. */
  94640. interface IViewportOwnerLike {
  94641. /**
  94642. * Gets or sets the viewport
  94643. */
  94644. viewport: IViewportLike;
  94645. }
  94646. /**
  94647. * Interface for attribute information associated with buffer instanciation
  94648. */
  94649. export class InstancingAttributeInfo {
  94650. /**
  94651. * Index/offset of the attribute in the vertex shader
  94652. */
  94653. index: number;
  94654. /**
  94655. * size of the attribute, 1, 2, 3 or 4
  94656. */
  94657. attributeSize: number;
  94658. /**
  94659. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94660. * default is FLOAT
  94661. */
  94662. attribyteType: number;
  94663. /**
  94664. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94665. */
  94666. normalized: boolean;
  94667. /**
  94668. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94669. */
  94670. offset: number;
  94671. /**
  94672. * Name of the GLSL attribute, for debugging purpose only
  94673. */
  94674. attributeName: string;
  94675. }
  94676. /**
  94677. * Define options used to create a depth texture
  94678. */
  94679. export class DepthTextureCreationOptions {
  94680. /** Specifies whether or not a stencil should be allocated in the texture */
  94681. generateStencil?: boolean;
  94682. /** Specifies whether or not bilinear filtering is enable on the texture */
  94683. bilinearFiltering?: boolean;
  94684. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94685. comparisonFunction?: number;
  94686. /** Specifies if the created texture is a cube texture */
  94687. isCube?: boolean;
  94688. }
  94689. /**
  94690. * Class used to describe the capabilities of the engine relatively to the current browser
  94691. */
  94692. export class EngineCapabilities {
  94693. /** Maximum textures units per fragment shader */
  94694. maxTexturesImageUnits: number;
  94695. /** Maximum texture units per vertex shader */
  94696. maxVertexTextureImageUnits: number;
  94697. /** Maximum textures units in the entire pipeline */
  94698. maxCombinedTexturesImageUnits: number;
  94699. /** Maximum texture size */
  94700. maxTextureSize: number;
  94701. /** Maximum cube texture size */
  94702. maxCubemapTextureSize: number;
  94703. /** Maximum render texture size */
  94704. maxRenderTextureSize: number;
  94705. /** Maximum number of vertex attributes */
  94706. maxVertexAttribs: number;
  94707. /** Maximum number of varyings */
  94708. maxVaryingVectors: number;
  94709. /** Maximum number of uniforms per vertex shader */
  94710. maxVertexUniformVectors: number;
  94711. /** Maximum number of uniforms per fragment shader */
  94712. maxFragmentUniformVectors: number;
  94713. /** Defines if standard derivates (dx/dy) are supported */
  94714. standardDerivatives: boolean;
  94715. /** Defines if s3tc texture compression is supported */
  94716. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94717. /** Defines if pvrtc texture compression is supported */
  94718. pvrtc: any;
  94719. /** Defines if etc1 texture compression is supported */
  94720. etc1: any;
  94721. /** Defines if etc2 texture compression is supported */
  94722. etc2: any;
  94723. /** Defines if astc texture compression is supported */
  94724. astc: any;
  94725. /** Defines if float textures are supported */
  94726. textureFloat: boolean;
  94727. /** Defines if vertex array objects are supported */
  94728. vertexArrayObject: boolean;
  94729. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94730. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94731. /** Gets the maximum level of anisotropy supported */
  94732. maxAnisotropy: number;
  94733. /** Defines if instancing is supported */
  94734. instancedArrays: boolean;
  94735. /** Defines if 32 bits indices are supported */
  94736. uintIndices: boolean;
  94737. /** Defines if high precision shaders are supported */
  94738. highPrecisionShaderSupported: boolean;
  94739. /** Defines if depth reading in the fragment shader is supported */
  94740. fragmentDepthSupported: boolean;
  94741. /** Defines if float texture linear filtering is supported*/
  94742. textureFloatLinearFiltering: boolean;
  94743. /** Defines if rendering to float textures is supported */
  94744. textureFloatRender: boolean;
  94745. /** Defines if half float textures are supported*/
  94746. textureHalfFloat: boolean;
  94747. /** Defines if half float texture linear filtering is supported*/
  94748. textureHalfFloatLinearFiltering: boolean;
  94749. /** Defines if rendering to half float textures is supported */
  94750. textureHalfFloatRender: boolean;
  94751. /** Defines if textureLOD shader command is supported */
  94752. textureLOD: boolean;
  94753. /** Defines if draw buffers extension is supported */
  94754. drawBuffersExtension: boolean;
  94755. /** Defines if depth textures are supported */
  94756. depthTextureExtension: boolean;
  94757. /** Defines if float color buffer are supported */
  94758. colorBufferFloat: boolean;
  94759. /** Gets disjoint timer query extension (null if not supported) */
  94760. timerQuery: EXT_disjoint_timer_query;
  94761. /** Defines if timestamp can be used with timer query */
  94762. canUseTimestampForTimerQuery: boolean;
  94763. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94764. multiview: any;
  94765. /** Function used to let the system compiles shaders in background */
  94766. parallelShaderCompile: {
  94767. COMPLETION_STATUS_KHR: number;
  94768. };
  94769. /** Max number of texture samples for MSAA */
  94770. maxMSAASamples: number;
  94771. }
  94772. /** Interface defining initialization parameters for Engine class */
  94773. export interface EngineOptions extends WebGLContextAttributes {
  94774. /**
  94775. * Defines if the engine should no exceed a specified device ratio
  94776. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94777. */
  94778. limitDeviceRatio?: number;
  94779. /**
  94780. * Defines if webvr should be enabled automatically
  94781. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94782. */
  94783. autoEnableWebVR?: boolean;
  94784. /**
  94785. * Defines if webgl2 should be turned off even if supported
  94786. * @see http://doc.babylonjs.com/features/webgl2
  94787. */
  94788. disableWebGL2Support?: boolean;
  94789. /**
  94790. * Defines if webaudio should be initialized as well
  94791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94792. */
  94793. audioEngine?: boolean;
  94794. /**
  94795. * Defines if animations should run using a deterministic lock step
  94796. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94797. */
  94798. deterministicLockstep?: boolean;
  94799. /** Defines the maximum steps to use with deterministic lock step mode */
  94800. lockstepMaxSteps?: number;
  94801. /**
  94802. * Defines that engine should ignore context lost events
  94803. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94804. */
  94805. doNotHandleContextLost?: boolean;
  94806. /**
  94807. * Defines that engine should ignore modifying touch action attribute and style
  94808. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94809. */
  94810. doNotHandleTouchAction?: boolean;
  94811. /**
  94812. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94813. */
  94814. useHighPrecisionFloats?: boolean;
  94815. }
  94816. /**
  94817. * Defines the interface used by display changed events
  94818. */
  94819. export interface IDisplayChangedEventArgs {
  94820. /** Gets the vrDisplay object (if any) */
  94821. vrDisplay: Nullable<any>;
  94822. /** Gets a boolean indicating if webVR is supported */
  94823. vrSupported: boolean;
  94824. }
  94825. /**
  94826. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94827. */
  94828. export class Engine {
  94829. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94830. static ExceptionList: ({
  94831. key: string;
  94832. capture: string;
  94833. captureConstraint: number;
  94834. targets: string[];
  94835. } | {
  94836. key: string;
  94837. capture: null;
  94838. captureConstraint: null;
  94839. targets: string[];
  94840. })[];
  94841. /** Gets the list of created engines */
  94842. static readonly Instances: Engine[];
  94843. /**
  94844. * Gets the latest created engine
  94845. */
  94846. static readonly LastCreatedEngine: Nullable<Engine>;
  94847. /**
  94848. * Gets the latest created scene
  94849. */
  94850. static readonly LastCreatedScene: Nullable<Scene>;
  94851. /**
  94852. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94853. * @param flag defines which part of the materials must be marked as dirty
  94854. * @param predicate defines a predicate used to filter which materials should be affected
  94855. */
  94856. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94857. /** @hidden */
  94858. static _TextureLoaders: IInternalTextureLoader[];
  94859. /** Defines that alpha blending is disabled */
  94860. static readonly ALPHA_DISABLE: number;
  94861. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94862. static readonly ALPHA_ADD: number;
  94863. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94864. static readonly ALPHA_COMBINE: number;
  94865. /** Defines that alpha blending to DEST - SRC * DEST */
  94866. static readonly ALPHA_SUBTRACT: number;
  94867. /** Defines that alpha blending to SRC * DEST */
  94868. static readonly ALPHA_MULTIPLY: number;
  94869. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94870. static readonly ALPHA_MAXIMIZED: number;
  94871. /** Defines that alpha blending to SRC + DEST */
  94872. static readonly ALPHA_ONEONE: number;
  94873. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94874. static readonly ALPHA_PREMULTIPLIED: number;
  94875. /**
  94876. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94877. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94878. */
  94879. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94880. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94881. static readonly ALPHA_INTERPOLATE: number;
  94882. /**
  94883. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94884. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94885. */
  94886. static readonly ALPHA_SCREENMODE: number;
  94887. /** Defines that the ressource is not delayed*/
  94888. static readonly DELAYLOADSTATE_NONE: number;
  94889. /** Defines that the ressource was successfully delay loaded */
  94890. static readonly DELAYLOADSTATE_LOADED: number;
  94891. /** Defines that the ressource is currently delay loading */
  94892. static readonly DELAYLOADSTATE_LOADING: number;
  94893. /** Defines that the ressource is delayed and has not started loading */
  94894. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94896. static readonly NEVER: number;
  94897. /** 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 */
  94898. static readonly ALWAYS: number;
  94899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94900. static readonly LESS: number;
  94901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94902. static readonly EQUAL: number;
  94903. /** 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 */
  94904. static readonly LEQUAL: number;
  94905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94906. static readonly GREATER: number;
  94907. /** 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 */
  94908. static readonly GEQUAL: number;
  94909. /** 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 */
  94910. static readonly NOTEQUAL: number;
  94911. /** Passed to stencilOperation to specify that stencil value must be kept */
  94912. static readonly KEEP: number;
  94913. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94914. static readonly REPLACE: number;
  94915. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94916. static readonly INCR: number;
  94917. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94918. static readonly DECR: number;
  94919. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94920. static readonly INVERT: number;
  94921. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94922. static readonly INCR_WRAP: number;
  94923. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94924. static readonly DECR_WRAP: number;
  94925. /** Texture is not repeating outside of 0..1 UVs */
  94926. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94927. /** Texture is repeating outside of 0..1 UVs */
  94928. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94929. /** Texture is repeating and mirrored */
  94930. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94931. /** ALPHA */
  94932. static readonly TEXTUREFORMAT_ALPHA: number;
  94933. /** LUMINANCE */
  94934. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94935. /** LUMINANCE_ALPHA */
  94936. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94937. /** RGB */
  94938. static readonly TEXTUREFORMAT_RGB: number;
  94939. /** RGBA */
  94940. static readonly TEXTUREFORMAT_RGBA: number;
  94941. /** RED */
  94942. static readonly TEXTUREFORMAT_RED: number;
  94943. /** RED (2nd reference) */
  94944. static readonly TEXTUREFORMAT_R: number;
  94945. /** RG */
  94946. static readonly TEXTUREFORMAT_RG: number;
  94947. /** RED_INTEGER */
  94948. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94949. /** RED_INTEGER (2nd reference) */
  94950. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94951. /** RG_INTEGER */
  94952. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94953. /** RGB_INTEGER */
  94954. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94955. /** RGBA_INTEGER */
  94956. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94957. /** UNSIGNED_BYTE */
  94958. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94959. /** UNSIGNED_BYTE (2nd reference) */
  94960. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94961. /** FLOAT */
  94962. static readonly TEXTURETYPE_FLOAT: number;
  94963. /** HALF_FLOAT */
  94964. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94965. /** BYTE */
  94966. static readonly TEXTURETYPE_BYTE: number;
  94967. /** SHORT */
  94968. static readonly TEXTURETYPE_SHORT: number;
  94969. /** UNSIGNED_SHORT */
  94970. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94971. /** INT */
  94972. static readonly TEXTURETYPE_INT: number;
  94973. /** UNSIGNED_INT */
  94974. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94975. /** UNSIGNED_SHORT_4_4_4_4 */
  94976. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94977. /** UNSIGNED_SHORT_5_5_5_1 */
  94978. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94979. /** UNSIGNED_SHORT_5_6_5 */
  94980. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94981. /** UNSIGNED_INT_2_10_10_10_REV */
  94982. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94983. /** UNSIGNED_INT_24_8 */
  94984. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94985. /** UNSIGNED_INT_10F_11F_11F_REV */
  94986. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94987. /** UNSIGNED_INT_5_9_9_9_REV */
  94988. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94989. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94990. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94991. /** nearest is mag = nearest and min = nearest and mip = linear */
  94992. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94994. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94995. /** Trilinear is mag = linear and min = linear and mip = linear */
  94996. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94997. /** nearest is mag = nearest and min = nearest and mip = linear */
  94998. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95000. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95001. /** Trilinear is mag = linear and min = linear and mip = linear */
  95002. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95003. /** mag = nearest and min = nearest and mip = nearest */
  95004. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95005. /** mag = nearest and min = linear and mip = nearest */
  95006. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95007. /** mag = nearest and min = linear and mip = linear */
  95008. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95009. /** mag = nearest and min = linear and mip = none */
  95010. static readonly TEXTURE_NEAREST_LINEAR: number;
  95011. /** mag = nearest and min = nearest and mip = none */
  95012. static readonly TEXTURE_NEAREST_NEAREST: number;
  95013. /** mag = linear and min = nearest and mip = nearest */
  95014. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95015. /** mag = linear and min = nearest and mip = linear */
  95016. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95017. /** mag = linear and min = linear and mip = none */
  95018. static readonly TEXTURE_LINEAR_LINEAR: number;
  95019. /** mag = linear and min = nearest and mip = none */
  95020. static readonly TEXTURE_LINEAR_NEAREST: number;
  95021. /** Explicit coordinates mode */
  95022. static readonly TEXTURE_EXPLICIT_MODE: number;
  95023. /** Spherical coordinates mode */
  95024. static readonly TEXTURE_SPHERICAL_MODE: number;
  95025. /** Planar coordinates mode */
  95026. static readonly TEXTURE_PLANAR_MODE: number;
  95027. /** Cubic coordinates mode */
  95028. static readonly TEXTURE_CUBIC_MODE: number;
  95029. /** Projection coordinates mode */
  95030. static readonly TEXTURE_PROJECTION_MODE: number;
  95031. /** Skybox coordinates mode */
  95032. static readonly TEXTURE_SKYBOX_MODE: number;
  95033. /** Inverse Cubic coordinates mode */
  95034. static readonly TEXTURE_INVCUBIC_MODE: number;
  95035. /** Equirectangular coordinates mode */
  95036. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95037. /** Equirectangular Fixed coordinates mode */
  95038. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95039. /** Equirectangular Fixed Mirrored coordinates mode */
  95040. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95041. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95042. static readonly SCALEMODE_FLOOR: number;
  95043. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95044. static readonly SCALEMODE_NEAREST: number;
  95045. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95046. static readonly SCALEMODE_CEILING: number;
  95047. /**
  95048. * Returns the current npm package of the sdk
  95049. */
  95050. static readonly NpmPackage: string;
  95051. /**
  95052. * Returns the current version of the framework
  95053. */
  95054. static readonly Version: string;
  95055. /**
  95056. * Returns a string describing the current engine
  95057. */
  95058. readonly description: string;
  95059. /**
  95060. * Gets or sets the epsilon value used by collision engine
  95061. */
  95062. static CollisionsEpsilon: number;
  95063. /**
  95064. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95065. */
  95066. static ShadersRepository: string;
  95067. /**
  95068. * Method called to create the default loading screen.
  95069. * This can be overriden in your own app.
  95070. * @param canvas The rendering canvas element
  95071. * @returns The loading screen
  95072. */
  95073. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95074. /**
  95075. * Method called to create the default rescale post process on each engine.
  95076. */
  95077. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95078. /** @hidden */
  95079. _shaderProcessor: IShaderProcessor;
  95080. /**
  95081. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95082. */
  95083. forcePOTTextures: boolean;
  95084. /**
  95085. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95086. */
  95087. isFullscreen: boolean;
  95088. /**
  95089. * Gets a boolean indicating if the pointer is currently locked
  95090. */
  95091. isPointerLock: boolean;
  95092. /**
  95093. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95094. */
  95095. cullBackFaces: boolean;
  95096. /**
  95097. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95098. */
  95099. renderEvenInBackground: boolean;
  95100. /**
  95101. * Gets or sets a boolean indicating that cache can be kept between frames
  95102. */
  95103. preventCacheWipeBetweenFrames: boolean;
  95104. /**
  95105. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95106. **/
  95107. enableOfflineSupport: boolean;
  95108. /**
  95109. * 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)
  95110. **/
  95111. disableManifestCheck: boolean;
  95112. /**
  95113. * Gets the list of created scenes
  95114. */
  95115. scenes: Scene[];
  95116. /**
  95117. * Event raised when a new scene is created
  95118. */
  95119. onNewSceneAddedObservable: Observable<Scene>;
  95120. /**
  95121. * Gets the list of created postprocesses
  95122. */
  95123. postProcesses: PostProcess[];
  95124. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95125. validateShaderPrograms: boolean;
  95126. /**
  95127. * Observable event triggered each time the rendering canvas is resized
  95128. */
  95129. onResizeObservable: Observable<Engine>;
  95130. /**
  95131. * Observable event triggered each time the canvas loses focus
  95132. */
  95133. onCanvasBlurObservable: Observable<Engine>;
  95134. /**
  95135. * Observable event triggered each time the canvas gains focus
  95136. */
  95137. onCanvasFocusObservable: Observable<Engine>;
  95138. /**
  95139. * Observable event triggered each time the canvas receives pointerout event
  95140. */
  95141. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95142. /**
  95143. * Observable event triggered before each texture is initialized
  95144. */
  95145. onBeforeTextureInitObservable: Observable<Texture>;
  95146. /**
  95147. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95148. */
  95149. disableUniformBuffers: boolean;
  95150. /** @hidden */
  95151. _uniformBuffers: UniformBuffer[];
  95152. /**
  95153. * Gets a boolean indicating that the engine supports uniform buffers
  95154. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95155. */
  95156. readonly supportsUniformBuffers: boolean;
  95157. /**
  95158. * Observable raised when the engine begins a new frame
  95159. */
  95160. onBeginFrameObservable: Observable<Engine>;
  95161. /**
  95162. * If set, will be used to request the next animation frame for the render loop
  95163. */
  95164. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95165. /**
  95166. * Observable raised when the engine ends the current frame
  95167. */
  95168. onEndFrameObservable: Observable<Engine>;
  95169. /**
  95170. * Observable raised when the engine is about to compile a shader
  95171. */
  95172. onBeforeShaderCompilationObservable: Observable<Engine>;
  95173. /**
  95174. * Observable raised when the engine has jsut compiled a shader
  95175. */
  95176. onAfterShaderCompilationObservable: Observable<Engine>;
  95177. /** @hidden */
  95178. _gl: WebGLRenderingContext;
  95179. private _renderingCanvas;
  95180. private _windowIsBackground;
  95181. private _webGLVersion;
  95182. protected _highPrecisionShadersAllowed: boolean;
  95183. /** @hidden */
  95184. readonly _shouldUseHighPrecisionShader: boolean;
  95185. /**
  95186. * Gets a boolean indicating that only power of 2 textures are supported
  95187. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95188. */
  95189. readonly needPOTTextures: boolean;
  95190. /** @hidden */
  95191. _badOS: boolean;
  95192. /** @hidden */
  95193. _badDesktopOS: boolean;
  95194. /**
  95195. * Gets the audio engine
  95196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95197. * @ignorenaming
  95198. */
  95199. static audioEngine: IAudioEngine;
  95200. /**
  95201. * Default AudioEngine factory responsible of creating the Audio Engine.
  95202. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95203. */
  95204. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95205. /**
  95206. * Default offline support factory responsible of creating a tool used to store data locally.
  95207. * By default, this will create a Database object if the workload has been embedded.
  95208. */
  95209. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95210. private _onFocus;
  95211. private _onBlur;
  95212. private _onCanvasPointerOut;
  95213. private _onCanvasBlur;
  95214. private _onCanvasFocus;
  95215. private _onFullscreenChange;
  95216. private _onPointerLockChange;
  95217. private _hardwareScalingLevel;
  95218. /** @hidden */
  95219. _caps: EngineCapabilities;
  95220. private _pointerLockRequested;
  95221. private _isStencilEnable;
  95222. private _colorWrite;
  95223. private _loadingScreen;
  95224. /** @hidden */
  95225. _drawCalls: PerfCounter;
  95226. private _glVersion;
  95227. private _glRenderer;
  95228. private _glVendor;
  95229. private _videoTextureSupported;
  95230. private _renderingQueueLaunched;
  95231. private _activeRenderLoops;
  95232. private _deterministicLockstep;
  95233. private _lockstepMaxSteps;
  95234. /**
  95235. * Observable signaled when a context lost event is raised
  95236. */
  95237. onContextLostObservable: Observable<Engine>;
  95238. /**
  95239. * Observable signaled when a context restored event is raised
  95240. */
  95241. onContextRestoredObservable: Observable<Engine>;
  95242. private _onContextLost;
  95243. private _onContextRestored;
  95244. private _contextWasLost;
  95245. /** @hidden */
  95246. _doNotHandleContextLost: boolean;
  95247. /**
  95248. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95250. */
  95251. doNotHandleContextLost: boolean;
  95252. private _performanceMonitor;
  95253. private _fps;
  95254. private _deltaTime;
  95255. /**
  95256. * Turn this value on if you want to pause FPS computation when in background
  95257. */
  95258. disablePerformanceMonitorInBackground: boolean;
  95259. /**
  95260. * Gets the performance monitor attached to this engine
  95261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95262. */
  95263. readonly performanceMonitor: PerformanceMonitor;
  95264. /**
  95265. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95266. */
  95267. disableVertexArrayObjects: boolean;
  95268. /** @hidden */
  95269. protected _depthCullingState: _DepthCullingState;
  95270. /** @hidden */
  95271. protected _stencilState: _StencilState;
  95272. /** @hidden */
  95273. protected _alphaState: _AlphaState;
  95274. /** @hidden */
  95275. protected _alphaMode: number;
  95276. /** @hidden */
  95277. _internalTexturesCache: InternalTexture[];
  95278. /** @hidden */
  95279. protected _activeChannel: number;
  95280. private _currentTextureChannel;
  95281. /** @hidden */
  95282. protected _boundTexturesCache: {
  95283. [key: string]: Nullable<InternalTexture>;
  95284. };
  95285. /** @hidden */
  95286. protected _currentEffect: Nullable<Effect>;
  95287. /** @hidden */
  95288. protected _currentProgram: Nullable<WebGLProgram>;
  95289. private _compiledEffects;
  95290. private _vertexAttribArraysEnabled;
  95291. /** @hidden */
  95292. protected _cachedViewport: Nullable<IViewportLike>;
  95293. private _cachedVertexArrayObject;
  95294. /** @hidden */
  95295. protected _cachedVertexBuffers: any;
  95296. /** @hidden */
  95297. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95298. /** @hidden */
  95299. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95300. /** @hidden */
  95301. _currentRenderTarget: Nullable<InternalTexture>;
  95302. private _uintIndicesCurrentlySet;
  95303. private _currentBoundBuffer;
  95304. /** @hidden */
  95305. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95306. private _currentBufferPointers;
  95307. private _currentInstanceLocations;
  95308. private _currentInstanceBuffers;
  95309. private _textureUnits;
  95310. /** @hidden */
  95311. _workingCanvas: Nullable<HTMLCanvasElement>;
  95312. /** @hidden */
  95313. _workingContext: Nullable<CanvasRenderingContext2D>;
  95314. private _rescalePostProcess;
  95315. private _dummyFramebuffer;
  95316. private _externalData;
  95317. /** @hidden */
  95318. _bindedRenderFunction: any;
  95319. private _vaoRecordInProgress;
  95320. private _mustWipeVertexAttributes;
  95321. private _emptyTexture;
  95322. private _emptyCubeTexture;
  95323. private _emptyTexture3D;
  95324. /** @hidden */
  95325. _frameHandler: number;
  95326. private _nextFreeTextureSlots;
  95327. private _maxSimultaneousTextures;
  95328. private _activeRequests;
  95329. private _texturesSupported;
  95330. /** @hidden */
  95331. _textureFormatInUse: Nullable<string>;
  95332. /**
  95333. * Gets the list of texture formats supported
  95334. */
  95335. readonly texturesSupported: Array<string>;
  95336. /**
  95337. * Gets the list of texture formats in use
  95338. */
  95339. readonly textureFormatInUse: Nullable<string>;
  95340. /**
  95341. * Gets the current viewport
  95342. */
  95343. readonly currentViewport: Nullable<IViewportLike>;
  95344. /**
  95345. * Gets the default empty texture
  95346. */
  95347. readonly emptyTexture: InternalTexture;
  95348. /**
  95349. * Gets the default empty 3D texture
  95350. */
  95351. readonly emptyTexture3D: InternalTexture;
  95352. /**
  95353. * Gets the default empty cube texture
  95354. */
  95355. readonly emptyCubeTexture: InternalTexture;
  95356. /**
  95357. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95358. */
  95359. readonly premultipliedAlpha: boolean;
  95360. /**
  95361. * Creates a new engine
  95362. * @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
  95363. * @param antialias defines enable antialiasing (default: false)
  95364. * @param options defines further options to be sent to the getContext() function
  95365. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95366. */
  95367. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95368. /**
  95369. * Initializes a webVR display and starts listening to display change events
  95370. * The onVRDisplayChangedObservable will be notified upon these changes
  95371. * @returns The onVRDisplayChangedObservable
  95372. */
  95373. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95374. /** @hidden */
  95375. _prepareVRComponent(): void;
  95376. /** @hidden */
  95377. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95378. /** @hidden */
  95379. _submitVRFrame(): void;
  95380. /**
  95381. * Call this function to leave webVR mode
  95382. * Will do nothing if webVR is not supported or if there is no webVR device
  95383. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95384. */
  95385. disableVR(): void;
  95386. /**
  95387. * Gets a boolean indicating that the system is in VR mode and is presenting
  95388. * @returns true if VR mode is engaged
  95389. */
  95390. isVRPresenting(): boolean;
  95391. /** @hidden */
  95392. _requestVRFrame(): void;
  95393. private _disableTouchAction;
  95394. private _rebuildInternalTextures;
  95395. private _rebuildEffects;
  95396. /**
  95397. * Gets a boolean indicating if all created effects are ready
  95398. * @returns true if all effects are ready
  95399. */
  95400. areAllEffectsReady(): boolean;
  95401. private _rebuildBuffers;
  95402. private _initGLContext;
  95403. /**
  95404. * Gets version of the current webGL context
  95405. */
  95406. readonly webGLVersion: number;
  95407. /**
  95408. * Gets a string idenfifying the name of the class
  95409. * @returns "Engine" string
  95410. */
  95411. getClassName(): string;
  95412. /**
  95413. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95414. */
  95415. readonly isStencilEnable: boolean;
  95416. /** @hidden */
  95417. _prepareWorkingCanvas(): void;
  95418. /**
  95419. * Reset the texture cache to empty state
  95420. */
  95421. resetTextureCache(): void;
  95422. /**
  95423. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95425. * @returns true if engine is in deterministic lock step mode
  95426. */
  95427. isDeterministicLockStep(): boolean;
  95428. /**
  95429. * Gets the max steps when engine is running in deterministic lock step
  95430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95431. * @returns the max steps
  95432. */
  95433. getLockstepMaxSteps(): number;
  95434. /**
  95435. * Gets an object containing information about the current webGL context
  95436. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95437. */
  95438. getGlInfo(): {
  95439. vendor: string;
  95440. renderer: string;
  95441. version: string;
  95442. };
  95443. /**
  95444. * Gets current aspect ratio
  95445. * @param viewportOwner defines the camera to use to get the aspect ratio
  95446. * @param useScreen defines if screen size must be used (or the current render target if any)
  95447. * @returns a number defining the aspect ratio
  95448. */
  95449. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95450. /**
  95451. * Gets current screen aspect ratio
  95452. * @returns a number defining the aspect ratio
  95453. */
  95454. getScreenAspectRatio(): number;
  95455. /**
  95456. * Gets the current render width
  95457. * @param useScreen defines if screen size must be used (or the current render target if any)
  95458. * @returns a number defining the current render width
  95459. */
  95460. getRenderWidth(useScreen?: boolean): number;
  95461. /**
  95462. * Gets the current render height
  95463. * @param useScreen defines if screen size must be used (or the current render target if any)
  95464. * @returns a number defining the current render height
  95465. */
  95466. getRenderHeight(useScreen?: boolean): number;
  95467. /**
  95468. * Gets the HTML canvas attached with the current webGL context
  95469. * @returns a HTML canvas
  95470. */
  95471. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95472. /**
  95473. * Gets host window
  95474. * @returns the host window object
  95475. */
  95476. getHostWindow(): Window;
  95477. /**
  95478. * Gets host document
  95479. * @returns the host document object
  95480. */
  95481. getHostDocument(): Document;
  95482. /**
  95483. * Gets the client rect of the HTML canvas attached with the current webGL context
  95484. * @returns a client rectanglee
  95485. */
  95486. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95487. /**
  95488. * Defines the hardware scaling level.
  95489. * By default the hardware scaling level is computed from the window device ratio.
  95490. * 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.
  95491. * @param level defines the level to use
  95492. */
  95493. setHardwareScalingLevel(level: number): void;
  95494. /**
  95495. * Gets the current hardware scaling level.
  95496. * By default the hardware scaling level is computed from the window device ratio.
  95497. * 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.
  95498. * @returns a number indicating the current hardware scaling level
  95499. */
  95500. getHardwareScalingLevel(): number;
  95501. /**
  95502. * Gets the list of loaded textures
  95503. * @returns an array containing all loaded textures
  95504. */
  95505. getLoadedTexturesCache(): InternalTexture[];
  95506. /**
  95507. * Gets the object containing all engine capabilities
  95508. * @returns the EngineCapabilities object
  95509. */
  95510. getCaps(): EngineCapabilities;
  95511. /**
  95512. * Gets the current depth function
  95513. * @returns a number defining the depth function
  95514. */
  95515. getDepthFunction(): Nullable<number>;
  95516. /**
  95517. * Sets the current depth function
  95518. * @param depthFunc defines the function to use
  95519. */
  95520. setDepthFunction(depthFunc: number): void;
  95521. /**
  95522. * Sets the current depth function to GREATER
  95523. */
  95524. setDepthFunctionToGreater(): void;
  95525. /**
  95526. * Sets the current depth function to GEQUAL
  95527. */
  95528. setDepthFunctionToGreaterOrEqual(): void;
  95529. /**
  95530. * Sets the current depth function to LESS
  95531. */
  95532. setDepthFunctionToLess(): void;
  95533. private _cachedStencilBuffer;
  95534. private _cachedStencilFunction;
  95535. private _cachedStencilMask;
  95536. private _cachedStencilOperationPass;
  95537. private _cachedStencilOperationFail;
  95538. private _cachedStencilOperationDepthFail;
  95539. private _cachedStencilReference;
  95540. /**
  95541. * Caches the the state of the stencil buffer
  95542. */
  95543. cacheStencilState(): void;
  95544. /**
  95545. * Restores the state of the stencil buffer
  95546. */
  95547. restoreStencilState(): void;
  95548. /**
  95549. * Sets the current depth function to LEQUAL
  95550. */
  95551. setDepthFunctionToLessOrEqual(): void;
  95552. /**
  95553. * Gets a boolean indicating if stencil buffer is enabled
  95554. * @returns the current stencil buffer state
  95555. */
  95556. getStencilBuffer(): boolean;
  95557. /**
  95558. * Enable or disable the stencil buffer
  95559. * @param enable defines if the stencil buffer must be enabled or disabled
  95560. */
  95561. setStencilBuffer(enable: boolean): void;
  95562. /**
  95563. * Gets the current stencil mask
  95564. * @returns a number defining the new stencil mask to use
  95565. */
  95566. getStencilMask(): number;
  95567. /**
  95568. * Sets the current stencil mask
  95569. * @param mask defines the new stencil mask to use
  95570. */
  95571. setStencilMask(mask: number): void;
  95572. /**
  95573. * Gets the current stencil function
  95574. * @returns a number defining the stencil function to use
  95575. */
  95576. getStencilFunction(): number;
  95577. /**
  95578. * Gets the current stencil reference value
  95579. * @returns a number defining the stencil reference value to use
  95580. */
  95581. getStencilFunctionReference(): number;
  95582. /**
  95583. * Gets the current stencil mask
  95584. * @returns a number defining the stencil mask to use
  95585. */
  95586. getStencilFunctionMask(): number;
  95587. /**
  95588. * Sets the current stencil function
  95589. * @param stencilFunc defines the new stencil function to use
  95590. */
  95591. setStencilFunction(stencilFunc: number): void;
  95592. /**
  95593. * Sets the current stencil reference
  95594. * @param reference defines the new stencil reference to use
  95595. */
  95596. setStencilFunctionReference(reference: number): void;
  95597. /**
  95598. * Sets the current stencil mask
  95599. * @param mask defines the new stencil mask to use
  95600. */
  95601. setStencilFunctionMask(mask: number): void;
  95602. /**
  95603. * Gets the current stencil operation when stencil fails
  95604. * @returns a number defining stencil operation to use when stencil fails
  95605. */
  95606. getStencilOperationFail(): number;
  95607. /**
  95608. * Gets the current stencil operation when depth fails
  95609. * @returns a number defining stencil operation to use when depth fails
  95610. */
  95611. getStencilOperationDepthFail(): number;
  95612. /**
  95613. * Gets the current stencil operation when stencil passes
  95614. * @returns a number defining stencil operation to use when stencil passes
  95615. */
  95616. getStencilOperationPass(): number;
  95617. /**
  95618. * Sets the stencil operation to use when stencil fails
  95619. * @param operation defines the stencil operation to use when stencil fails
  95620. */
  95621. setStencilOperationFail(operation: number): void;
  95622. /**
  95623. * Sets the stencil operation to use when depth fails
  95624. * @param operation defines the stencil operation to use when depth fails
  95625. */
  95626. setStencilOperationDepthFail(operation: number): void;
  95627. /**
  95628. * Sets the stencil operation to use when stencil passes
  95629. * @param operation defines the stencil operation to use when stencil passes
  95630. */
  95631. setStencilOperationPass(operation: number): void;
  95632. /**
  95633. * Sets a boolean indicating if the dithering state is enabled or disabled
  95634. * @param value defines the dithering state
  95635. */
  95636. setDitheringState(value: boolean): void;
  95637. /**
  95638. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95639. * @param value defines the rasterizer state
  95640. */
  95641. setRasterizerState(value: boolean): void;
  95642. /**
  95643. * stop executing a render loop function and remove it from the execution array
  95644. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95645. */
  95646. stopRenderLoop(renderFunction?: () => void): void;
  95647. /** @hidden */
  95648. _renderLoop(): void;
  95649. /**
  95650. * Register and execute a render loop. The engine can have more than one render function
  95651. * @param renderFunction defines the function to continuously execute
  95652. */
  95653. runRenderLoop(renderFunction: () => void): void;
  95654. /**
  95655. * Toggle full screen mode
  95656. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95657. */
  95658. switchFullscreen(requestPointerLock: boolean): void;
  95659. /**
  95660. * Enters full screen mode
  95661. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95662. */
  95663. enterFullscreen(requestPointerLock: boolean): void;
  95664. /**
  95665. * Exits full screen mode
  95666. */
  95667. exitFullscreen(): void;
  95668. /**
  95669. * Enters Pointerlock mode
  95670. */
  95671. enterPointerlock(): void;
  95672. /**
  95673. * Exits Pointerlock mode
  95674. */
  95675. exitPointerlock(): void;
  95676. /**
  95677. * Clear the current render buffer or the current render target (if any is set up)
  95678. * @param color defines the color to use
  95679. * @param backBuffer defines if the back buffer must be cleared
  95680. * @param depth defines if the depth buffer must be cleared
  95681. * @param stencil defines if the stencil buffer must be cleared
  95682. */
  95683. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95684. /**
  95685. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95686. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95687. * @param y defines the y-coordinate of the corner of the clear rectangle
  95688. * @param width defines the width of the clear rectangle
  95689. * @param height defines the height of the clear rectangle
  95690. * @param clearColor defines the clear color
  95691. */
  95692. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95693. /**
  95694. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95695. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95696. * @param y defines the y-coordinate of the corner of the clear rectangle
  95697. * @param width defines the width of the clear rectangle
  95698. * @param height defines the height of the clear rectangle
  95699. */
  95700. enableScissor(x: number, y: number, width: number, height: number): void;
  95701. /**
  95702. * Disable previously set scissor test rectangle
  95703. */
  95704. disableScissor(): void;
  95705. private _viewportCached;
  95706. /** @hidden */
  95707. _viewport(x: number, y: number, width: number, height: number): void;
  95708. /**
  95709. * Set the WebGL's viewport
  95710. * @param viewport defines the viewport element to be used
  95711. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95712. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95713. */
  95714. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95715. /**
  95716. * Directly set the WebGL Viewport
  95717. * @param x defines the x coordinate of the viewport (in screen space)
  95718. * @param y defines the y coordinate of the viewport (in screen space)
  95719. * @param width defines the width of the viewport (in screen space)
  95720. * @param height defines the height of the viewport (in screen space)
  95721. * @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
  95722. */
  95723. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95724. /**
  95725. * Begin a new frame
  95726. */
  95727. beginFrame(): void;
  95728. /**
  95729. * Enf the current frame
  95730. */
  95731. endFrame(): void;
  95732. /**
  95733. * Resize the view according to the canvas' size
  95734. */
  95735. resize(): void;
  95736. /**
  95737. * Force a specific size of the canvas
  95738. * @param width defines the new canvas' width
  95739. * @param height defines the new canvas' height
  95740. */
  95741. setSize(width: number, height: number): void;
  95742. /**
  95743. * Binds the frame buffer to the specified texture.
  95744. * @param texture The texture to render to or null for the default canvas
  95745. * @param faceIndex The face of the texture to render to in case of cube texture
  95746. * @param requiredWidth The width of the target to render to
  95747. * @param requiredHeight The height of the target to render to
  95748. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95749. * @param depthStencilTexture The depth stencil texture to use to render
  95750. * @param lodLevel defines le lod level to bind to the frame buffer
  95751. */
  95752. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95753. /** @hidden */
  95754. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95755. /**
  95756. * Unbind the current render target texture from the webGL context
  95757. * @param texture defines the render target texture to unbind
  95758. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95759. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95760. */
  95761. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95762. /**
  95763. * Force the mipmap generation for the given render target texture
  95764. * @param texture defines the render target texture to use
  95765. */
  95766. generateMipMapsForCubemap(texture: InternalTexture): void;
  95767. /**
  95768. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95769. */
  95770. flushFramebuffer(): void;
  95771. /**
  95772. * Unbind the current render target and bind the default framebuffer
  95773. */
  95774. restoreDefaultFramebuffer(): void;
  95775. /**
  95776. * Create an uniform buffer
  95777. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95778. * @param elements defines the content of the uniform buffer
  95779. * @returns the webGL uniform buffer
  95780. */
  95781. createUniformBuffer(elements: FloatArray): DataBuffer;
  95782. /**
  95783. * Create a dynamic uniform buffer
  95784. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95785. * @param elements defines the content of the uniform buffer
  95786. * @returns the webGL uniform buffer
  95787. */
  95788. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95789. /**
  95790. * Update an existing uniform buffer
  95791. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95792. * @param uniformBuffer defines the target uniform buffer
  95793. * @param elements defines the content to update
  95794. * @param offset defines the offset in the uniform buffer where update should start
  95795. * @param count defines the size of the data to update
  95796. */
  95797. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95798. private _resetVertexBufferBinding;
  95799. /**
  95800. * Creates a vertex buffer
  95801. * @param data the data for the vertex buffer
  95802. * @returns the new WebGL static buffer
  95803. */
  95804. createVertexBuffer(data: DataArray): DataBuffer;
  95805. /**
  95806. * Creates a dynamic vertex buffer
  95807. * @param data the data for the dynamic vertex buffer
  95808. * @returns the new WebGL dynamic buffer
  95809. */
  95810. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95811. /**
  95812. * Update a dynamic index buffer
  95813. * @param indexBuffer defines the target index buffer
  95814. * @param indices defines the data to update
  95815. * @param offset defines the offset in the target index buffer where update should start
  95816. */
  95817. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95818. /**
  95819. * Updates a dynamic vertex buffer.
  95820. * @param vertexBuffer the vertex buffer to update
  95821. * @param data the data used to update the vertex buffer
  95822. * @param byteOffset the byte offset of the data
  95823. * @param byteLength the byte length of the data
  95824. */
  95825. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95826. private _resetIndexBufferBinding;
  95827. /**
  95828. * Creates a new index buffer
  95829. * @param indices defines the content of the index buffer
  95830. * @param updatable defines if the index buffer must be updatable
  95831. * @returns a new webGL buffer
  95832. */
  95833. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95834. /**
  95835. * Bind a webGL buffer to the webGL context
  95836. * @param buffer defines the buffer to bind
  95837. */
  95838. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95839. /**
  95840. * Bind an uniform buffer to the current webGL context
  95841. * @param buffer defines the buffer to bind
  95842. */
  95843. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95844. /**
  95845. * Bind a buffer to the current webGL context at a given location
  95846. * @param buffer defines the buffer to bind
  95847. * @param location defines the index where to bind the buffer
  95848. */
  95849. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95850. /**
  95851. * Bind a specific block at a given index in a specific shader program
  95852. * @param pipelineContext defines the pipeline context to use
  95853. * @param blockName defines the block name
  95854. * @param index defines the index where to bind the block
  95855. */
  95856. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95857. private bindIndexBuffer;
  95858. private bindBuffer;
  95859. /**
  95860. * update the bound buffer with the given data
  95861. * @param data defines the data to update
  95862. */
  95863. updateArrayBuffer(data: Float32Array): void;
  95864. private _vertexAttribPointer;
  95865. private _bindIndexBufferWithCache;
  95866. private _bindVertexBuffersAttributes;
  95867. /**
  95868. * Records a vertex array object
  95869. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95870. * @param vertexBuffers defines the list of vertex buffers to store
  95871. * @param indexBuffer defines the index buffer to store
  95872. * @param effect defines the effect to store
  95873. * @returns the new vertex array object
  95874. */
  95875. recordVertexArrayObject(vertexBuffers: {
  95876. [key: string]: VertexBuffer;
  95877. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95878. /**
  95879. * Bind a specific vertex array object
  95880. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95881. * @param vertexArrayObject defines the vertex array object to bind
  95882. * @param indexBuffer defines the index buffer to bind
  95883. */
  95884. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95885. /**
  95886. * Bind webGl buffers directly to the webGL context
  95887. * @param vertexBuffer defines the vertex buffer to bind
  95888. * @param indexBuffer defines the index buffer to bind
  95889. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95890. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95891. * @param effect defines the effect associated with the vertex buffer
  95892. */
  95893. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95894. private _unbindVertexArrayObject;
  95895. /**
  95896. * Bind a list of vertex buffers to the webGL context
  95897. * @param vertexBuffers defines the list of vertex buffers to bind
  95898. * @param indexBuffer defines the index buffer to bind
  95899. * @param effect defines the effect associated with the vertex buffers
  95900. */
  95901. bindBuffers(vertexBuffers: {
  95902. [key: string]: Nullable<VertexBuffer>;
  95903. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95904. /**
  95905. * Unbind all instance attributes
  95906. */
  95907. unbindInstanceAttributes(): void;
  95908. /**
  95909. * Release and free the memory of a vertex array object
  95910. * @param vao defines the vertex array object to delete
  95911. */
  95912. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95913. /** @hidden */
  95914. _releaseBuffer(buffer: DataBuffer): boolean;
  95915. /**
  95916. * Creates a webGL buffer to use with instanciation
  95917. * @param capacity defines the size of the buffer
  95918. * @returns the webGL buffer
  95919. */
  95920. createInstancesBuffer(capacity: number): DataBuffer;
  95921. /**
  95922. * Delete a webGL buffer used with instanciation
  95923. * @param buffer defines the webGL buffer to delete
  95924. */
  95925. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95926. /**
  95927. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95928. * @param instancesBuffer defines the webGL buffer to update and bind
  95929. * @param data defines the data to store in the buffer
  95930. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95931. */
  95932. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95933. /**
  95934. * Apply all cached states (depth, culling, stencil and alpha)
  95935. */
  95936. applyStates(): void;
  95937. /**
  95938. * Send a draw order
  95939. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95940. * @param indexStart defines the starting index
  95941. * @param indexCount defines the number of index to draw
  95942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95943. */
  95944. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95945. /**
  95946. * Draw a list of points
  95947. * @param verticesStart defines the index of first vertex to draw
  95948. * @param verticesCount defines the count of vertices to draw
  95949. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95950. */
  95951. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95952. /**
  95953. * Draw a list of unindexed primitives
  95954. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95955. * @param verticesStart defines the index of first vertex to draw
  95956. * @param verticesCount defines the count of vertices to draw
  95957. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95958. */
  95959. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95960. /**
  95961. * Draw a list of indexed primitives
  95962. * @param fillMode defines the primitive to use
  95963. * @param indexStart defines the starting index
  95964. * @param indexCount defines the number of index to draw
  95965. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95966. */
  95967. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95968. /**
  95969. * Draw a list of unindexed primitives
  95970. * @param fillMode defines the primitive to use
  95971. * @param verticesStart defines the index of first vertex to draw
  95972. * @param verticesCount defines the count of vertices to draw
  95973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95974. */
  95975. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95976. private _drawMode;
  95977. /** @hidden */
  95978. _releaseEffect(effect: Effect): void;
  95979. /** @hidden */
  95980. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95981. /**
  95982. * Create a new effect (used to store vertex/fragment shaders)
  95983. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95984. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95985. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95986. * @param samplers defines an array of string used to represent textures
  95987. * @param defines defines the string containing the defines to use to compile the shaders
  95988. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95989. * @param onCompiled defines a function to call when the effect creation is successful
  95990. * @param onError defines a function to call when the effect creation has failed
  95991. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95992. * @returns the new Effect
  95993. */
  95994. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  95995. private _compileShader;
  95996. private _compileRawShader;
  95997. /**
  95998. * Directly creates a webGL program
  95999. * @param pipelineContext defines the pipeline context to attach to
  96000. * @param vertexCode defines the vertex shader code to use
  96001. * @param fragmentCode defines the fragment shader code to use
  96002. * @param context defines the webGL context to use (if not set, the current one will be used)
  96003. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96004. * @returns the new webGL program
  96005. */
  96006. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96007. /**
  96008. * Creates a webGL program
  96009. * @param pipelineContext defines the pipeline context to attach to
  96010. * @param vertexCode defines the vertex shader code to use
  96011. * @param fragmentCode defines the fragment shader code to use
  96012. * @param defines defines the string containing the defines to use to compile the shaders
  96013. * @param context defines the webGL context to use (if not set, the current one will be used)
  96014. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96015. * @returns the new webGL program
  96016. */
  96017. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96018. /**
  96019. * Creates a new pipeline context
  96020. * @returns the new pipeline
  96021. */
  96022. createPipelineContext(): WebGLPipelineContext;
  96023. private _createShaderProgram;
  96024. private _finalizePipelineContext;
  96025. /** @hidden */
  96026. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96027. /** @hidden */
  96028. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96029. /** @hidden */
  96030. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96031. /**
  96032. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96033. * @param pipelineContext defines the pipeline context to use
  96034. * @param uniformsNames defines the list of uniform names
  96035. * @returns an array of webGL uniform locations
  96036. */
  96037. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96038. /**
  96039. * Gets the lsit of active attributes for a given webGL program
  96040. * @param pipelineContext defines the pipeline context to use
  96041. * @param attributesNames defines the list of attribute names to get
  96042. * @returns an array of indices indicating the offset of each attribute
  96043. */
  96044. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96045. /**
  96046. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96047. * @param effect defines the effect to activate
  96048. */
  96049. enableEffect(effect: Nullable<Effect>): void;
  96050. /**
  96051. * Set the value of an uniform to an array of int32
  96052. * @param uniform defines the webGL uniform location where to store the value
  96053. * @param array defines the array of int32 to store
  96054. */
  96055. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96056. /**
  96057. * Set the value of an uniform to an array of int32 (stored as vec2)
  96058. * @param uniform defines the webGL uniform location where to store the value
  96059. * @param array defines the array of int32 to store
  96060. */
  96061. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96062. /**
  96063. * Set the value of an uniform to an array of int32 (stored as vec3)
  96064. * @param uniform defines the webGL uniform location where to store the value
  96065. * @param array defines the array of int32 to store
  96066. */
  96067. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96068. /**
  96069. * Set the value of an uniform to an array of int32 (stored as vec4)
  96070. * @param uniform defines the webGL uniform location where to store the value
  96071. * @param array defines the array of int32 to store
  96072. */
  96073. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96074. /**
  96075. * Set the value of an uniform to an array of float32
  96076. * @param uniform defines the webGL uniform location where to store the value
  96077. * @param array defines the array of float32 to store
  96078. */
  96079. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96080. /**
  96081. * Set the value of an uniform to an array of float32 (stored as vec2)
  96082. * @param uniform defines the webGL uniform location where to store the value
  96083. * @param array defines the array of float32 to store
  96084. */
  96085. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96086. /**
  96087. * Set the value of an uniform to an array of float32 (stored as vec3)
  96088. * @param uniform defines the webGL uniform location where to store the value
  96089. * @param array defines the array of float32 to store
  96090. */
  96091. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96092. /**
  96093. * Set the value of an uniform to an array of float32 (stored as vec4)
  96094. * @param uniform defines the webGL uniform location where to store the value
  96095. * @param array defines the array of float32 to store
  96096. */
  96097. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96098. /**
  96099. * Set the value of an uniform to an array of number
  96100. * @param uniform defines the webGL uniform location where to store the value
  96101. * @param array defines the array of number to store
  96102. */
  96103. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96104. /**
  96105. * Set the value of an uniform to an array of number (stored as vec2)
  96106. * @param uniform defines the webGL uniform location where to store the value
  96107. * @param array defines the array of number to store
  96108. */
  96109. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96110. /**
  96111. * Set the value of an uniform to an array of number (stored as vec3)
  96112. * @param uniform defines the webGL uniform location where to store the value
  96113. * @param array defines the array of number to store
  96114. */
  96115. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96116. /**
  96117. * Set the value of an uniform to an array of number (stored as vec4)
  96118. * @param uniform defines the webGL uniform location where to store the value
  96119. * @param array defines the array of number to store
  96120. */
  96121. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96122. /**
  96123. * Set the value of an uniform to an array of float32 (stored as matrices)
  96124. * @param uniform defines the webGL uniform location where to store the value
  96125. * @param matrices defines the array of float32 to store
  96126. */
  96127. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96128. /**
  96129. * Set the value of an uniform to a matrix (3x3)
  96130. * @param uniform defines the webGL uniform location where to store the value
  96131. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96132. */
  96133. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96134. /**
  96135. * Set the value of an uniform to a matrix (2x2)
  96136. * @param uniform defines the webGL uniform location where to store the value
  96137. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96138. */
  96139. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96140. /**
  96141. * Set the value of an uniform to a number (int)
  96142. * @param uniform defines the webGL uniform location where to store the value
  96143. * @param value defines the int number to store
  96144. */
  96145. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96146. /**
  96147. * Set the value of an uniform to a number (float)
  96148. * @param uniform defines the webGL uniform location where to store the value
  96149. * @param value defines the float number to store
  96150. */
  96151. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96152. /**
  96153. * Set the value of an uniform to a vec2
  96154. * @param uniform defines the webGL uniform location where to store the value
  96155. * @param x defines the 1st component of the value
  96156. * @param y defines the 2nd component of the value
  96157. */
  96158. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96159. /**
  96160. * Set the value of an uniform to a vec3
  96161. * @param uniform defines the webGL uniform location where to store the value
  96162. * @param x defines the 1st component of the value
  96163. * @param y defines the 2nd component of the value
  96164. * @param z defines the 3rd component of the value
  96165. */
  96166. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96167. /**
  96168. * Set the value of an uniform to a boolean
  96169. * @param uniform defines the webGL uniform location where to store the value
  96170. * @param bool defines the boolean to store
  96171. */
  96172. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96173. /**
  96174. * Set the value of an uniform to a vec4
  96175. * @param uniform defines the webGL uniform location where to store the value
  96176. * @param x defines the 1st component of the value
  96177. * @param y defines the 2nd component of the value
  96178. * @param z defines the 3rd component of the value
  96179. * @param w defines the 4th component of the value
  96180. */
  96181. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96182. /**
  96183. * Sets a Color4 on a uniform variable
  96184. * @param uniform defines the uniform location
  96185. * @param color4 defines the value to be set
  96186. */
  96187. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96188. /**
  96189. * Set various states to the webGL context
  96190. * @param culling defines backface culling state
  96191. * @param zOffset defines the value to apply to zOffset (0 by default)
  96192. * @param force defines if states must be applied even if cache is up to date
  96193. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96194. */
  96195. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96196. /**
  96197. * Set the z offset to apply to current rendering
  96198. * @param value defines the offset to apply
  96199. */
  96200. setZOffset(value: number): void;
  96201. /**
  96202. * Gets the current value of the zOffset
  96203. * @returns the current zOffset state
  96204. */
  96205. getZOffset(): number;
  96206. /**
  96207. * Enable or disable depth buffering
  96208. * @param enable defines the state to set
  96209. */
  96210. setDepthBuffer(enable: boolean): void;
  96211. /**
  96212. * Gets a boolean indicating if depth writing is enabled
  96213. * @returns the current depth writing state
  96214. */
  96215. getDepthWrite(): boolean;
  96216. /**
  96217. * Enable or disable depth writing
  96218. * @param enable defines the state to set
  96219. */
  96220. setDepthWrite(enable: boolean): void;
  96221. /**
  96222. * Enable or disable color writing
  96223. * @param enable defines the state to set
  96224. */
  96225. setColorWrite(enable: boolean): void;
  96226. /**
  96227. * Gets a boolean indicating if color writing is enabled
  96228. * @returns the current color writing state
  96229. */
  96230. getColorWrite(): boolean;
  96231. /**
  96232. * Sets alpha constants used by some alpha blending modes
  96233. * @param r defines the red component
  96234. * @param g defines the green component
  96235. * @param b defines the blue component
  96236. * @param a defines the alpha component
  96237. */
  96238. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96239. /**
  96240. * Sets the current alpha mode
  96241. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96242. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96244. */
  96245. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96246. /**
  96247. * Gets the current alpha mode
  96248. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96249. * @returns the current alpha mode
  96250. */
  96251. getAlphaMode(): number;
  96252. /**
  96253. * Clears the list of texture accessible through engine.
  96254. * This can help preventing texture load conflict due to name collision.
  96255. */
  96256. clearInternalTexturesCache(): void;
  96257. /**
  96258. * Force the entire cache to be cleared
  96259. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96260. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96261. */
  96262. wipeCaches(bruteForce?: boolean): void;
  96263. /**
  96264. * Set the compressed texture format to use, based on the formats you have, and the formats
  96265. * supported by the hardware / browser.
  96266. *
  96267. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96268. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96269. * to API arguments needed to compressed textures. This puts the burden on the container
  96270. * generator to house the arcane code for determining these for current & future formats.
  96271. *
  96272. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96273. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96274. *
  96275. * Note: The result of this call is not taken into account when a texture is base64.
  96276. *
  96277. * @param formatsAvailable defines the list of those format families you have created
  96278. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96279. *
  96280. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96281. * @returns The extension selected.
  96282. */
  96283. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96284. /** @hidden */
  96285. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96286. min: number;
  96287. mag: number;
  96288. };
  96289. /** @hidden */
  96290. _createTexture(): WebGLTexture;
  96291. /**
  96292. * Usually called from Texture.ts.
  96293. * Passed information to create a WebGLTexture
  96294. * @param urlArg defines a value which contains one of the following:
  96295. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96296. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96297. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96298. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96299. * @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)
  96300. * @param scene needed for loading to the correct scene
  96301. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96302. * @param onLoad optional callback to be called upon successful completion
  96303. * @param onError optional callback to be called upon failure
  96304. * @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
  96305. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96306. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96307. * @param forcedExtension defines the extension to use to pick the right loader
  96308. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96309. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96310. */
  96311. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96312. /**
  96313. * @hidden
  96314. * Rescales a texture
  96315. * @param source input texutre
  96316. * @param destination destination texture
  96317. * @param scene scene to use to render the resize
  96318. * @param internalFormat format to use when resizing
  96319. * @param onComplete callback to be called when resize has completed
  96320. */
  96321. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96322. private _unpackFlipYCached;
  96323. /**
  96324. * In case you are sharing the context with other applications, it might
  96325. * be interested to not cache the unpack flip y state to ensure a consistent
  96326. * value would be set.
  96327. */
  96328. enableUnpackFlipYCached: boolean;
  96329. /** @hidden */
  96330. _unpackFlipY(value: boolean): void;
  96331. /** @hidden */
  96332. _getUnpackAlignement(): number;
  96333. /**
  96334. * Creates a dynamic texture
  96335. * @param width defines the width of the texture
  96336. * @param height defines the height of the texture
  96337. * @param generateMipMaps defines if the engine should generate the mip levels
  96338. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96339. * @returns the dynamic texture inside an InternalTexture
  96340. */
  96341. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96342. /**
  96343. * Update the sampling mode of a given texture
  96344. * @param samplingMode defines the required sampling mode
  96345. * @param texture defines the texture to update
  96346. */
  96347. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96348. /**
  96349. * Update the content of a dynamic texture
  96350. * @param texture defines the texture to update
  96351. * @param canvas defines the canvas containing the source
  96352. * @param invertY defines if data must be stored with Y axis inverted
  96353. * @param premulAlpha defines if alpha is stored as premultiplied
  96354. * @param format defines the format of the data
  96355. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96356. */
  96357. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96358. /**
  96359. * Update a video texture
  96360. * @param texture defines the texture to update
  96361. * @param video defines the video element to use
  96362. * @param invertY defines if data must be stored with Y axis inverted
  96363. */
  96364. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96365. /**
  96366. * Updates a depth texture Comparison Mode and Function.
  96367. * If the comparison Function is equal to 0, the mode will be set to none.
  96368. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96369. * @param texture The texture to set the comparison function for
  96370. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96371. */
  96372. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96373. /** @hidden */
  96374. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96375. width: number;
  96376. height: number;
  96377. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96378. /**
  96379. * Creates a depth stencil texture.
  96380. * This is only available in WebGL 2 or with the depth texture extension available.
  96381. * @param size The size of face edge in the texture.
  96382. * @param options The options defining the texture.
  96383. * @returns The texture
  96384. */
  96385. createDepthStencilTexture(size: number | {
  96386. width: number;
  96387. height: number;
  96388. }, options: DepthTextureCreationOptions): InternalTexture;
  96389. /**
  96390. * Creates a depth stencil texture.
  96391. * This is only available in WebGL 2 or with the depth texture extension available.
  96392. * @param size The size of face edge in the texture.
  96393. * @param options The options defining the texture.
  96394. * @returns The texture
  96395. */
  96396. private _createDepthStencilTexture;
  96397. /**
  96398. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96399. * @param renderTarget The render target to set the frame buffer for
  96400. */
  96401. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96402. /**
  96403. * Creates a new render target texture
  96404. * @param size defines the size of the texture
  96405. * @param options defines the options used to create the texture
  96406. * @returns a new render target texture stored in an InternalTexture
  96407. */
  96408. createRenderTargetTexture(size: number | {
  96409. width: number;
  96410. height: number;
  96411. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96412. /** @hidden */
  96413. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96414. /**
  96415. * Updates the sample count of a render target texture
  96416. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96417. * @param texture defines the texture to update
  96418. * @param samples defines the sample count to set
  96419. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96420. */
  96421. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96422. /** @hidden */
  96423. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96424. /** @hidden */
  96425. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96426. /** @hidden */
  96427. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96428. /** @hidden */
  96429. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96430. /**
  96431. * @hidden
  96432. */
  96433. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96434. private _prepareWebGLTextureContinuation;
  96435. private _prepareWebGLTexture;
  96436. /** @hidden */
  96437. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96438. /** @hidden */
  96439. _releaseFramebufferObjects(texture: InternalTexture): void;
  96440. /** @hidden */
  96441. _releaseTexture(texture: InternalTexture): void;
  96442. private setProgram;
  96443. private _boundUniforms;
  96444. /**
  96445. * Binds an effect to the webGL context
  96446. * @param effect defines the effect to bind
  96447. */
  96448. bindSamplers(effect: Effect): void;
  96449. private _activateCurrentTexture;
  96450. /** @hidden */
  96451. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96452. /** @hidden */
  96453. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96454. /**
  96455. * Sets a texture to the webGL context from a postprocess
  96456. * @param channel defines the channel to use
  96457. * @param postProcess defines the source postprocess
  96458. */
  96459. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96460. /**
  96461. * Binds the output of the passed in post process to the texture channel specified
  96462. * @param channel The channel the texture should be bound to
  96463. * @param postProcess The post process which's output should be bound
  96464. */
  96465. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96466. /**
  96467. * Unbind all textures from the webGL context
  96468. */
  96469. unbindAllTextures(): void;
  96470. /**
  96471. * Sets a texture to the according uniform.
  96472. * @param channel The texture channel
  96473. * @param uniform The uniform to set
  96474. * @param texture The texture to apply
  96475. */
  96476. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96477. /**
  96478. * Sets a depth stencil texture from a render target to the according uniform.
  96479. * @param channel The texture channel
  96480. * @param uniform The uniform to set
  96481. * @param texture The render target texture containing the depth stencil texture to apply
  96482. */
  96483. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96484. private _bindSamplerUniformToChannel;
  96485. private _getTextureWrapMode;
  96486. private _setTexture;
  96487. /**
  96488. * Sets an array of texture to the webGL context
  96489. * @param channel defines the channel where the texture array must be set
  96490. * @param uniform defines the associated uniform location
  96491. * @param textures defines the array of textures to bind
  96492. */
  96493. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96494. /** @hidden */
  96495. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96496. private _setTextureParameterFloat;
  96497. private _setTextureParameterInteger;
  96498. /**
  96499. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96500. * @param x defines the x coordinate of the rectangle where pixels must be read
  96501. * @param y defines the y coordinate of the rectangle where pixels must be read
  96502. * @param width defines the width of the rectangle where pixels must be read
  96503. * @param height defines the height of the rectangle where pixels must be read
  96504. * @returns a Uint8Array containing RGBA colors
  96505. */
  96506. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96507. /**
  96508. * Add an externaly attached data from its key.
  96509. * This method call will fail and return false, if such key already exists.
  96510. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96511. * @param key the unique key that identifies the data
  96512. * @param data the data object to associate to the key for this Engine instance
  96513. * @return true if no such key were already present and the data was added successfully, false otherwise
  96514. */
  96515. addExternalData<T>(key: string, data: T): boolean;
  96516. /**
  96517. * Get an externaly attached data from its key
  96518. * @param key the unique key that identifies the data
  96519. * @return the associated data, if present (can be null), or undefined if not present
  96520. */
  96521. getExternalData<T>(key: string): T;
  96522. /**
  96523. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96524. * @param key the unique key that identifies the data
  96525. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96526. * @return the associated data, can be null if the factory returned null.
  96527. */
  96528. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96529. /**
  96530. * Remove an externaly attached data from the Engine instance
  96531. * @param key the unique key that identifies the data
  96532. * @return true if the data was successfully removed, false if it doesn't exist
  96533. */
  96534. removeExternalData(key: string): boolean;
  96535. /**
  96536. * Unbind all vertex attributes from the webGL context
  96537. */
  96538. unbindAllAttributes(): void;
  96539. /**
  96540. * 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
  96541. */
  96542. releaseEffects(): void;
  96543. /**
  96544. * Dispose and release all associated resources
  96545. */
  96546. dispose(): void;
  96547. /**
  96548. * Display the loading screen
  96549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96550. */
  96551. displayLoadingUI(): void;
  96552. /**
  96553. * Hide the loading screen
  96554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96555. */
  96556. hideLoadingUI(): void;
  96557. /**
  96558. * Gets the current loading screen object
  96559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96560. */
  96561. /**
  96562. * Sets the current loading screen object
  96563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96564. */
  96565. loadingScreen: ILoadingScreen;
  96566. /**
  96567. * Sets the current loading screen text
  96568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96569. */
  96570. loadingUIText: string;
  96571. /**
  96572. * Sets the current loading screen background color
  96573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96574. */
  96575. loadingUIBackgroundColor: string;
  96576. /**
  96577. * Attach a new callback raised when context lost event is fired
  96578. * @param callback defines the callback to call
  96579. */
  96580. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96581. /**
  96582. * Attach a new callback raised when context restored event is fired
  96583. * @param callback defines the callback to call
  96584. */
  96585. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96586. /**
  96587. * Gets the source code of the vertex shader associated with a specific webGL program
  96588. * @param program defines the program to use
  96589. * @returns a string containing the source code of the vertex shader associated with the program
  96590. */
  96591. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96592. /**
  96593. * Gets the source code of the fragment shader associated with a specific webGL program
  96594. * @param program defines the program to use
  96595. * @returns a string containing the source code of the fragment shader associated with the program
  96596. */
  96597. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96598. /**
  96599. * Get the current error code of the webGL context
  96600. * @returns the error code
  96601. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96602. */
  96603. getError(): number;
  96604. /**
  96605. * Gets the current framerate
  96606. * @returns a number representing the framerate
  96607. */
  96608. getFps(): number;
  96609. /**
  96610. * Gets the time spent between current and previous frame
  96611. * @returns a number representing the delta time in ms
  96612. */
  96613. getDeltaTime(): number;
  96614. private _measureFps;
  96615. /** @hidden */
  96616. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96617. private _canRenderToFloatFramebuffer;
  96618. private _canRenderToHalfFloatFramebuffer;
  96619. private _canRenderToFramebuffer;
  96620. /** @hidden */
  96621. _getWebGLTextureType(type: number): number;
  96622. /** @hidden */
  96623. _getInternalFormat(format: number): number;
  96624. /** @hidden */
  96625. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96626. /** @hidden */
  96627. _getRGBAMultiSampleBufferFormat(type: number): number;
  96628. /** @hidden */
  96629. _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;
  96630. /** @hidden */
  96631. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96632. /**
  96633. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96634. * @returns true if the engine can be created
  96635. * @ignorenaming
  96636. */
  96637. static isSupported(): boolean;
  96638. /**
  96639. * Find the next highest power of two.
  96640. * @param x Number to start search from.
  96641. * @return Next highest power of two.
  96642. */
  96643. static CeilingPOT(x: number): number;
  96644. /**
  96645. * Find the next lowest power of two.
  96646. * @param x Number to start search from.
  96647. * @return Next lowest power of two.
  96648. */
  96649. static FloorPOT(x: number): number;
  96650. /**
  96651. * Find the nearest power of two.
  96652. * @param x Number to start search from.
  96653. * @return Next nearest power of two.
  96654. */
  96655. static NearestPOT(x: number): number;
  96656. /**
  96657. * Get the closest exponent of two
  96658. * @param value defines the value to approximate
  96659. * @param max defines the maximum value to return
  96660. * @param mode defines how to define the closest value
  96661. * @returns closest exponent of two of the given value
  96662. */
  96663. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96664. /**
  96665. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96666. * @param func - the function to be called
  96667. * @param requester - the object that will request the next frame. Falls back to window.
  96668. * @returns frame number
  96669. */
  96670. static QueueNewFrame(func: () => void, requester?: any): number;
  96671. /**
  96672. * Ask the browser to promote the current element to pointerlock mode
  96673. * @param element defines the DOM element to promote
  96674. */
  96675. static _RequestPointerlock(element: HTMLElement): void;
  96676. /**
  96677. * Asks the browser to exit pointerlock mode
  96678. */
  96679. static _ExitPointerlock(): void;
  96680. /**
  96681. * Ask the browser to promote the current element to fullscreen rendering mode
  96682. * @param element defines the DOM element to promote
  96683. */
  96684. static _RequestFullscreen(element: HTMLElement): void;
  96685. /**
  96686. * Asks the browser to exit fullscreen mode
  96687. */
  96688. static _ExitFullscreen(): void;
  96689. }
  96690. }
  96691. declare module BABYLON {
  96692. /**
  96693. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96694. * during the life time of the application.
  96695. */
  96696. export class EngineStore {
  96697. /** Gets the list of created engines */
  96698. static Instances: Engine[];
  96699. /** @hidden */
  96700. static _LastCreatedScene: Nullable<Scene>;
  96701. /**
  96702. * Gets the latest created engine
  96703. */
  96704. static readonly LastCreatedEngine: Nullable<Engine>;
  96705. /**
  96706. * Gets the latest created scene
  96707. */
  96708. static readonly LastCreatedScene: Nullable<Scene>;
  96709. /**
  96710. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96711. * @ignorenaming
  96712. */
  96713. static UseFallbackTexture: boolean;
  96714. /**
  96715. * Texture content used if a texture cannot loaded
  96716. * @ignorenaming
  96717. */
  96718. static FallbackTexture: string;
  96719. }
  96720. }
  96721. declare module BABYLON {
  96722. /**
  96723. * Helper class that provides a small promise polyfill
  96724. */
  96725. export class PromisePolyfill {
  96726. /**
  96727. * Static function used to check if the polyfill is required
  96728. * If this is the case then the function will inject the polyfill to window.Promise
  96729. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96730. */
  96731. static Apply(force?: boolean): void;
  96732. }
  96733. }
  96734. declare module BABYLON {
  96735. /**
  96736. * Interface for screenshot methods with describe argument called `size` as object with options
  96737. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96738. */
  96739. export interface IScreenshotSize {
  96740. /**
  96741. * number in pixels for canvas height
  96742. */
  96743. height?: number;
  96744. /**
  96745. * multiplier allowing render at a higher or lower resolution
  96746. * If value is defined then height and width will be ignored and taken from camera
  96747. */
  96748. precision?: number;
  96749. /**
  96750. * number in pixels for canvas width
  96751. */
  96752. width?: number;
  96753. }
  96754. }
  96755. declare module BABYLON {
  96756. interface IColor4Like {
  96757. r: float;
  96758. g: float;
  96759. b: float;
  96760. a: float;
  96761. }
  96762. /**
  96763. * Class containing a set of static utilities functions
  96764. */
  96765. export class Tools {
  96766. /**
  96767. * Gets or sets the base URL to use to load assets
  96768. */
  96769. static BaseUrl: string;
  96770. /**
  96771. * Enable/Disable Custom HTTP Request Headers globally.
  96772. * default = false
  96773. * @see CustomRequestHeaders
  96774. */
  96775. static UseCustomRequestHeaders: boolean;
  96776. /**
  96777. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96778. * i.e. when loading files, where the server/service expects an Authorization header
  96779. */
  96780. static CustomRequestHeaders: {
  96781. [key: string]: string;
  96782. };
  96783. /**
  96784. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96785. */
  96786. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96787. /**
  96788. * Default behaviour for cors in the application.
  96789. * It can be a string if the expected behavior is identical in the entire app.
  96790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96791. */
  96792. static CorsBehavior: string | ((url: string | string[]) => string);
  96793. /**
  96794. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96795. * @ignorenaming
  96796. */
  96797. static UseFallbackTexture: boolean;
  96798. /**
  96799. * Use this object to register external classes like custom textures or material
  96800. * to allow the laoders to instantiate them
  96801. */
  96802. static RegisteredExternalClasses: {
  96803. [key: string]: Object;
  96804. };
  96805. /**
  96806. * Texture content used if a texture cannot loaded
  96807. * @ignorenaming
  96808. */
  96809. static fallbackTexture: string;
  96810. /**
  96811. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96812. * @param u defines the coordinate on X axis
  96813. * @param v defines the coordinate on Y axis
  96814. * @param width defines the width of the source data
  96815. * @param height defines the height of the source data
  96816. * @param pixels defines the source byte array
  96817. * @param color defines the output color
  96818. */
  96819. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96820. /**
  96821. * Interpolates between a and b via alpha
  96822. * @param a The lower value (returned when alpha = 0)
  96823. * @param b The upper value (returned when alpha = 1)
  96824. * @param alpha The interpolation-factor
  96825. * @return The mixed value
  96826. */
  96827. static Mix(a: number, b: number, alpha: number): number;
  96828. /**
  96829. * Tries to instantiate a new object from a given class name
  96830. * @param className defines the class name to instantiate
  96831. * @returns the new object or null if the system was not able to do the instantiation
  96832. */
  96833. static Instantiate(className: string): any;
  96834. /**
  96835. * Provides a slice function that will work even on IE
  96836. * @param data defines the array to slice
  96837. * @param start defines the start of the data (optional)
  96838. * @param end defines the end of the data (optional)
  96839. * @returns the new sliced array
  96840. */
  96841. static Slice<T>(data: T, start?: number, end?: number): T;
  96842. /**
  96843. * Polyfill for setImmediate
  96844. * @param action defines the action to execute after the current execution block
  96845. */
  96846. static SetImmediate(action: () => void): void;
  96847. /**
  96848. * Function indicating if a number is an exponent of 2
  96849. * @param value defines the value to test
  96850. * @returns true if the value is an exponent of 2
  96851. */
  96852. static IsExponentOfTwo(value: number): boolean;
  96853. private static _tmpFloatArray;
  96854. /**
  96855. * Returns the nearest 32-bit single precision float representation of a Number
  96856. * @param value A Number. If the parameter is of a different type, it will get converted
  96857. * to a number or to NaN if it cannot be converted
  96858. * @returns number
  96859. */
  96860. static FloatRound(value: number): number;
  96861. /**
  96862. * Extracts the filename from a path
  96863. * @param path defines the path to use
  96864. * @returns the filename
  96865. */
  96866. static GetFilename(path: string): string;
  96867. /**
  96868. * Extracts the "folder" part of a path (everything before the filename).
  96869. * @param uri The URI to extract the info from
  96870. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96871. * @returns The "folder" part of the path
  96872. */
  96873. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96874. /**
  96875. * Extracts text content from a DOM element hierarchy
  96876. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96877. */
  96878. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96879. /**
  96880. * Convert an angle in radians to degrees
  96881. * @param angle defines the angle to convert
  96882. * @returns the angle in degrees
  96883. */
  96884. static ToDegrees(angle: number): number;
  96885. /**
  96886. * Convert an angle in degrees to radians
  96887. * @param angle defines the angle to convert
  96888. * @returns the angle in radians
  96889. */
  96890. static ToRadians(angle: number): number;
  96891. /**
  96892. * Encode a buffer to a base64 string
  96893. * @param buffer defines the buffer to encode
  96894. * @returns the encoded string
  96895. */
  96896. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96897. /**
  96898. * Returns an array if obj is not an array
  96899. * @param obj defines the object to evaluate as an array
  96900. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96901. * @returns either obj directly if obj is an array or a new array containing obj
  96902. */
  96903. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96904. /**
  96905. * Gets the pointer prefix to use
  96906. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96907. */
  96908. static GetPointerPrefix(): string;
  96909. /**
  96910. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96911. * @param url define the url we are trying
  96912. * @param element define the dom element where to configure the cors policy
  96913. */
  96914. static SetCorsBehavior(url: string | string[], element: {
  96915. crossOrigin: string | null;
  96916. }): void;
  96917. /**
  96918. * Removes unwanted characters from an url
  96919. * @param url defines the url to clean
  96920. * @returns the cleaned url
  96921. */
  96922. static CleanUrl(url: string): string;
  96923. /**
  96924. * Gets or sets a function used to pre-process url before using them to load assets
  96925. */
  96926. static PreprocessUrl: (url: string) => string;
  96927. /**
  96928. * Loads an image as an HTMLImageElement.
  96929. * @param input url string, ArrayBuffer, or Blob to load
  96930. * @param onLoad callback called when the image successfully loads
  96931. * @param onError callback called when the image fails to load
  96932. * @param offlineProvider offline provider for caching
  96933. * @returns the HTMLImageElement of the loaded image
  96934. */
  96935. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96936. /**
  96937. * Loads a file
  96938. * @param url url string, ArrayBuffer, or Blob to load
  96939. * @param onSuccess callback called when the file successfully loads
  96940. * @param onProgress callback called while file is loading (if the server supports this mode)
  96941. * @param offlineProvider defines the offline provider for caching
  96942. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96943. * @param onError callback called when the file fails to load
  96944. * @returns a file request object
  96945. */
  96946. 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;
  96947. /**
  96948. * Loads a file from a url
  96949. * @param url the file url to load
  96950. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96951. */
  96952. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96953. /**
  96954. * Load a script (identified by an url). When the url returns, the
  96955. * content of this file is added into a new script element, attached to the DOM (body element)
  96956. * @param scriptUrl defines the url of the script to laod
  96957. * @param onSuccess defines the callback called when the script is loaded
  96958. * @param onError defines the callback to call if an error occurs
  96959. * @param scriptId defines the id of the script element
  96960. */
  96961. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96962. /**
  96963. * Load an asynchronous script (identified by an url). When the url returns, the
  96964. * content of this file is added into a new script element, attached to the DOM (body element)
  96965. * @param scriptUrl defines the url of the script to laod
  96966. * @param scriptId defines the id of the script element
  96967. * @returns a promise request object
  96968. */
  96969. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96970. /**
  96971. * Loads a file from a blob
  96972. * @param fileToLoad defines the blob to use
  96973. * @param callback defines the callback to call when data is loaded
  96974. * @param progressCallback defines the callback to call during loading process
  96975. * @returns a file request object
  96976. */
  96977. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96978. /**
  96979. * Loads a file
  96980. * @param fileToLoad defines the file to load
  96981. * @param callback defines the callback to call when data is loaded
  96982. * @param progressCallBack defines the callback to call during loading process
  96983. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96984. * @returns a file request object
  96985. */
  96986. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96987. /**
  96988. * Creates a data url from a given string content
  96989. * @param content defines the content to convert
  96990. * @returns the new data url link
  96991. */
  96992. static FileAsURL(content: string): string;
  96993. /**
  96994. * Format the given number to a specific decimal format
  96995. * @param value defines the number to format
  96996. * @param decimals defines the number of decimals to use
  96997. * @returns the formatted string
  96998. */
  96999. static Format(value: number, decimals?: number): string;
  97000. /**
  97001. * Tries to copy an object by duplicating every property
  97002. * @param source defines the source object
  97003. * @param destination defines the target object
  97004. * @param doNotCopyList defines a list of properties to avoid
  97005. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97006. */
  97007. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97008. /**
  97009. * Gets a boolean indicating if the given object has no own property
  97010. * @param obj defines the object to test
  97011. * @returns true if object has no own property
  97012. */
  97013. static IsEmpty(obj: any): boolean;
  97014. /**
  97015. * Function used to register events at window level
  97016. * @param windowElement defines the Window object to use
  97017. * @param events defines the events to register
  97018. */
  97019. static RegisterTopRootEvents(windowElement: Window, events: {
  97020. name: string;
  97021. handler: Nullable<(e: FocusEvent) => any>;
  97022. }[]): void;
  97023. /**
  97024. * Function used to unregister events from window level
  97025. * @param windowElement defines the Window object to use
  97026. * @param events defines the events to unregister
  97027. */
  97028. static UnregisterTopRootEvents(windowElement: Window, events: {
  97029. name: string;
  97030. handler: Nullable<(e: FocusEvent) => any>;
  97031. }[]): void;
  97032. /**
  97033. * @ignore
  97034. */
  97035. static _ScreenshotCanvas: HTMLCanvasElement;
  97036. /**
  97037. * Dumps the current bound framebuffer
  97038. * @param width defines the rendering width
  97039. * @param height defines the rendering height
  97040. * @param engine defines the hosting engine
  97041. * @param successCallback defines the callback triggered once the data are available
  97042. * @param mimeType defines the mime type of the result
  97043. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97044. */
  97045. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97046. /**
  97047. * Converts the canvas data to blob.
  97048. * This acts as a polyfill for browsers not supporting the to blob function.
  97049. * @param canvas Defines the canvas to extract the data from
  97050. * @param successCallback Defines the callback triggered once the data are available
  97051. * @param mimeType Defines the mime type of the result
  97052. */
  97053. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97054. /**
  97055. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97056. * @param successCallback defines the callback triggered once the data are available
  97057. * @param mimeType defines the mime type of the result
  97058. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97059. */
  97060. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97061. /**
  97062. * Downloads a blob in the browser
  97063. * @param blob defines the blob to download
  97064. * @param fileName defines the name of the downloaded file
  97065. */
  97066. static Download(blob: Blob, fileName: string): void;
  97067. /**
  97068. * Captures a screenshot of the current rendering
  97069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97070. * @param engine defines the rendering engine
  97071. * @param camera defines the source camera
  97072. * @param size This parameter can be set to a single number or to an object with the
  97073. * following (optional) properties: precision, width, height. If a single number is passed,
  97074. * it will be used for both width and height. If an object is passed, the screenshot size
  97075. * will be derived from the parameters. The precision property is a multiplier allowing
  97076. * rendering at a higher or lower resolution
  97077. * @param successCallback defines the callback receives a single parameter which contains the
  97078. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97079. * src parameter of an <img> to display it
  97080. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97081. * Check your browser for supported MIME types
  97082. */
  97083. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97084. /**
  97085. * Captures a screenshot of the current rendering
  97086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97087. * @param engine defines the rendering engine
  97088. * @param camera defines the source camera
  97089. * @param size This parameter can be set to a single number or to an object with the
  97090. * following (optional) properties: precision, width, height. If a single number is passed,
  97091. * it will be used for both width and height. If an object is passed, the screenshot size
  97092. * will be derived from the parameters. The precision property is a multiplier allowing
  97093. * rendering at a higher or lower resolution
  97094. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97095. * Check your browser for supported MIME types
  97096. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97097. * to the src parameter of an <img> to display it
  97098. */
  97099. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97100. /**
  97101. * Generates an image screenshot from the specified camera.
  97102. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97103. * @param engine The engine to use for rendering
  97104. * @param camera The camera to use for rendering
  97105. * @param size This parameter can be set to a single number or to an object with the
  97106. * following (optional) properties: precision, width, height. If a single number is passed,
  97107. * it will be used for both width and height. If an object is passed, the screenshot size
  97108. * will be derived from the parameters. The precision property is a multiplier allowing
  97109. * rendering at a higher or lower resolution
  97110. * @param successCallback The callback receives a single parameter which contains the
  97111. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97112. * src parameter of an <img> to display it
  97113. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97114. * Check your browser for supported MIME types
  97115. * @param samples Texture samples (default: 1)
  97116. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97117. * @param fileName A name for for the downloaded file.
  97118. */
  97119. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97120. /**
  97121. * Generates an image screenshot from the specified camera.
  97122. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97123. * @param engine The engine to use for rendering
  97124. * @param camera The camera to use for rendering
  97125. * @param size This parameter can be set to a single number or to an object with the
  97126. * following (optional) properties: precision, width, height. If a single number is passed,
  97127. * it will be used for both width and height. If an object is passed, the screenshot size
  97128. * will be derived from the parameters. The precision property is a multiplier allowing
  97129. * rendering at a higher or lower resolution
  97130. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97131. * Check your browser for supported MIME types
  97132. * @param samples Texture samples (default: 1)
  97133. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97134. * @param fileName A name for for the downloaded file.
  97135. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97136. * to the src parameter of an <img> to display it
  97137. */
  97138. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97139. /**
  97140. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97141. * Be aware Math.random() could cause collisions, but:
  97142. * "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"
  97143. * @returns a pseudo random id
  97144. */
  97145. static RandomId(): string;
  97146. /**
  97147. * Test if the given uri is a base64 string
  97148. * @param uri The uri to test
  97149. * @return True if the uri is a base64 string or false otherwise
  97150. */
  97151. static IsBase64(uri: string): boolean;
  97152. /**
  97153. * Decode the given base64 uri.
  97154. * @param uri The uri to decode
  97155. * @return The decoded base64 data.
  97156. */
  97157. static DecodeBase64(uri: string): ArrayBuffer;
  97158. /**
  97159. * Gets the absolute url.
  97160. * @param url the input url
  97161. * @return the absolute url
  97162. */
  97163. static GetAbsoluteUrl(url: string): string;
  97164. /**
  97165. * No log
  97166. */
  97167. static readonly NoneLogLevel: number;
  97168. /**
  97169. * Only message logs
  97170. */
  97171. static readonly MessageLogLevel: number;
  97172. /**
  97173. * Only warning logs
  97174. */
  97175. static readonly WarningLogLevel: number;
  97176. /**
  97177. * Only error logs
  97178. */
  97179. static readonly ErrorLogLevel: number;
  97180. /**
  97181. * All logs
  97182. */
  97183. static readonly AllLogLevel: number;
  97184. /**
  97185. * Gets a value indicating the number of loading errors
  97186. * @ignorenaming
  97187. */
  97188. static readonly errorsCount: number;
  97189. /**
  97190. * Callback called when a new log is added
  97191. */
  97192. static OnNewCacheEntry: (entry: string) => void;
  97193. /**
  97194. * Log a message to the console
  97195. * @param message defines the message to log
  97196. */
  97197. static Log(message: string): void;
  97198. /**
  97199. * Write a warning message to the console
  97200. * @param message defines the message to log
  97201. */
  97202. static Warn(message: string): void;
  97203. /**
  97204. * Write an error message to the console
  97205. * @param message defines the message to log
  97206. */
  97207. static Error(message: string): void;
  97208. /**
  97209. * Gets current log cache (list of logs)
  97210. */
  97211. static readonly LogCache: string;
  97212. /**
  97213. * Clears the log cache
  97214. */
  97215. static ClearLogCache(): void;
  97216. /**
  97217. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97218. */
  97219. static LogLevels: number;
  97220. /**
  97221. * Checks if the window object exists
  97222. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97223. */
  97224. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97225. /**
  97226. * No performance log
  97227. */
  97228. static readonly PerformanceNoneLogLevel: number;
  97229. /**
  97230. * Use user marks to log performance
  97231. */
  97232. static readonly PerformanceUserMarkLogLevel: number;
  97233. /**
  97234. * Log performance to the console
  97235. */
  97236. static readonly PerformanceConsoleLogLevel: number;
  97237. private static _performance;
  97238. /**
  97239. * Sets the current performance log level
  97240. */
  97241. static PerformanceLogLevel: number;
  97242. private static _StartPerformanceCounterDisabled;
  97243. private static _EndPerformanceCounterDisabled;
  97244. private static _StartUserMark;
  97245. private static _EndUserMark;
  97246. private static _StartPerformanceConsole;
  97247. private static _EndPerformanceConsole;
  97248. /**
  97249. * Starts a performance counter
  97250. */
  97251. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97252. /**
  97253. * Ends a specific performance coutner
  97254. */
  97255. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97256. /**
  97257. * Gets either window.performance.now() if supported or Date.now() else
  97258. */
  97259. static readonly Now: number;
  97260. /**
  97261. * This method will return the name of the class used to create the instance of the given object.
  97262. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97263. * @param object the object to get the class name from
  97264. * @param isType defines if the object is actually a type
  97265. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97266. */
  97267. static GetClassName(object: any, isType?: boolean): string;
  97268. /**
  97269. * Gets the first element of an array satisfying a given predicate
  97270. * @param array defines the array to browse
  97271. * @param predicate defines the predicate to use
  97272. * @returns null if not found or the element
  97273. */
  97274. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97275. /**
  97276. * This method will return the name of the full name of the class, including its owning module (if any).
  97277. * 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).
  97278. * @param object the object to get the class name from
  97279. * @param isType defines if the object is actually a type
  97280. * @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.
  97281. * @ignorenaming
  97282. */
  97283. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97284. /**
  97285. * Returns a promise that resolves after the given amount of time.
  97286. * @param delay Number of milliseconds to delay
  97287. * @returns Promise that resolves after the given amount of time
  97288. */
  97289. static DelayAsync(delay: number): Promise<void>;
  97290. }
  97291. /**
  97292. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97293. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97294. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97295. * @param name The name of the class, case should be preserved
  97296. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97297. */
  97298. export function className(name: string, module?: string): (target: Object) => void;
  97299. /**
  97300. * An implementation of a loop for asynchronous functions.
  97301. */
  97302. export class AsyncLoop {
  97303. /**
  97304. * Defines the number of iterations for the loop
  97305. */
  97306. iterations: number;
  97307. /**
  97308. * Defines the current index of the loop.
  97309. */
  97310. index: number;
  97311. private _done;
  97312. private _fn;
  97313. private _successCallback;
  97314. /**
  97315. * Constructor.
  97316. * @param iterations the number of iterations.
  97317. * @param func the function to run each iteration
  97318. * @param successCallback the callback that will be called upon succesful execution
  97319. * @param offset starting offset.
  97320. */
  97321. constructor(
  97322. /**
  97323. * Defines the number of iterations for the loop
  97324. */
  97325. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97326. /**
  97327. * Execute the next iteration. Must be called after the last iteration was finished.
  97328. */
  97329. executeNext(): void;
  97330. /**
  97331. * Break the loop and run the success callback.
  97332. */
  97333. breakLoop(): void;
  97334. /**
  97335. * Create and run an async loop.
  97336. * @param iterations the number of iterations.
  97337. * @param fn the function to run each iteration
  97338. * @param successCallback the callback that will be called upon succesful execution
  97339. * @param offset starting offset.
  97340. * @returns the created async loop object
  97341. */
  97342. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97343. /**
  97344. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97345. * @param iterations total number of iterations
  97346. * @param syncedIterations number of synchronous iterations in each async iteration.
  97347. * @param fn the function to call each iteration.
  97348. * @param callback a success call back that will be called when iterating stops.
  97349. * @param breakFunction a break condition (optional)
  97350. * @param timeout timeout settings for the setTimeout function. default - 0.
  97351. * @returns the created async loop object
  97352. */
  97353. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97354. }
  97355. }
  97356. declare module BABYLON {
  97357. /** @hidden */
  97358. export interface ICollisionCoordinator {
  97359. createCollider(): Collider;
  97360. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97361. init(scene: Scene): void;
  97362. }
  97363. /** @hidden */
  97364. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97365. private _scene;
  97366. private _scaledPosition;
  97367. private _scaledVelocity;
  97368. private _finalPosition;
  97369. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97370. createCollider(): Collider;
  97371. init(scene: Scene): void;
  97372. private _collideWithWorld;
  97373. }
  97374. }
  97375. declare module BABYLON {
  97376. /**
  97377. * Class used to manage all inputs for the scene.
  97378. */
  97379. export class InputManager {
  97380. /** The distance in pixel that you have to move to prevent some events */
  97381. static DragMovementThreshold: number;
  97382. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97383. static LongPressDelay: number;
  97384. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97385. static DoubleClickDelay: number;
  97386. /** If you need to check double click without raising a single click at first click, enable this flag */
  97387. static ExclusiveDoubleClickMode: boolean;
  97388. private _wheelEventName;
  97389. private _onPointerMove;
  97390. private _onPointerDown;
  97391. private _onPointerUp;
  97392. private _initClickEvent;
  97393. private _initActionManager;
  97394. private _delayedSimpleClick;
  97395. private _delayedSimpleClickTimeout;
  97396. private _previousDelayedSimpleClickTimeout;
  97397. private _meshPickProceed;
  97398. private _previousButtonPressed;
  97399. private _currentPickResult;
  97400. private _previousPickResult;
  97401. private _totalPointersPressed;
  97402. private _doubleClickOccured;
  97403. private _pointerOverMesh;
  97404. private _pickedDownMesh;
  97405. private _pickedUpMesh;
  97406. private _pointerX;
  97407. private _pointerY;
  97408. private _unTranslatedPointerX;
  97409. private _unTranslatedPointerY;
  97410. private _startingPointerPosition;
  97411. private _previousStartingPointerPosition;
  97412. private _startingPointerTime;
  97413. private _previousStartingPointerTime;
  97414. private _pointerCaptures;
  97415. private _onKeyDown;
  97416. private _onKeyUp;
  97417. private _onCanvasFocusObserver;
  97418. private _onCanvasBlurObserver;
  97419. private _scene;
  97420. /**
  97421. * Creates a new InputManager
  97422. * @param scene defines the hosting scene
  97423. */
  97424. constructor(scene: Scene);
  97425. /**
  97426. * Gets the mesh that is currently under the pointer
  97427. */
  97428. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97429. /**
  97430. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97431. */
  97432. readonly unTranslatedPointer: Vector2;
  97433. /**
  97434. * Gets or sets the current on-screen X position of the pointer
  97435. */
  97436. pointerX: number;
  97437. /**
  97438. * Gets or sets the current on-screen Y position of the pointer
  97439. */
  97440. pointerY: number;
  97441. private _updatePointerPosition;
  97442. private _processPointerMove;
  97443. private _setRayOnPointerInfo;
  97444. private _checkPrePointerObservable;
  97445. /**
  97446. * Use this method to simulate a pointer move on a mesh
  97447. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97448. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97449. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97450. */
  97451. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97452. /**
  97453. * Use this method to simulate a pointer down on a mesh
  97454. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97455. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97456. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97457. */
  97458. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97459. private _processPointerDown;
  97460. /** @hidden */
  97461. _isPointerSwiping(): boolean;
  97462. /**
  97463. * Use this method to simulate a pointer up on a mesh
  97464. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97465. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97466. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97467. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97468. */
  97469. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97470. private _processPointerUp;
  97471. /**
  97472. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97473. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97474. * @returns true if the pointer was captured
  97475. */
  97476. isPointerCaptured(pointerId?: number): boolean;
  97477. /**
  97478. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97479. * @param attachUp defines if you want to attach events to pointerup
  97480. * @param attachDown defines if you want to attach events to pointerdown
  97481. * @param attachMove defines if you want to attach events to pointermove
  97482. */
  97483. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97484. /**
  97485. * Detaches all event handlers
  97486. */
  97487. detachControl(): void;
  97488. /**
  97489. * Force the value of meshUnderPointer
  97490. * @param mesh defines the mesh to use
  97491. */
  97492. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97493. /**
  97494. * Gets the mesh under the pointer
  97495. * @returns a Mesh or null if no mesh is under the pointer
  97496. */
  97497. getPointerOverMesh(): Nullable<AbstractMesh>;
  97498. }
  97499. }
  97500. declare module BABYLON {
  97501. /**
  97502. * Helper class used to generate session unique ID
  97503. */
  97504. export class UniqueIdGenerator {
  97505. private static _UniqueIdCounter;
  97506. /**
  97507. * Gets an unique (relatively to the current scene) Id
  97508. */
  97509. static readonly UniqueId: number;
  97510. }
  97511. }
  97512. declare module BABYLON {
  97513. /**
  97514. * This class defines the direct association between an animation and a target
  97515. */
  97516. export class TargetedAnimation {
  97517. /**
  97518. * Animation to perform
  97519. */
  97520. animation: Animation;
  97521. /**
  97522. * Target to animate
  97523. */
  97524. target: any;
  97525. /**
  97526. * Serialize the object
  97527. * @returns the JSON object representing the current entity
  97528. */
  97529. serialize(): any;
  97530. }
  97531. /**
  97532. * Use this class to create coordinated animations on multiple targets
  97533. */
  97534. export class AnimationGroup implements IDisposable {
  97535. /** The name of the animation group */
  97536. name: string;
  97537. private _scene;
  97538. private _targetedAnimations;
  97539. private _animatables;
  97540. private _from;
  97541. private _to;
  97542. private _isStarted;
  97543. private _isPaused;
  97544. private _speedRatio;
  97545. private _loopAnimation;
  97546. /**
  97547. * Gets or sets the unique id of the node
  97548. */
  97549. uniqueId: number;
  97550. /**
  97551. * This observable will notify when one animation have ended
  97552. */
  97553. onAnimationEndObservable: Observable<TargetedAnimation>;
  97554. /**
  97555. * Observer raised when one animation loops
  97556. */
  97557. onAnimationLoopObservable: Observable<TargetedAnimation>;
  97558. /**
  97559. * This observable will notify when all animations have ended.
  97560. */
  97561. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  97562. /**
  97563. * This observable will notify when all animations have paused.
  97564. */
  97565. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  97566. /**
  97567. * This observable will notify when all animations are playing.
  97568. */
  97569. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  97570. /**
  97571. * Gets the first frame
  97572. */
  97573. readonly from: number;
  97574. /**
  97575. * Gets the last frame
  97576. */
  97577. readonly to: number;
  97578. /**
  97579. * Define if the animations are started
  97580. */
  97581. readonly isStarted: boolean;
  97582. /**
  97583. * Gets a value indicating that the current group is playing
  97584. */
  97585. readonly isPlaying: boolean;
  97586. /**
  97587. * Gets or sets the speed ratio to use for all animations
  97588. */
  97589. /**
  97590. * Gets or sets the speed ratio to use for all animations
  97591. */
  97592. speedRatio: number;
  97593. /**
  97594. * Gets or sets if all animations should loop or not
  97595. */
  97596. loopAnimation: boolean;
  97597. /**
  97598. * Gets the targeted animations for this animation group
  97599. */
  97600. readonly targetedAnimations: Array<TargetedAnimation>;
  97601. /**
  97602. * returning the list of animatables controlled by this animation group.
  97603. */
  97604. readonly animatables: Array<Animatable>;
  97605. /**
  97606. * Instantiates a new Animation Group.
  97607. * This helps managing several animations at once.
  97608. * @see http://doc.babylonjs.com/how_to/group
  97609. * @param name Defines the name of the group
  97610. * @param scene Defines the scene the group belongs to
  97611. */
  97612. constructor(
  97613. /** The name of the animation group */
  97614. name: string, scene?: Nullable<Scene>);
  97615. /**
  97616. * Add an animation (with its target) in the group
  97617. * @param animation defines the animation we want to add
  97618. * @param target defines the target of the animation
  97619. * @returns the TargetedAnimation object
  97620. */
  97621. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97622. /**
  97623. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97624. * It can add constant keys at begin or end
  97625. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97626. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97627. * @returns the animation group
  97628. */
  97629. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97630. /**
  97631. * Start all animations on given targets
  97632. * @param loop defines if animations must loop
  97633. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97634. * @param from defines the from key (optional)
  97635. * @param to defines the to key (optional)
  97636. * @returns the current animation group
  97637. */
  97638. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97639. /**
  97640. * Pause all animations
  97641. * @returns the animation group
  97642. */
  97643. pause(): AnimationGroup;
  97644. /**
  97645. * Play all animations to initial state
  97646. * This function will start() the animations if they were not started or will restart() them if they were paused
  97647. * @param loop defines if animations must loop
  97648. * @returns the animation group
  97649. */
  97650. play(loop?: boolean): AnimationGroup;
  97651. /**
  97652. * Reset all animations to initial state
  97653. * @returns the animation group
  97654. */
  97655. reset(): AnimationGroup;
  97656. /**
  97657. * Restart animations from key 0
  97658. * @returns the animation group
  97659. */
  97660. restart(): AnimationGroup;
  97661. /**
  97662. * Stop all animations
  97663. * @returns the animation group
  97664. */
  97665. stop(): AnimationGroup;
  97666. /**
  97667. * Set animation weight for all animatables
  97668. * @param weight defines the weight to use
  97669. * @return the animationGroup
  97670. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97671. */
  97672. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97673. /**
  97674. * Synchronize and normalize all animatables with a source animatable
  97675. * @param root defines the root animatable to synchronize with
  97676. * @return the animationGroup
  97677. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97678. */
  97679. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97680. /**
  97681. * Goes to a specific frame in this animation group
  97682. * @param frame the frame number to go to
  97683. * @return the animationGroup
  97684. */
  97685. goToFrame(frame: number): AnimationGroup;
  97686. /**
  97687. * Dispose all associated resources
  97688. */
  97689. dispose(): void;
  97690. private _checkAnimationGroupEnded;
  97691. /**
  97692. * Clone the current animation group and returns a copy
  97693. * @param newName defines the name of the new group
  97694. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97695. * @returns the new aniamtion group
  97696. */
  97697. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97698. /**
  97699. * Serializes the animationGroup to an object
  97700. * @returns Serialized object
  97701. */
  97702. serialize(): any;
  97703. /**
  97704. * Returns a new AnimationGroup object parsed from the source provided.
  97705. * @param parsedAnimationGroup defines the source
  97706. * @param scene defines the scene that will receive the animationGroup
  97707. * @returns a new AnimationGroup
  97708. */
  97709. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97710. /**
  97711. * Returns the string "AnimationGroup"
  97712. * @returns "AnimationGroup"
  97713. */
  97714. getClassName(): string;
  97715. /**
  97716. * Creates a detailled string about the object
  97717. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97718. * @returns a string representing the object
  97719. */
  97720. toString(fullDetails?: boolean): string;
  97721. }
  97722. }
  97723. declare module BABYLON {
  97724. /**
  97725. * Define an interface for all classes that will hold resources
  97726. */
  97727. export interface IDisposable {
  97728. /**
  97729. * Releases all held resources
  97730. */
  97731. dispose(): void;
  97732. }
  97733. /** Interface defining initialization parameters for Scene class */
  97734. export interface SceneOptions {
  97735. /**
  97736. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97737. * It will improve performance when the number of geometries becomes important.
  97738. */
  97739. useGeometryUniqueIdsMap?: boolean;
  97740. /**
  97741. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97743. */
  97744. useMaterialMeshMap?: boolean;
  97745. /**
  97746. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97747. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97748. */
  97749. useClonedMeshhMap?: boolean;
  97750. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97751. virtual?: boolean;
  97752. }
  97753. /**
  97754. * Represents a scene to be rendered by the engine.
  97755. * @see http://doc.babylonjs.com/features/scene
  97756. */
  97757. export class Scene extends AbstractScene implements IAnimatable {
  97758. /** The fog is deactivated */
  97759. static readonly FOGMODE_NONE: number;
  97760. /** The fog density is following an exponential function */
  97761. static readonly FOGMODE_EXP: number;
  97762. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97763. static readonly FOGMODE_EXP2: number;
  97764. /** The fog density is following a linear function. */
  97765. static readonly FOGMODE_LINEAR: number;
  97766. /**
  97767. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97769. */
  97770. static MinDeltaTime: number;
  97771. /**
  97772. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97774. */
  97775. static MaxDeltaTime: number;
  97776. /**
  97777. * Factory used to create the default material.
  97778. * @param name The name of the material to create
  97779. * @param scene The scene to create the material for
  97780. * @returns The default material
  97781. */
  97782. static DefaultMaterialFactory(scene: Scene): Material;
  97783. /**
  97784. * Factory used to create the a collision coordinator.
  97785. * @returns The collision coordinator
  97786. */
  97787. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97788. /** @hidden */
  97789. _inputManager: InputManager;
  97790. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97791. cameraToUseForPointers: Nullable<Camera>;
  97792. /** @hidden */
  97793. readonly _isScene: boolean;
  97794. /**
  97795. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97796. */
  97797. autoClear: boolean;
  97798. /**
  97799. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97800. */
  97801. autoClearDepthAndStencil: boolean;
  97802. /**
  97803. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97804. */
  97805. clearColor: Color4;
  97806. /**
  97807. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97808. */
  97809. ambientColor: Color3;
  97810. /**
  97811. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97812. * It should only be one of the following (if not the default embedded one):
  97813. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97814. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97815. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97816. * The material properties need to be setup according to the type of texture in use.
  97817. */
  97818. environmentBRDFTexture: BaseTexture;
  97819. /** @hidden */
  97820. protected _environmentTexture: Nullable<BaseTexture>;
  97821. /**
  97822. * Texture used in all pbr material as the reflection texture.
  97823. * As in the majority of the scene they are the same (exception for multi room and so on),
  97824. * this is easier to reference from here than from all the materials.
  97825. */
  97826. /**
  97827. * Texture used in all pbr material as the reflection texture.
  97828. * As in the majority of the scene they are the same (exception for multi room and so on),
  97829. * this is easier to set here than in all the materials.
  97830. */
  97831. environmentTexture: Nullable<BaseTexture>;
  97832. /** @hidden */
  97833. protected _environmentIntensity: number;
  97834. /**
  97835. * Intensity of the environment in all pbr material.
  97836. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97837. * As in the majority of the scene they are the same (exception for multi room and so on),
  97838. * this is easier to reference from here than from all the materials.
  97839. */
  97840. /**
  97841. * Intensity of the environment in all pbr material.
  97842. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97843. * As in the majority of the scene they are the same (exception for multi room and so on),
  97844. * this is easier to set here than in all the materials.
  97845. */
  97846. environmentIntensity: number;
  97847. /** @hidden */
  97848. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97849. /**
  97850. * Default image processing configuration used either in the rendering
  97851. * Forward main pass or through the imageProcessingPostProcess if present.
  97852. * As in the majority of the scene they are the same (exception for multi camera),
  97853. * this is easier to reference from here than from all the materials and post process.
  97854. *
  97855. * No setter as we it is a shared configuration, you can set the values instead.
  97856. */
  97857. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97858. private _forceWireframe;
  97859. /**
  97860. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97861. */
  97862. forceWireframe: boolean;
  97863. private _forcePointsCloud;
  97864. /**
  97865. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97866. */
  97867. forcePointsCloud: boolean;
  97868. /**
  97869. * Gets or sets the active clipplane 1
  97870. */
  97871. clipPlane: Nullable<Plane>;
  97872. /**
  97873. * Gets or sets the active clipplane 2
  97874. */
  97875. clipPlane2: Nullable<Plane>;
  97876. /**
  97877. * Gets or sets the active clipplane 3
  97878. */
  97879. clipPlane3: Nullable<Plane>;
  97880. /**
  97881. * Gets or sets the active clipplane 4
  97882. */
  97883. clipPlane4: Nullable<Plane>;
  97884. /**
  97885. * Gets or sets a boolean indicating if animations are enabled
  97886. */
  97887. animationsEnabled: boolean;
  97888. private _animationPropertiesOverride;
  97889. /**
  97890. * Gets or sets the animation properties override
  97891. */
  97892. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97893. /**
  97894. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97895. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97896. */
  97897. useConstantAnimationDeltaTime: boolean;
  97898. /**
  97899. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97900. * Please note that it requires to run a ray cast through the scene on every frame
  97901. */
  97902. constantlyUpdateMeshUnderPointer: boolean;
  97903. /**
  97904. * Defines the HTML cursor to use when hovering over interactive elements
  97905. */
  97906. hoverCursor: string;
  97907. /**
  97908. * Defines the HTML default cursor to use (empty by default)
  97909. */
  97910. defaultCursor: string;
  97911. /**
  97912. * This is used to call preventDefault() on pointer down
  97913. * in order to block unwanted artifacts like system double clicks
  97914. */
  97915. preventDefaultOnPointerDown: boolean;
  97916. /**
  97917. * This is used to call preventDefault() on pointer up
  97918. * in order to block unwanted artifacts like system double clicks
  97919. */
  97920. preventDefaultOnPointerUp: boolean;
  97921. /**
  97922. * Gets or sets user defined metadata
  97923. */
  97924. metadata: any;
  97925. /**
  97926. * For internal use only. Please do not use.
  97927. */
  97928. reservedDataStore: any;
  97929. /**
  97930. * Gets the name of the plugin used to load this scene (null by default)
  97931. */
  97932. loadingPluginName: string;
  97933. /**
  97934. * Use this array to add regular expressions used to disable offline support for specific urls
  97935. */
  97936. disableOfflineSupportExceptionRules: RegExp[];
  97937. /**
  97938. * An event triggered when the scene is disposed.
  97939. */
  97940. onDisposeObservable: Observable<Scene>;
  97941. private _onDisposeObserver;
  97942. /** Sets a function to be executed when this scene is disposed. */
  97943. onDispose: () => void;
  97944. /**
  97945. * An event triggered before rendering the scene (right after animations and physics)
  97946. */
  97947. onBeforeRenderObservable: Observable<Scene>;
  97948. private _onBeforeRenderObserver;
  97949. /** Sets a function to be executed before rendering this scene */
  97950. beforeRender: Nullable<() => void>;
  97951. /**
  97952. * An event triggered after rendering the scene
  97953. */
  97954. onAfterRenderObservable: Observable<Scene>;
  97955. /**
  97956. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97957. */
  97958. onAfterRenderCameraObservable: Observable<Camera>;
  97959. private _onAfterRenderObserver;
  97960. /** Sets a function to be executed after rendering this scene */
  97961. afterRender: Nullable<() => void>;
  97962. /**
  97963. * An event triggered before animating the scene
  97964. */
  97965. onBeforeAnimationsObservable: Observable<Scene>;
  97966. /**
  97967. * An event triggered after animations processing
  97968. */
  97969. onAfterAnimationsObservable: Observable<Scene>;
  97970. /**
  97971. * An event triggered before draw calls are ready to be sent
  97972. */
  97973. onBeforeDrawPhaseObservable: Observable<Scene>;
  97974. /**
  97975. * An event triggered after draw calls have been sent
  97976. */
  97977. onAfterDrawPhaseObservable: Observable<Scene>;
  97978. /**
  97979. * An event triggered when the scene is ready
  97980. */
  97981. onReadyObservable: Observable<Scene>;
  97982. /**
  97983. * An event triggered before rendering a camera
  97984. */
  97985. onBeforeCameraRenderObservable: Observable<Camera>;
  97986. private _onBeforeCameraRenderObserver;
  97987. /** Sets a function to be executed before rendering a camera*/
  97988. beforeCameraRender: () => void;
  97989. /**
  97990. * An event triggered after rendering a camera
  97991. */
  97992. onAfterCameraRenderObservable: Observable<Camera>;
  97993. private _onAfterCameraRenderObserver;
  97994. /** Sets a function to be executed after rendering a camera*/
  97995. afterCameraRender: () => void;
  97996. /**
  97997. * An event triggered when active meshes evaluation is about to start
  97998. */
  97999. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98000. /**
  98001. * An event triggered when active meshes evaluation is done
  98002. */
  98003. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98004. /**
  98005. * An event triggered when particles rendering is about to start
  98006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98007. */
  98008. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98009. /**
  98010. * An event triggered when particles rendering is done
  98011. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98012. */
  98013. onAfterParticlesRenderingObservable: Observable<Scene>;
  98014. /**
  98015. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98016. */
  98017. onDataLoadedObservable: Observable<Scene>;
  98018. /**
  98019. * An event triggered when a camera is created
  98020. */
  98021. onNewCameraAddedObservable: Observable<Camera>;
  98022. /**
  98023. * An event triggered when a camera is removed
  98024. */
  98025. onCameraRemovedObservable: Observable<Camera>;
  98026. /**
  98027. * An event triggered when a light is created
  98028. */
  98029. onNewLightAddedObservable: Observable<Light>;
  98030. /**
  98031. * An event triggered when a light is removed
  98032. */
  98033. onLightRemovedObservable: Observable<Light>;
  98034. /**
  98035. * An event triggered when a geometry is created
  98036. */
  98037. onNewGeometryAddedObservable: Observable<Geometry>;
  98038. /**
  98039. * An event triggered when a geometry is removed
  98040. */
  98041. onGeometryRemovedObservable: Observable<Geometry>;
  98042. /**
  98043. * An event triggered when a transform node is created
  98044. */
  98045. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98046. /**
  98047. * An event triggered when a transform node is removed
  98048. */
  98049. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98050. /**
  98051. * An event triggered when a mesh is created
  98052. */
  98053. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98054. /**
  98055. * An event triggered when a mesh is removed
  98056. */
  98057. onMeshRemovedObservable: Observable<AbstractMesh>;
  98058. /**
  98059. * An event triggered when a skeleton is created
  98060. */
  98061. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98062. /**
  98063. * An event triggered when a skeleton is removed
  98064. */
  98065. onSkeletonRemovedObservable: Observable<Skeleton>;
  98066. /**
  98067. * An event triggered when a material is created
  98068. */
  98069. onNewMaterialAddedObservable: Observable<Material>;
  98070. /**
  98071. * An event triggered when a material is removed
  98072. */
  98073. onMaterialRemovedObservable: Observable<Material>;
  98074. /**
  98075. * An event triggered when a texture is created
  98076. */
  98077. onNewTextureAddedObservable: Observable<BaseTexture>;
  98078. /**
  98079. * An event triggered when a texture is removed
  98080. */
  98081. onTextureRemovedObservable: Observable<BaseTexture>;
  98082. /**
  98083. * An event triggered when render targets are about to be rendered
  98084. * Can happen multiple times per frame.
  98085. */
  98086. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98087. /**
  98088. * An event triggered when render targets were rendered.
  98089. * Can happen multiple times per frame.
  98090. */
  98091. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98092. /**
  98093. * An event triggered before calculating deterministic simulation step
  98094. */
  98095. onBeforeStepObservable: Observable<Scene>;
  98096. /**
  98097. * An event triggered after calculating deterministic simulation step
  98098. */
  98099. onAfterStepObservable: Observable<Scene>;
  98100. /**
  98101. * An event triggered when the activeCamera property is updated
  98102. */
  98103. onActiveCameraChanged: Observable<Scene>;
  98104. /**
  98105. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98106. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98107. * 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)
  98108. */
  98109. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98110. /**
  98111. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98112. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98113. * 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)
  98114. */
  98115. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98116. /**
  98117. * This Observable will when a mesh has been imported into the scene.
  98118. */
  98119. onMeshImportedObservable: Observable<AbstractMesh>;
  98120. /**
  98121. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98122. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98123. */
  98124. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98125. /** @hidden */
  98126. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98127. /**
  98128. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98129. */
  98130. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98131. /**
  98132. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98133. */
  98134. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98135. /**
  98136. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98137. */
  98138. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98139. /** Callback called when a pointer move is detected */
  98140. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98141. /** Callback called when a pointer down is detected */
  98142. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98143. /** Callback called when a pointer up is detected */
  98144. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98145. /** Callback called when a pointer pick is detected */
  98146. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98147. /**
  98148. * 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).
  98149. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98150. */
  98151. onPrePointerObservable: Observable<PointerInfoPre>;
  98152. /**
  98153. * Observable event triggered each time an input event is received from the rendering canvas
  98154. */
  98155. onPointerObservable: Observable<PointerInfo>;
  98156. /**
  98157. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98158. */
  98159. readonly unTranslatedPointer: Vector2;
  98160. /**
  98161. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98162. */
  98163. static DragMovementThreshold: number;
  98164. /**
  98165. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98166. */
  98167. static LongPressDelay: number;
  98168. /**
  98169. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98170. */
  98171. static DoubleClickDelay: number;
  98172. /** If you need to check double click without raising a single click at first click, enable this flag */
  98173. static ExclusiveDoubleClickMode: boolean;
  98174. /** @hidden */
  98175. _mirroredCameraPosition: Nullable<Vector3>;
  98176. /**
  98177. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98178. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98179. */
  98180. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98181. /**
  98182. * Observable event triggered each time an keyboard event is received from the hosting window
  98183. */
  98184. onKeyboardObservable: Observable<KeyboardInfo>;
  98185. private _useRightHandedSystem;
  98186. /**
  98187. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98188. */
  98189. useRightHandedSystem: boolean;
  98190. private _timeAccumulator;
  98191. private _currentStepId;
  98192. private _currentInternalStep;
  98193. /**
  98194. * Sets the step Id used by deterministic lock step
  98195. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98196. * @param newStepId defines the step Id
  98197. */
  98198. setStepId(newStepId: number): void;
  98199. /**
  98200. * Gets the step Id used by deterministic lock step
  98201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98202. * @returns the step Id
  98203. */
  98204. getStepId(): number;
  98205. /**
  98206. * Gets the internal step used by deterministic lock step
  98207. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98208. * @returns the internal step
  98209. */
  98210. getInternalStep(): number;
  98211. private _fogEnabled;
  98212. /**
  98213. * Gets or sets a boolean indicating if fog is enabled on this scene
  98214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98215. * (Default is true)
  98216. */
  98217. fogEnabled: boolean;
  98218. private _fogMode;
  98219. /**
  98220. * Gets or sets the fog mode to use
  98221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98222. * | mode | value |
  98223. * | --- | --- |
  98224. * | FOGMODE_NONE | 0 |
  98225. * | FOGMODE_EXP | 1 |
  98226. * | FOGMODE_EXP2 | 2 |
  98227. * | FOGMODE_LINEAR | 3 |
  98228. */
  98229. fogMode: number;
  98230. /**
  98231. * Gets or sets the fog color to use
  98232. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98233. * (Default is Color3(0.2, 0.2, 0.3))
  98234. */
  98235. fogColor: Color3;
  98236. /**
  98237. * Gets or sets the fog density to use
  98238. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98239. * (Default is 0.1)
  98240. */
  98241. fogDensity: number;
  98242. /**
  98243. * Gets or sets the fog start distance to use
  98244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98245. * (Default is 0)
  98246. */
  98247. fogStart: number;
  98248. /**
  98249. * Gets or sets the fog end distance to use
  98250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98251. * (Default is 1000)
  98252. */
  98253. fogEnd: number;
  98254. private _shadowsEnabled;
  98255. /**
  98256. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98257. */
  98258. shadowsEnabled: boolean;
  98259. private _lightsEnabled;
  98260. /**
  98261. * Gets or sets a boolean indicating if lights are enabled on this scene
  98262. */
  98263. lightsEnabled: boolean;
  98264. /** All of the active cameras added to this scene. */
  98265. activeCameras: Camera[];
  98266. /** @hidden */
  98267. _activeCamera: Nullable<Camera>;
  98268. /** Gets or sets the current active camera */
  98269. activeCamera: Nullable<Camera>;
  98270. private _defaultMaterial;
  98271. /** The default material used on meshes when no material is affected */
  98272. /** The default material used on meshes when no material is affected */
  98273. defaultMaterial: Material;
  98274. private _texturesEnabled;
  98275. /**
  98276. * Gets or sets a boolean indicating if textures are enabled on this scene
  98277. */
  98278. texturesEnabled: boolean;
  98279. /**
  98280. * Gets or sets a boolean indicating if particles are enabled on this scene
  98281. */
  98282. particlesEnabled: boolean;
  98283. /**
  98284. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98285. */
  98286. spritesEnabled: boolean;
  98287. private _skeletonsEnabled;
  98288. /**
  98289. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98290. */
  98291. skeletonsEnabled: boolean;
  98292. /**
  98293. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98294. */
  98295. lensFlaresEnabled: boolean;
  98296. /**
  98297. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98298. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98299. */
  98300. collisionsEnabled: boolean;
  98301. private _collisionCoordinator;
  98302. /** @hidden */
  98303. readonly collisionCoordinator: ICollisionCoordinator;
  98304. /**
  98305. * Defines the gravity applied to this scene (used only for collisions)
  98306. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98307. */
  98308. gravity: Vector3;
  98309. /**
  98310. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98311. */
  98312. postProcessesEnabled: boolean;
  98313. /**
  98314. * The list of postprocesses added to the scene
  98315. */
  98316. postProcesses: PostProcess[];
  98317. /**
  98318. * Gets the current postprocess manager
  98319. */
  98320. postProcessManager: PostProcessManager;
  98321. /**
  98322. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98323. */
  98324. renderTargetsEnabled: boolean;
  98325. /**
  98326. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98327. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98328. */
  98329. dumpNextRenderTargets: boolean;
  98330. /**
  98331. * The list of user defined render targets added to the scene
  98332. */
  98333. customRenderTargets: RenderTargetTexture[];
  98334. /**
  98335. * Defines if texture loading must be delayed
  98336. * If true, textures will only be loaded when they need to be rendered
  98337. */
  98338. useDelayedTextureLoading: boolean;
  98339. /**
  98340. * Gets the list of meshes imported to the scene through SceneLoader
  98341. */
  98342. importedMeshesFiles: String[];
  98343. /**
  98344. * Gets or sets a boolean indicating if probes are enabled on this scene
  98345. */
  98346. probesEnabled: boolean;
  98347. /**
  98348. * Gets or sets the current offline provider to use to store scene data
  98349. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98350. */
  98351. offlineProvider: IOfflineProvider;
  98352. /**
  98353. * Gets or sets the action manager associated with the scene
  98354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98355. */
  98356. actionManager: AbstractActionManager;
  98357. private _meshesForIntersections;
  98358. /**
  98359. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98360. */
  98361. proceduralTexturesEnabled: boolean;
  98362. private _engine;
  98363. private _totalVertices;
  98364. /** @hidden */
  98365. _activeIndices: PerfCounter;
  98366. /** @hidden */
  98367. _activeParticles: PerfCounter;
  98368. /** @hidden */
  98369. _activeBones: PerfCounter;
  98370. private _animationRatio;
  98371. /** @hidden */
  98372. _animationTimeLast: number;
  98373. /** @hidden */
  98374. _animationTime: number;
  98375. /**
  98376. * Gets or sets a general scale for animation speed
  98377. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98378. */
  98379. animationTimeScale: number;
  98380. /** @hidden */
  98381. _cachedMaterial: Nullable<Material>;
  98382. /** @hidden */
  98383. _cachedEffect: Nullable<Effect>;
  98384. /** @hidden */
  98385. _cachedVisibility: Nullable<number>;
  98386. private _renderId;
  98387. private _frameId;
  98388. private _executeWhenReadyTimeoutId;
  98389. private _intermediateRendering;
  98390. private _viewUpdateFlag;
  98391. private _projectionUpdateFlag;
  98392. /** @hidden */
  98393. _toBeDisposed: Nullable<IDisposable>[];
  98394. private _activeRequests;
  98395. /** @hidden */
  98396. _pendingData: any[];
  98397. private _isDisposed;
  98398. /**
  98399. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98400. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98401. */
  98402. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98403. private _activeMeshes;
  98404. private _processedMaterials;
  98405. private _renderTargets;
  98406. /** @hidden */
  98407. _activeParticleSystems: SmartArray<IParticleSystem>;
  98408. private _activeSkeletons;
  98409. private _softwareSkinnedMeshes;
  98410. private _renderingManager;
  98411. /** @hidden */
  98412. _activeAnimatables: Animatable[];
  98413. private _transformMatrix;
  98414. private _sceneUbo;
  98415. /** @hidden */
  98416. _viewMatrix: Matrix;
  98417. private _projectionMatrix;
  98418. /** @hidden */
  98419. _forcedViewPosition: Nullable<Vector3>;
  98420. /** @hidden */
  98421. _frustumPlanes: Plane[];
  98422. /**
  98423. * Gets the list of frustum planes (built from the active camera)
  98424. */
  98425. readonly frustumPlanes: Plane[];
  98426. /**
  98427. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98428. * This is useful if there are more lights that the maximum simulteanous authorized
  98429. */
  98430. requireLightSorting: boolean;
  98431. /** @hidden */
  98432. readonly useMaterialMeshMap: boolean;
  98433. /** @hidden */
  98434. readonly useClonedMeshhMap: boolean;
  98435. private _externalData;
  98436. private _uid;
  98437. /**
  98438. * @hidden
  98439. * Backing store of defined scene components.
  98440. */
  98441. _components: ISceneComponent[];
  98442. /**
  98443. * @hidden
  98444. * Backing store of defined scene components.
  98445. */
  98446. _serializableComponents: ISceneSerializableComponent[];
  98447. /**
  98448. * List of components to register on the next registration step.
  98449. */
  98450. private _transientComponents;
  98451. /**
  98452. * Registers the transient components if needed.
  98453. */
  98454. private _registerTransientComponents;
  98455. /**
  98456. * @hidden
  98457. * Add a component to the scene.
  98458. * Note that the ccomponent could be registered on th next frame if this is called after
  98459. * the register component stage.
  98460. * @param component Defines the component to add to the scene
  98461. */
  98462. _addComponent(component: ISceneComponent): void;
  98463. /**
  98464. * @hidden
  98465. * Gets a component from the scene.
  98466. * @param name defines the name of the component to retrieve
  98467. * @returns the component or null if not present
  98468. */
  98469. _getComponent(name: string): Nullable<ISceneComponent>;
  98470. /**
  98471. * @hidden
  98472. * Defines the actions happening before camera updates.
  98473. */
  98474. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98475. /**
  98476. * @hidden
  98477. * Defines the actions happening before clear the canvas.
  98478. */
  98479. _beforeClearStage: Stage<SimpleStageAction>;
  98480. /**
  98481. * @hidden
  98482. * Defines the actions when collecting render targets for the frame.
  98483. */
  98484. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98485. /**
  98486. * @hidden
  98487. * Defines the actions happening for one camera in the frame.
  98488. */
  98489. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98490. /**
  98491. * @hidden
  98492. * Defines the actions happening during the per mesh ready checks.
  98493. */
  98494. _isReadyForMeshStage: Stage<MeshStageAction>;
  98495. /**
  98496. * @hidden
  98497. * Defines the actions happening before evaluate active mesh checks.
  98498. */
  98499. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98500. /**
  98501. * @hidden
  98502. * Defines the actions happening during the evaluate sub mesh checks.
  98503. */
  98504. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98505. /**
  98506. * @hidden
  98507. * Defines the actions happening during the active mesh stage.
  98508. */
  98509. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98510. /**
  98511. * @hidden
  98512. * Defines the actions happening during the per camera render target step.
  98513. */
  98514. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98515. /**
  98516. * @hidden
  98517. * Defines the actions happening just before the active camera is drawing.
  98518. */
  98519. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98520. /**
  98521. * @hidden
  98522. * Defines the actions happening just before a render target is drawing.
  98523. */
  98524. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98525. /**
  98526. * @hidden
  98527. * Defines the actions happening just before a rendering group is drawing.
  98528. */
  98529. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98530. /**
  98531. * @hidden
  98532. * Defines the actions happening just before a mesh is drawing.
  98533. */
  98534. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98535. /**
  98536. * @hidden
  98537. * Defines the actions happening just after a mesh has been drawn.
  98538. */
  98539. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98540. /**
  98541. * @hidden
  98542. * Defines the actions happening just after a rendering group has been drawn.
  98543. */
  98544. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98545. /**
  98546. * @hidden
  98547. * Defines the actions happening just after the active camera has been drawn.
  98548. */
  98549. _afterCameraDrawStage: Stage<CameraStageAction>;
  98550. /**
  98551. * @hidden
  98552. * Defines the actions happening just after a render target has been drawn.
  98553. */
  98554. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98555. /**
  98556. * @hidden
  98557. * Defines the actions happening just after rendering all cameras and computing intersections.
  98558. */
  98559. _afterRenderStage: Stage<SimpleStageAction>;
  98560. /**
  98561. * @hidden
  98562. * Defines the actions happening when a pointer move event happens.
  98563. */
  98564. _pointerMoveStage: Stage<PointerMoveStageAction>;
  98565. /**
  98566. * @hidden
  98567. * Defines the actions happening when a pointer down event happens.
  98568. */
  98569. _pointerDownStage: Stage<PointerUpDownStageAction>;
  98570. /**
  98571. * @hidden
  98572. * Defines the actions happening when a pointer up event happens.
  98573. */
  98574. _pointerUpStage: Stage<PointerUpDownStageAction>;
  98575. /**
  98576. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  98577. */
  98578. private geometriesByUniqueId;
  98579. /**
  98580. * Creates a new Scene
  98581. * @param engine defines the engine to use to render this scene
  98582. * @param options defines the scene options
  98583. */
  98584. constructor(engine: Engine, options?: SceneOptions);
  98585. /**
  98586. * Gets a string idenfifying the name of the class
  98587. * @returns "Scene" string
  98588. */
  98589. getClassName(): string;
  98590. private _defaultMeshCandidates;
  98591. /**
  98592. * @hidden
  98593. */
  98594. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98595. private _defaultSubMeshCandidates;
  98596. /**
  98597. * @hidden
  98598. */
  98599. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98600. /**
  98601. * Sets the default candidate providers for the scene.
  98602. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98603. * and getCollidingSubMeshCandidates to their default function
  98604. */
  98605. setDefaultCandidateProviders(): void;
  98606. /**
  98607. * Gets the mesh that is currently under the pointer
  98608. */
  98609. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98610. /**
  98611. * Gets or sets the current on-screen X position of the pointer
  98612. */
  98613. pointerX: number;
  98614. /**
  98615. * Gets or sets the current on-screen Y position of the pointer
  98616. */
  98617. pointerY: number;
  98618. /**
  98619. * Gets the cached material (ie. the latest rendered one)
  98620. * @returns the cached material
  98621. */
  98622. getCachedMaterial(): Nullable<Material>;
  98623. /**
  98624. * Gets the cached effect (ie. the latest rendered one)
  98625. * @returns the cached effect
  98626. */
  98627. getCachedEffect(): Nullable<Effect>;
  98628. /**
  98629. * Gets the cached visibility state (ie. the latest rendered one)
  98630. * @returns the cached visibility state
  98631. */
  98632. getCachedVisibility(): Nullable<number>;
  98633. /**
  98634. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98635. * @param material defines the current material
  98636. * @param effect defines the current effect
  98637. * @param visibility defines the current visibility state
  98638. * @returns true if one parameter is not cached
  98639. */
  98640. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98641. /**
  98642. * Gets the engine associated with the scene
  98643. * @returns an Engine
  98644. */
  98645. getEngine(): Engine;
  98646. /**
  98647. * Gets the total number of vertices rendered per frame
  98648. * @returns the total number of vertices rendered per frame
  98649. */
  98650. getTotalVertices(): number;
  98651. /**
  98652. * Gets the performance counter for total vertices
  98653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98654. */
  98655. readonly totalVerticesPerfCounter: PerfCounter;
  98656. /**
  98657. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98658. * @returns the total number of active indices rendered per frame
  98659. */
  98660. getActiveIndices(): number;
  98661. /**
  98662. * Gets the performance counter for active indices
  98663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98664. */
  98665. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98666. /**
  98667. * Gets the total number of active particles rendered per frame
  98668. * @returns the total number of active particles rendered per frame
  98669. */
  98670. getActiveParticles(): number;
  98671. /**
  98672. * Gets the performance counter for active particles
  98673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98674. */
  98675. readonly activeParticlesPerfCounter: PerfCounter;
  98676. /**
  98677. * Gets the total number of active bones rendered per frame
  98678. * @returns the total number of active bones rendered per frame
  98679. */
  98680. getActiveBones(): number;
  98681. /**
  98682. * Gets the performance counter for active bones
  98683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98684. */
  98685. readonly activeBonesPerfCounter: PerfCounter;
  98686. /**
  98687. * Gets the array of active meshes
  98688. * @returns an array of AbstractMesh
  98689. */
  98690. getActiveMeshes(): SmartArray<AbstractMesh>;
  98691. /**
  98692. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98693. * @returns a number
  98694. */
  98695. getAnimationRatio(): number;
  98696. /**
  98697. * Gets an unique Id for the current render phase
  98698. * @returns a number
  98699. */
  98700. getRenderId(): number;
  98701. /**
  98702. * Gets an unique Id for the current frame
  98703. * @returns a number
  98704. */
  98705. getFrameId(): number;
  98706. /** Call this function if you want to manually increment the render Id*/
  98707. incrementRenderId(): void;
  98708. private _createUbo;
  98709. /**
  98710. * Use this method to simulate a pointer move on a mesh
  98711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98714. * @returns the current scene
  98715. */
  98716. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98717. /**
  98718. * Use this method to simulate a pointer down on a mesh
  98719. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98720. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98721. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98722. * @returns the current scene
  98723. */
  98724. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98725. /**
  98726. * Use this method to simulate a pointer up on a mesh
  98727. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98728. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98729. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98730. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98731. * @returns the current scene
  98732. */
  98733. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98734. /**
  98735. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98736. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98737. * @returns true if the pointer was captured
  98738. */
  98739. isPointerCaptured(pointerId?: number): boolean;
  98740. /**
  98741. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98742. * @param attachUp defines if you want to attach events to pointerup
  98743. * @param attachDown defines if you want to attach events to pointerdown
  98744. * @param attachMove defines if you want to attach events to pointermove
  98745. */
  98746. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98747. /** Detaches all event handlers*/
  98748. detachControl(): void;
  98749. /**
  98750. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98751. * Delay loaded resources are not taking in account
  98752. * @return true if all required resources are ready
  98753. */
  98754. isReady(): boolean;
  98755. /** Resets all cached information relative to material (including effect and visibility) */
  98756. resetCachedMaterial(): void;
  98757. /**
  98758. * Registers a function to be called before every frame render
  98759. * @param func defines the function to register
  98760. */
  98761. registerBeforeRender(func: () => void): void;
  98762. /**
  98763. * Unregisters a function called before every frame render
  98764. * @param func defines the function to unregister
  98765. */
  98766. unregisterBeforeRender(func: () => void): void;
  98767. /**
  98768. * Registers a function to be called after every frame render
  98769. * @param func defines the function to register
  98770. */
  98771. registerAfterRender(func: () => void): void;
  98772. /**
  98773. * Unregisters a function called after every frame render
  98774. * @param func defines the function to unregister
  98775. */
  98776. unregisterAfterRender(func: () => void): void;
  98777. private _executeOnceBeforeRender;
  98778. /**
  98779. * The provided function will run before render once and will be disposed afterwards.
  98780. * A timeout delay can be provided so that the function will be executed in N ms.
  98781. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98782. * @param func The function to be executed.
  98783. * @param timeout optional delay in ms
  98784. */
  98785. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98786. /** @hidden */
  98787. _addPendingData(data: any): void;
  98788. /** @hidden */
  98789. _removePendingData(data: any): void;
  98790. /**
  98791. * Returns the number of items waiting to be loaded
  98792. * @returns the number of items waiting to be loaded
  98793. */
  98794. getWaitingItemsCount(): number;
  98795. /**
  98796. * Returns a boolean indicating if the scene is still loading data
  98797. */
  98798. readonly isLoading: boolean;
  98799. /**
  98800. * Registers a function to be executed when the scene is ready
  98801. * @param {Function} func - the function to be executed
  98802. */
  98803. executeWhenReady(func: () => void): void;
  98804. /**
  98805. * Returns a promise that resolves when the scene is ready
  98806. * @returns A promise that resolves when the scene is ready
  98807. */
  98808. whenReadyAsync(): Promise<void>;
  98809. /** @hidden */
  98810. _checkIsReady(): void;
  98811. /**
  98812. * Gets all animatable attached to the scene
  98813. */
  98814. readonly animatables: Animatable[];
  98815. /**
  98816. * Resets the last animation time frame.
  98817. * Useful to override when animations start running when loading a scene for the first time.
  98818. */
  98819. resetLastAnimationTimeFrame(): void;
  98820. /**
  98821. * Gets the current view matrix
  98822. * @returns a Matrix
  98823. */
  98824. getViewMatrix(): Matrix;
  98825. /**
  98826. * Gets the current projection matrix
  98827. * @returns a Matrix
  98828. */
  98829. getProjectionMatrix(): Matrix;
  98830. /**
  98831. * Gets the current transform matrix
  98832. * @returns a Matrix made of View * Projection
  98833. */
  98834. getTransformMatrix(): Matrix;
  98835. /**
  98836. * Sets the current transform matrix
  98837. * @param viewL defines the View matrix to use
  98838. * @param projectionL defines the Projection matrix to use
  98839. * @param viewR defines the right View matrix to use (if provided)
  98840. * @param projectionR defines the right Projection matrix to use (if provided)
  98841. */
  98842. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98843. /**
  98844. * Gets the uniform buffer used to store scene data
  98845. * @returns a UniformBuffer
  98846. */
  98847. getSceneUniformBuffer(): UniformBuffer;
  98848. /**
  98849. * Gets an unique (relatively to the current scene) Id
  98850. * @returns an unique number for the scene
  98851. */
  98852. getUniqueId(): number;
  98853. /**
  98854. * Add a mesh to the list of scene's meshes
  98855. * @param newMesh defines the mesh to add
  98856. * @param recursive if all child meshes should also be added to the scene
  98857. */
  98858. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98859. /**
  98860. * Remove a mesh for the list of scene's meshes
  98861. * @param toRemove defines the mesh to remove
  98862. * @param recursive if all child meshes should also be removed from the scene
  98863. * @returns the index where the mesh was in the mesh list
  98864. */
  98865. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98866. /**
  98867. * Add a transform node to the list of scene's transform nodes
  98868. * @param newTransformNode defines the transform node to add
  98869. */
  98870. addTransformNode(newTransformNode: TransformNode): void;
  98871. /**
  98872. * Remove a transform node for the list of scene's transform nodes
  98873. * @param toRemove defines the transform node to remove
  98874. * @returns the index where the transform node was in the transform node list
  98875. */
  98876. removeTransformNode(toRemove: TransformNode): number;
  98877. /**
  98878. * Remove a skeleton for the list of scene's skeletons
  98879. * @param toRemove defines the skeleton to remove
  98880. * @returns the index where the skeleton was in the skeleton list
  98881. */
  98882. removeSkeleton(toRemove: Skeleton): number;
  98883. /**
  98884. * Remove a morph target for the list of scene's morph targets
  98885. * @param toRemove defines the morph target to remove
  98886. * @returns the index where the morph target was in the morph target list
  98887. */
  98888. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98889. /**
  98890. * Remove a light for the list of scene's lights
  98891. * @param toRemove defines the light to remove
  98892. * @returns the index where the light was in the light list
  98893. */
  98894. removeLight(toRemove: Light): number;
  98895. /**
  98896. * Remove a camera for the list of scene's cameras
  98897. * @param toRemove defines the camera to remove
  98898. * @returns the index where the camera was in the camera list
  98899. */
  98900. removeCamera(toRemove: Camera): number;
  98901. /**
  98902. * Remove a particle system for the list of scene's particle systems
  98903. * @param toRemove defines the particle system to remove
  98904. * @returns the index where the particle system was in the particle system list
  98905. */
  98906. removeParticleSystem(toRemove: IParticleSystem): number;
  98907. /**
  98908. * Remove a animation for the list of scene's animations
  98909. * @param toRemove defines the animation to remove
  98910. * @returns the index where the animation was in the animation list
  98911. */
  98912. removeAnimation(toRemove: Animation): number;
  98913. /**
  98914. * Will stop the animation of the given target
  98915. * @param target - the target
  98916. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98917. * @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)
  98918. */
  98919. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98920. /**
  98921. * Removes the given animation group from this scene.
  98922. * @param toRemove The animation group to remove
  98923. * @returns The index of the removed animation group
  98924. */
  98925. removeAnimationGroup(toRemove: AnimationGroup): number;
  98926. /**
  98927. * Removes the given multi-material from this scene.
  98928. * @param toRemove The multi-material to remove
  98929. * @returns The index of the removed multi-material
  98930. */
  98931. removeMultiMaterial(toRemove: MultiMaterial): number;
  98932. /**
  98933. * Removes the given material from this scene.
  98934. * @param toRemove The material to remove
  98935. * @returns The index of the removed material
  98936. */
  98937. removeMaterial(toRemove: Material): number;
  98938. /**
  98939. * Removes the given action manager from this scene.
  98940. * @param toRemove The action manager to remove
  98941. * @returns The index of the removed action manager
  98942. */
  98943. removeActionManager(toRemove: AbstractActionManager): number;
  98944. /**
  98945. * Removes the given texture from this scene.
  98946. * @param toRemove The texture to remove
  98947. * @returns The index of the removed texture
  98948. */
  98949. removeTexture(toRemove: BaseTexture): number;
  98950. /**
  98951. * Adds the given light to this scene
  98952. * @param newLight The light to add
  98953. */
  98954. addLight(newLight: Light): void;
  98955. /**
  98956. * Sorts the list list based on light priorities
  98957. */
  98958. sortLightsByPriority(): void;
  98959. /**
  98960. * Adds the given camera to this scene
  98961. * @param newCamera The camera to add
  98962. */
  98963. addCamera(newCamera: Camera): void;
  98964. /**
  98965. * Adds the given skeleton to this scene
  98966. * @param newSkeleton The skeleton to add
  98967. */
  98968. addSkeleton(newSkeleton: Skeleton): void;
  98969. /**
  98970. * Adds the given particle system to this scene
  98971. * @param newParticleSystem The particle system to add
  98972. */
  98973. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98974. /**
  98975. * Adds the given animation to this scene
  98976. * @param newAnimation The animation to add
  98977. */
  98978. addAnimation(newAnimation: Animation): void;
  98979. /**
  98980. * Adds the given animation group to this scene.
  98981. * @param newAnimationGroup The animation group to add
  98982. */
  98983. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98984. /**
  98985. * Adds the given multi-material to this scene
  98986. * @param newMultiMaterial The multi-material to add
  98987. */
  98988. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98989. /**
  98990. * Adds the given material to this scene
  98991. * @param newMaterial The material to add
  98992. */
  98993. addMaterial(newMaterial: Material): void;
  98994. /**
  98995. * Adds the given morph target to this scene
  98996. * @param newMorphTargetManager The morph target to add
  98997. */
  98998. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98999. /**
  99000. * Adds the given geometry to this scene
  99001. * @param newGeometry The geometry to add
  99002. */
  99003. addGeometry(newGeometry: Geometry): void;
  99004. /**
  99005. * Adds the given action manager to this scene
  99006. * @param newActionManager The action manager to add
  99007. */
  99008. addActionManager(newActionManager: AbstractActionManager): void;
  99009. /**
  99010. * Adds the given texture to this scene.
  99011. * @param newTexture The texture to add
  99012. */
  99013. addTexture(newTexture: BaseTexture): void;
  99014. /**
  99015. * Switch active camera
  99016. * @param newCamera defines the new active camera
  99017. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99018. */
  99019. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99020. /**
  99021. * sets the active camera of the scene using its ID
  99022. * @param id defines the camera's ID
  99023. * @return the new active camera or null if none found.
  99024. */
  99025. setActiveCameraByID(id: string): Nullable<Camera>;
  99026. /**
  99027. * sets the active camera of the scene using its name
  99028. * @param name defines the camera's name
  99029. * @returns the new active camera or null if none found.
  99030. */
  99031. setActiveCameraByName(name: string): Nullable<Camera>;
  99032. /**
  99033. * get an animation group using its name
  99034. * @param name defines the material's name
  99035. * @return the animation group or null if none found.
  99036. */
  99037. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99038. /**
  99039. * Get a material using its unique id
  99040. * @param uniqueId defines the material's unique id
  99041. * @return the material or null if none found.
  99042. */
  99043. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99044. /**
  99045. * get a material using its id
  99046. * @param id defines the material's ID
  99047. * @return the material or null if none found.
  99048. */
  99049. getMaterialByID(id: string): Nullable<Material>;
  99050. /**
  99051. * Gets a the last added material using a given id
  99052. * @param id defines the material's ID
  99053. * @return the last material with the given id or null if none found.
  99054. */
  99055. getLastMaterialByID(id: string): Nullable<Material>;
  99056. /**
  99057. * Gets a material using its name
  99058. * @param name defines the material's name
  99059. * @return the material or null if none found.
  99060. */
  99061. getMaterialByName(name: string): Nullable<Material>;
  99062. /**
  99063. * Get a texture using its unique id
  99064. * @param uniqueId defines the texture's unique id
  99065. * @return the texture or null if none found.
  99066. */
  99067. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99068. /**
  99069. * Gets a camera using its id
  99070. * @param id defines the id to look for
  99071. * @returns the camera or null if not found
  99072. */
  99073. getCameraByID(id: string): Nullable<Camera>;
  99074. /**
  99075. * Gets a camera using its unique id
  99076. * @param uniqueId defines the unique id to look for
  99077. * @returns the camera or null if not found
  99078. */
  99079. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99080. /**
  99081. * Gets a camera using its name
  99082. * @param name defines the camera's name
  99083. * @return the camera or null if none found.
  99084. */
  99085. getCameraByName(name: string): Nullable<Camera>;
  99086. /**
  99087. * Gets a bone using its id
  99088. * @param id defines the bone's id
  99089. * @return the bone or null if not found
  99090. */
  99091. getBoneByID(id: string): Nullable<Bone>;
  99092. /**
  99093. * Gets a bone using its id
  99094. * @param name defines the bone's name
  99095. * @return the bone or null if not found
  99096. */
  99097. getBoneByName(name: string): Nullable<Bone>;
  99098. /**
  99099. * Gets a light node using its name
  99100. * @param name defines the the light's name
  99101. * @return the light or null if none found.
  99102. */
  99103. getLightByName(name: string): Nullable<Light>;
  99104. /**
  99105. * Gets a light node using its id
  99106. * @param id defines the light's id
  99107. * @return the light or null if none found.
  99108. */
  99109. getLightByID(id: string): Nullable<Light>;
  99110. /**
  99111. * Gets a light node using its scene-generated unique ID
  99112. * @param uniqueId defines the light's unique id
  99113. * @return the light or null if none found.
  99114. */
  99115. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99116. /**
  99117. * Gets a particle system by id
  99118. * @param id defines the particle system id
  99119. * @return the corresponding system or null if none found
  99120. */
  99121. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99122. /**
  99123. * Gets a geometry using its ID
  99124. * @param id defines the geometry's id
  99125. * @return the geometry or null if none found.
  99126. */
  99127. getGeometryByID(id: string): Nullable<Geometry>;
  99128. private _getGeometryByUniqueID;
  99129. /**
  99130. * Add a new geometry to this scene
  99131. * @param geometry defines the geometry to be added to the scene.
  99132. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99133. * @return a boolean defining if the geometry was added or not
  99134. */
  99135. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99136. /**
  99137. * Removes an existing geometry
  99138. * @param geometry defines the geometry to be removed from the scene
  99139. * @return a boolean defining if the geometry was removed or not
  99140. */
  99141. removeGeometry(geometry: Geometry): boolean;
  99142. /**
  99143. * Gets the list of geometries attached to the scene
  99144. * @returns an array of Geometry
  99145. */
  99146. getGeometries(): Geometry[];
  99147. /**
  99148. * Gets the first added mesh found of a given ID
  99149. * @param id defines the id to search for
  99150. * @return the mesh found or null if not found at all
  99151. */
  99152. getMeshByID(id: string): Nullable<AbstractMesh>;
  99153. /**
  99154. * Gets a list of meshes using their id
  99155. * @param id defines the id to search for
  99156. * @returns a list of meshes
  99157. */
  99158. getMeshesByID(id: string): Array<AbstractMesh>;
  99159. /**
  99160. * Gets the first added transform node found of a given ID
  99161. * @param id defines the id to search for
  99162. * @return the found transform node or null if not found at all.
  99163. */
  99164. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99165. /**
  99166. * Gets a transform node with its auto-generated unique id
  99167. * @param uniqueId efines the unique id to search for
  99168. * @return the found transform node or null if not found at all.
  99169. */
  99170. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99171. /**
  99172. * Gets a list of transform nodes using their id
  99173. * @param id defines the id to search for
  99174. * @returns a list of transform nodes
  99175. */
  99176. getTransformNodesByID(id: string): Array<TransformNode>;
  99177. /**
  99178. * Gets a mesh with its auto-generated unique id
  99179. * @param uniqueId defines the unique id to search for
  99180. * @return the found mesh or null if not found at all.
  99181. */
  99182. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99183. /**
  99184. * Gets a the last added mesh using a given id
  99185. * @param id defines the id to search for
  99186. * @return the found mesh or null if not found at all.
  99187. */
  99188. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99189. /**
  99190. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99191. * @param id defines the id to search for
  99192. * @return the found node or null if not found at all
  99193. */
  99194. getLastEntryByID(id: string): Nullable<Node>;
  99195. /**
  99196. * Gets a node (Mesh, Camera, Light) using a given id
  99197. * @param id defines the id to search for
  99198. * @return the found node or null if not found at all
  99199. */
  99200. getNodeByID(id: string): Nullable<Node>;
  99201. /**
  99202. * Gets a node (Mesh, Camera, Light) using a given name
  99203. * @param name defines the name to search for
  99204. * @return the found node or null if not found at all.
  99205. */
  99206. getNodeByName(name: string): Nullable<Node>;
  99207. /**
  99208. * Gets a mesh using a given name
  99209. * @param name defines the name to search for
  99210. * @return the found mesh or null if not found at all.
  99211. */
  99212. getMeshByName(name: string): Nullable<AbstractMesh>;
  99213. /**
  99214. * Gets a transform node using a given name
  99215. * @param name defines the name to search for
  99216. * @return the found transform node or null if not found at all.
  99217. */
  99218. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99219. /**
  99220. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99221. * @param id defines the id to search for
  99222. * @return the found skeleton or null if not found at all.
  99223. */
  99224. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99225. /**
  99226. * Gets a skeleton using a given auto generated unique id
  99227. * @param uniqueId defines the unique id to search for
  99228. * @return the found skeleton or null if not found at all.
  99229. */
  99230. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99231. /**
  99232. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99233. * @param id defines the id to search for
  99234. * @return the found skeleton or null if not found at all.
  99235. */
  99236. getSkeletonById(id: string): Nullable<Skeleton>;
  99237. /**
  99238. * Gets a skeleton using a given name
  99239. * @param name defines the name to search for
  99240. * @return the found skeleton or null if not found at all.
  99241. */
  99242. getSkeletonByName(name: string): Nullable<Skeleton>;
  99243. /**
  99244. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99245. * @param id defines the id to search for
  99246. * @return the found morph target manager or null if not found at all.
  99247. */
  99248. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99249. /**
  99250. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99251. * @param id defines the id to search for
  99252. * @return the found morph target or null if not found at all.
  99253. */
  99254. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99255. /**
  99256. * Gets a boolean indicating if the given mesh is active
  99257. * @param mesh defines the mesh to look for
  99258. * @returns true if the mesh is in the active list
  99259. */
  99260. isActiveMesh(mesh: AbstractMesh): boolean;
  99261. /**
  99262. * Return a unique id as a string which can serve as an identifier for the scene
  99263. */
  99264. readonly uid: string;
  99265. /**
  99266. * Add an externaly attached data from its key.
  99267. * This method call will fail and return false, if such key already exists.
  99268. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99269. * @param key the unique key that identifies the data
  99270. * @param data the data object to associate to the key for this Engine instance
  99271. * @return true if no such key were already present and the data was added successfully, false otherwise
  99272. */
  99273. addExternalData<T>(key: string, data: T): boolean;
  99274. /**
  99275. * Get an externaly attached data from its key
  99276. * @param key the unique key that identifies the data
  99277. * @return the associated data, if present (can be null), or undefined if not present
  99278. */
  99279. getExternalData<T>(key: string): Nullable<T>;
  99280. /**
  99281. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99282. * @param key the unique key that identifies the data
  99283. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99284. * @return the associated data, can be null if the factory returned null.
  99285. */
  99286. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99287. /**
  99288. * Remove an externaly attached data from the Engine instance
  99289. * @param key the unique key that identifies the data
  99290. * @return true if the data was successfully removed, false if it doesn't exist
  99291. */
  99292. removeExternalData(key: string): boolean;
  99293. private _evaluateSubMesh;
  99294. /**
  99295. * Clear the processed materials smart array preventing retention point in material dispose.
  99296. */
  99297. freeProcessedMaterials(): void;
  99298. private _preventFreeActiveMeshesAndRenderingGroups;
  99299. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99300. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99301. * when disposing several meshes in a row or a hierarchy of meshes.
  99302. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99303. */
  99304. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99305. /**
  99306. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99307. */
  99308. freeActiveMeshes(): void;
  99309. /**
  99310. * Clear the info related to rendering groups preventing retention points during dispose.
  99311. */
  99312. freeRenderingGroups(): void;
  99313. /** @hidden */
  99314. _isInIntermediateRendering(): boolean;
  99315. /**
  99316. * Lambda returning the list of potentially active meshes.
  99317. */
  99318. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99319. /**
  99320. * Lambda returning the list of potentially active sub meshes.
  99321. */
  99322. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99323. /**
  99324. * Lambda returning the list of potentially intersecting sub meshes.
  99325. */
  99326. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99327. /**
  99328. * Lambda returning the list of potentially colliding sub meshes.
  99329. */
  99330. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99331. private _activeMeshesFrozen;
  99332. /**
  99333. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99334. * @returns the current scene
  99335. */
  99336. freezeActiveMeshes(): Scene;
  99337. /**
  99338. * Use this function to restart evaluating active meshes on every frame
  99339. * @returns the current scene
  99340. */
  99341. unfreezeActiveMeshes(): Scene;
  99342. private _evaluateActiveMeshes;
  99343. private _activeMesh;
  99344. /**
  99345. * Update the transform matrix to update from the current active camera
  99346. * @param force defines a boolean used to force the update even if cache is up to date
  99347. */
  99348. updateTransformMatrix(force?: boolean): void;
  99349. private _bindFrameBuffer;
  99350. /** @hidden */
  99351. _allowPostProcessClearColor: boolean;
  99352. /** @hidden */
  99353. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99354. private _processSubCameras;
  99355. private _checkIntersections;
  99356. /** @hidden */
  99357. _advancePhysicsEngineStep(step: number): void;
  99358. /**
  99359. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99360. */
  99361. getDeterministicFrameTime: () => number;
  99362. /** @hidden */
  99363. _animate(): void;
  99364. /** Execute all animations (for a frame) */
  99365. animate(): void;
  99366. /**
  99367. * Render the scene
  99368. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99369. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99370. */
  99371. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99372. /**
  99373. * Freeze all materials
  99374. * A frozen material will not be updatable but should be faster to render
  99375. */
  99376. freezeMaterials(): void;
  99377. /**
  99378. * Unfreeze all materials
  99379. * A frozen material will not be updatable but should be faster to render
  99380. */
  99381. unfreezeMaterials(): void;
  99382. /**
  99383. * Releases all held ressources
  99384. */
  99385. dispose(): void;
  99386. /**
  99387. * Gets if the scene is already disposed
  99388. */
  99389. readonly isDisposed: boolean;
  99390. /**
  99391. * Call this function to reduce memory footprint of the scene.
  99392. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99393. */
  99394. clearCachedVertexData(): void;
  99395. /**
  99396. * This function will remove the local cached buffer data from texture.
  99397. * It will save memory but will prevent the texture from being rebuilt
  99398. */
  99399. cleanCachedTextureBuffer(): void;
  99400. /**
  99401. * Get the world extend vectors with an optional filter
  99402. *
  99403. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99404. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99405. */
  99406. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99407. min: Vector3;
  99408. max: Vector3;
  99409. };
  99410. /**
  99411. * Creates a ray that can be used to pick in the scene
  99412. * @param x defines the x coordinate of the origin (on-screen)
  99413. * @param y defines the y coordinate of the origin (on-screen)
  99414. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99415. * @param camera defines the camera to use for the picking
  99416. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99417. * @returns a Ray
  99418. */
  99419. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99420. /**
  99421. * Creates a ray that can be used to pick in the scene
  99422. * @param x defines the x coordinate of the origin (on-screen)
  99423. * @param y defines the y coordinate of the origin (on-screen)
  99424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99425. * @param result defines the ray where to store the picking ray
  99426. * @param camera defines the camera to use for the picking
  99427. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99428. * @returns the current scene
  99429. */
  99430. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99431. /**
  99432. * Creates a ray that can be used to pick in the scene
  99433. * @param x defines the x coordinate of the origin (on-screen)
  99434. * @param y defines the y coordinate of the origin (on-screen)
  99435. * @param camera defines the camera to use for the picking
  99436. * @returns a Ray
  99437. */
  99438. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  99439. /**
  99440. * Creates a ray that can be used to pick in the scene
  99441. * @param x defines the x coordinate of the origin (on-screen)
  99442. * @param y defines the y coordinate of the origin (on-screen)
  99443. * @param result defines the ray where to store the picking ray
  99444. * @param camera defines the camera to use for the picking
  99445. * @returns the current scene
  99446. */
  99447. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99448. /** Launch a ray to try to pick a mesh in the scene
  99449. * @param x position on screen
  99450. * @param y position on screen
  99451. * @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
  99452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99453. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99454. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99455. * @returns a PickingInfo
  99456. */
  99457. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99458. /** Use the given ray to pick a mesh in the scene
  99459. * @param ray The ray to use to pick meshes
  99460. * @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
  99461. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99462. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99463. * @returns a PickingInfo
  99464. */
  99465. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99466. /**
  99467. * Launch a ray to try to pick a mesh in the scene
  99468. * @param x X position on screen
  99469. * @param y Y position on screen
  99470. * @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
  99471. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99472. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99473. * @returns an array of PickingInfo
  99474. */
  99475. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99476. /**
  99477. * Launch a ray to try to pick a mesh in the scene
  99478. * @param ray Ray to use
  99479. * @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
  99480. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99481. * @returns an array of PickingInfo
  99482. */
  99483. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99484. /**
  99485. * Force the value of meshUnderPointer
  99486. * @param mesh defines the mesh to use
  99487. */
  99488. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99489. /**
  99490. * Gets the mesh under the pointer
  99491. * @returns a Mesh or null if no mesh is under the pointer
  99492. */
  99493. getPointerOverMesh(): Nullable<AbstractMesh>;
  99494. /** @hidden */
  99495. _rebuildGeometries(): void;
  99496. /** @hidden */
  99497. _rebuildTextures(): void;
  99498. private _getByTags;
  99499. /**
  99500. * Get a list of meshes by tags
  99501. * @param tagsQuery defines the tags query to use
  99502. * @param forEach defines a predicate used to filter results
  99503. * @returns an array of Mesh
  99504. */
  99505. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99506. /**
  99507. * Get a list of cameras by tags
  99508. * @param tagsQuery defines the tags query to use
  99509. * @param forEach defines a predicate used to filter results
  99510. * @returns an array of Camera
  99511. */
  99512. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99513. /**
  99514. * Get a list of lights by tags
  99515. * @param tagsQuery defines the tags query to use
  99516. * @param forEach defines a predicate used to filter results
  99517. * @returns an array of Light
  99518. */
  99519. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99520. /**
  99521. * Get a list of materials by tags
  99522. * @param tagsQuery defines the tags query to use
  99523. * @param forEach defines a predicate used to filter results
  99524. * @returns an array of Material
  99525. */
  99526. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99527. /**
  99528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99529. * This allowed control for front to back rendering or reversly depending of the special needs.
  99530. *
  99531. * @param renderingGroupId The rendering group id corresponding to its index
  99532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99535. */
  99536. 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;
  99537. /**
  99538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99539. *
  99540. * @param renderingGroupId The rendering group id corresponding to its index
  99541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99542. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99543. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99544. */
  99545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99546. /**
  99547. * Gets the current auto clear configuration for one rendering group of the rendering
  99548. * manager.
  99549. * @param index the rendering group index to get the information for
  99550. * @returns The auto clear setup for the requested rendering group
  99551. */
  99552. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99553. private _blockMaterialDirtyMechanism;
  99554. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99555. blockMaterialDirtyMechanism: boolean;
  99556. /**
  99557. * Will flag all materials as dirty to trigger new shader compilation
  99558. * @param flag defines the flag used to specify which material part must be marked as dirty
  99559. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  99560. */
  99561. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99562. /** @hidden */
  99563. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  99564. /** @hidden */
  99565. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99566. }
  99567. }
  99568. declare module BABYLON {
  99569. /**
  99570. * Set of assets to keep when moving a scene into an asset container.
  99571. */
  99572. export class KeepAssets extends AbstractScene {
  99573. }
  99574. /**
  99575. * Container with a set of assets that can be added or removed from a scene.
  99576. */
  99577. export class AssetContainer extends AbstractScene {
  99578. /**
  99579. * The scene the AssetContainer belongs to.
  99580. */
  99581. scene: Scene;
  99582. /**
  99583. * Instantiates an AssetContainer.
  99584. * @param scene The scene the AssetContainer belongs to.
  99585. */
  99586. constructor(scene: Scene);
  99587. /**
  99588. * Adds all the assets from the container to the scene.
  99589. */
  99590. addAllToScene(): void;
  99591. /**
  99592. * Removes all the assets in the container from the scene
  99593. */
  99594. removeAllFromScene(): void;
  99595. /**
  99596. * Disposes all the assets in the container
  99597. */
  99598. dispose(): void;
  99599. private _moveAssets;
  99600. /**
  99601. * Removes all the assets contained in the scene and adds them to the container.
  99602. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99603. */
  99604. moveAllFromScene(keepAssets?: KeepAssets): void;
  99605. /**
  99606. * 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.
  99607. * @returns the root mesh
  99608. */
  99609. createRootMesh(): Mesh;
  99610. }
  99611. }
  99612. declare module BABYLON {
  99613. /**
  99614. * Defines how the parser contract is defined.
  99615. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99616. */
  99617. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99618. /**
  99619. * Defines how the individual parser contract is defined.
  99620. * These parser can parse an individual asset
  99621. */
  99622. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99623. /**
  99624. * Base class of the scene acting as a container for the different elements composing a scene.
  99625. * This class is dynamically extended by the different components of the scene increasing
  99626. * flexibility and reducing coupling
  99627. */
  99628. export abstract class AbstractScene {
  99629. /**
  99630. * Stores the list of available parsers in the application.
  99631. */
  99632. private static _BabylonFileParsers;
  99633. /**
  99634. * Stores the list of available individual parsers in the application.
  99635. */
  99636. private static _IndividualBabylonFileParsers;
  99637. /**
  99638. * Adds a parser in the list of available ones
  99639. * @param name Defines the name of the parser
  99640. * @param parser Defines the parser to add
  99641. */
  99642. static AddParser(name: string, parser: BabylonFileParser): void;
  99643. /**
  99644. * Gets a general parser from the list of avaialble ones
  99645. * @param name Defines the name of the parser
  99646. * @returns the requested parser or null
  99647. */
  99648. static GetParser(name: string): Nullable<BabylonFileParser>;
  99649. /**
  99650. * Adds n individual parser in the list of available ones
  99651. * @param name Defines the name of the parser
  99652. * @param parser Defines the parser to add
  99653. */
  99654. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99655. /**
  99656. * Gets an individual parser from the list of avaialble ones
  99657. * @param name Defines the name of the parser
  99658. * @returns the requested parser or null
  99659. */
  99660. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99661. /**
  99662. * Parser json data and populate both a scene and its associated container object
  99663. * @param jsonData Defines the data to parse
  99664. * @param scene Defines the scene to parse the data for
  99665. * @param container Defines the container attached to the parsing sequence
  99666. * @param rootUrl Defines the root url of the data
  99667. */
  99668. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99669. /**
  99670. * Gets the list of root nodes (ie. nodes with no parent)
  99671. */
  99672. rootNodes: Node[];
  99673. /** All of the cameras added to this scene
  99674. * @see http://doc.babylonjs.com/babylon101/cameras
  99675. */
  99676. cameras: Camera[];
  99677. /**
  99678. * All of the lights added to this scene
  99679. * @see http://doc.babylonjs.com/babylon101/lights
  99680. */
  99681. lights: Light[];
  99682. /**
  99683. * All of the (abstract) meshes added to this scene
  99684. */
  99685. meshes: AbstractMesh[];
  99686. /**
  99687. * The list of skeletons added to the scene
  99688. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99689. */
  99690. skeletons: Skeleton[];
  99691. /**
  99692. * All of the particle systems added to this scene
  99693. * @see http://doc.babylonjs.com/babylon101/particles
  99694. */
  99695. particleSystems: IParticleSystem[];
  99696. /**
  99697. * Gets a list of Animations associated with the scene
  99698. */
  99699. animations: Animation[];
  99700. /**
  99701. * All of the animation groups added to this scene
  99702. * @see http://doc.babylonjs.com/how_to/group
  99703. */
  99704. animationGroups: AnimationGroup[];
  99705. /**
  99706. * All of the multi-materials added to this scene
  99707. * @see http://doc.babylonjs.com/how_to/multi_materials
  99708. */
  99709. multiMaterials: MultiMaterial[];
  99710. /**
  99711. * All of the materials added to this scene
  99712. * In the context of a Scene, it is not supposed to be modified manually.
  99713. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99714. * Note also that the order of the Material wihin the array is not significant and might change.
  99715. * @see http://doc.babylonjs.com/babylon101/materials
  99716. */
  99717. materials: Material[];
  99718. /**
  99719. * The list of morph target managers added to the scene
  99720. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99721. */
  99722. morphTargetManagers: MorphTargetManager[];
  99723. /**
  99724. * The list of geometries used in the scene.
  99725. */
  99726. geometries: Geometry[];
  99727. /**
  99728. * All of the tranform nodes added to this scene
  99729. * In the context of a Scene, it is not supposed to be modified manually.
  99730. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99731. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99732. * @see http://doc.babylonjs.com/how_to/transformnode
  99733. */
  99734. transformNodes: TransformNode[];
  99735. /**
  99736. * ActionManagers available on the scene.
  99737. */
  99738. actionManagers: AbstractActionManager[];
  99739. /**
  99740. * Textures to keep.
  99741. */
  99742. textures: BaseTexture[];
  99743. /**
  99744. * Environment texture for the scene
  99745. */
  99746. environmentTexture: Nullable<BaseTexture>;
  99747. }
  99748. }
  99749. declare module BABYLON {
  99750. /**
  99751. * Interface used to define options for Sound class
  99752. */
  99753. export interface ISoundOptions {
  99754. /**
  99755. * Does the sound autoplay once loaded.
  99756. */
  99757. autoplay?: boolean;
  99758. /**
  99759. * Does the sound loop after it finishes playing once.
  99760. */
  99761. loop?: boolean;
  99762. /**
  99763. * Sound's volume
  99764. */
  99765. volume?: number;
  99766. /**
  99767. * Is it a spatial sound?
  99768. */
  99769. spatialSound?: boolean;
  99770. /**
  99771. * Maximum distance to hear that sound
  99772. */
  99773. maxDistance?: number;
  99774. /**
  99775. * Uses user defined attenuation function
  99776. */
  99777. useCustomAttenuation?: boolean;
  99778. /**
  99779. * Define the roll off factor of spatial sounds.
  99780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99781. */
  99782. rolloffFactor?: number;
  99783. /**
  99784. * Define the reference distance the sound should be heard perfectly.
  99785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99786. */
  99787. refDistance?: number;
  99788. /**
  99789. * Define the distance attenuation model the sound will follow.
  99790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99791. */
  99792. distanceModel?: string;
  99793. /**
  99794. * Defines the playback speed (1 by default)
  99795. */
  99796. playbackRate?: number;
  99797. /**
  99798. * Defines if the sound is from a streaming source
  99799. */
  99800. streaming?: boolean;
  99801. /**
  99802. * Defines an optional length (in seconds) inside the sound file
  99803. */
  99804. length?: number;
  99805. /**
  99806. * Defines an optional offset (in seconds) inside the sound file
  99807. */
  99808. offset?: number;
  99809. /**
  99810. * If true, URLs will not be required to state the audio file codec to use.
  99811. */
  99812. skipCodecCheck?: boolean;
  99813. }
  99814. /**
  99815. * Defines a sound that can be played in the application.
  99816. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99818. */
  99819. export class Sound {
  99820. /**
  99821. * The name of the sound in the scene.
  99822. */
  99823. name: string;
  99824. /**
  99825. * Does the sound autoplay once loaded.
  99826. */
  99827. autoplay: boolean;
  99828. /**
  99829. * Does the sound loop after it finishes playing once.
  99830. */
  99831. loop: boolean;
  99832. /**
  99833. * Does the sound use a custom attenuation curve to simulate the falloff
  99834. * happening when the source gets further away from the camera.
  99835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99836. */
  99837. useCustomAttenuation: boolean;
  99838. /**
  99839. * The sound track id this sound belongs to.
  99840. */
  99841. soundTrackId: number;
  99842. /**
  99843. * Is this sound currently played.
  99844. */
  99845. isPlaying: boolean;
  99846. /**
  99847. * Is this sound currently paused.
  99848. */
  99849. isPaused: boolean;
  99850. /**
  99851. * Does this sound enables spatial sound.
  99852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99853. */
  99854. spatialSound: boolean;
  99855. /**
  99856. * Define the reference distance the sound should be heard perfectly.
  99857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99858. */
  99859. refDistance: number;
  99860. /**
  99861. * Define the roll off factor of spatial sounds.
  99862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99863. */
  99864. rolloffFactor: number;
  99865. /**
  99866. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99868. */
  99869. maxDistance: number;
  99870. /**
  99871. * Define the distance attenuation model the sound will follow.
  99872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99873. */
  99874. distanceModel: string;
  99875. /**
  99876. * @hidden
  99877. * Back Compat
  99878. **/
  99879. onended: () => any;
  99880. /**
  99881. * Observable event when the current playing sound finishes.
  99882. */
  99883. onEndedObservable: Observable<Sound>;
  99884. private _panningModel;
  99885. private _playbackRate;
  99886. private _streaming;
  99887. private _startTime;
  99888. private _startOffset;
  99889. private _position;
  99890. /** @hidden */
  99891. _positionInEmitterSpace: boolean;
  99892. private _localDirection;
  99893. private _volume;
  99894. private _isReadyToPlay;
  99895. private _isDirectional;
  99896. private _readyToPlayCallback;
  99897. private _audioBuffer;
  99898. private _soundSource;
  99899. private _streamingSource;
  99900. private _soundPanner;
  99901. private _soundGain;
  99902. private _inputAudioNode;
  99903. private _outputAudioNode;
  99904. private _coneInnerAngle;
  99905. private _coneOuterAngle;
  99906. private _coneOuterGain;
  99907. private _scene;
  99908. private _connectedTransformNode;
  99909. private _customAttenuationFunction;
  99910. private _registerFunc;
  99911. private _isOutputConnected;
  99912. private _htmlAudioElement;
  99913. private _urlType;
  99914. private _length?;
  99915. private _offset?;
  99916. /** @hidden */
  99917. static _SceneComponentInitialization: (scene: Scene) => void;
  99918. /**
  99919. * Create a sound and attach it to a scene
  99920. * @param name Name of your sound
  99921. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99922. * @param scene defines the scene the sound belongs to
  99923. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99924. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99925. */
  99926. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99927. /**
  99928. * Release the sound and its associated resources
  99929. */
  99930. dispose(): void;
  99931. /**
  99932. * Gets if the sounds is ready to be played or not.
  99933. * @returns true if ready, otherwise false
  99934. */
  99935. isReady(): boolean;
  99936. private _soundLoaded;
  99937. /**
  99938. * Sets the data of the sound from an audiobuffer
  99939. * @param audioBuffer The audioBuffer containing the data
  99940. */
  99941. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99942. /**
  99943. * Updates the current sounds options such as maxdistance, loop...
  99944. * @param options A JSON object containing values named as the object properties
  99945. */
  99946. updateOptions(options: ISoundOptions): void;
  99947. private _createSpatialParameters;
  99948. private _updateSpatialParameters;
  99949. /**
  99950. * Switch the panning model to HRTF:
  99951. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99953. */
  99954. switchPanningModelToHRTF(): void;
  99955. /**
  99956. * Switch the panning model to Equal Power:
  99957. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99959. */
  99960. switchPanningModelToEqualPower(): void;
  99961. private _switchPanningModel;
  99962. /**
  99963. * Connect this sound to a sound track audio node like gain...
  99964. * @param soundTrackAudioNode the sound track audio node to connect to
  99965. */
  99966. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99967. /**
  99968. * Transform this sound into a directional source
  99969. * @param coneInnerAngle Size of the inner cone in degree
  99970. * @param coneOuterAngle Size of the outer cone in degree
  99971. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99972. */
  99973. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99974. /**
  99975. * Gets or sets the inner angle for the directional cone.
  99976. */
  99977. /**
  99978. * Gets or sets the inner angle for the directional cone.
  99979. */
  99980. directionalConeInnerAngle: number;
  99981. /**
  99982. * Gets or sets the outer angle for the directional cone.
  99983. */
  99984. /**
  99985. * Gets or sets the outer angle for the directional cone.
  99986. */
  99987. directionalConeOuterAngle: number;
  99988. /**
  99989. * Sets the position of the emitter if spatial sound is enabled
  99990. * @param newPosition Defines the new posisiton
  99991. */
  99992. setPosition(newPosition: Vector3): void;
  99993. /**
  99994. * Sets the local direction of the emitter if spatial sound is enabled
  99995. * @param newLocalDirection Defines the new local direction
  99996. */
  99997. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99998. private _updateDirection;
  99999. /** @hidden */
  100000. updateDistanceFromListener(): void;
  100001. /**
  100002. * Sets a new custom attenuation function for the sound.
  100003. * @param callback Defines the function used for the attenuation
  100004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100005. */
  100006. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100007. /**
  100008. * Play the sound
  100009. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100010. * @param offset (optional) Start the sound at a specific time in seconds
  100011. * @param length (optional) Sound duration (in seconds)
  100012. */
  100013. play(time?: number, offset?: number, length?: number): void;
  100014. private _onended;
  100015. /**
  100016. * Stop the sound
  100017. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100018. */
  100019. stop(time?: number): void;
  100020. /**
  100021. * Put the sound in pause
  100022. */
  100023. pause(): void;
  100024. /**
  100025. * Sets a dedicated volume for this sounds
  100026. * @param newVolume Define the new volume of the sound
  100027. * @param time Define time for gradual change to new volume
  100028. */
  100029. setVolume(newVolume: number, time?: number): void;
  100030. /**
  100031. * Set the sound play back rate
  100032. * @param newPlaybackRate Define the playback rate the sound should be played at
  100033. */
  100034. setPlaybackRate(newPlaybackRate: number): void;
  100035. /**
  100036. * Gets the volume of the sound.
  100037. * @returns the volume of the sound
  100038. */
  100039. getVolume(): number;
  100040. /**
  100041. * Attach the sound to a dedicated mesh
  100042. * @param transformNode The transform node to connect the sound with
  100043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100044. */
  100045. attachToMesh(transformNode: TransformNode): void;
  100046. /**
  100047. * Detach the sound from the previously attached mesh
  100048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100049. */
  100050. detachFromMesh(): void;
  100051. private _onRegisterAfterWorldMatrixUpdate;
  100052. /**
  100053. * Clone the current sound in the scene.
  100054. * @returns the new sound clone
  100055. */
  100056. clone(): Nullable<Sound>;
  100057. /**
  100058. * Gets the current underlying audio buffer containing the data
  100059. * @returns the audio buffer
  100060. */
  100061. getAudioBuffer(): Nullable<AudioBuffer>;
  100062. /**
  100063. * Serializes the Sound in a JSON representation
  100064. * @returns the JSON representation of the sound
  100065. */
  100066. serialize(): any;
  100067. /**
  100068. * Parse a JSON representation of a sound to innstantiate in a given scene
  100069. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100070. * @param scene Define the scene the new parsed sound should be created in
  100071. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100072. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100073. * @returns the newly parsed sound
  100074. */
  100075. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100076. }
  100077. }
  100078. declare module BABYLON {
  100079. /**
  100080. * This defines an action helpful to play a defined sound on a triggered action.
  100081. */
  100082. export class PlaySoundAction extends Action {
  100083. private _sound;
  100084. /**
  100085. * Instantiate the action
  100086. * @param triggerOptions defines the trigger options
  100087. * @param sound defines the sound to play
  100088. * @param condition defines the trigger related conditions
  100089. */
  100090. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100091. /** @hidden */
  100092. _prepare(): void;
  100093. /**
  100094. * Execute the action and play the sound.
  100095. */
  100096. execute(): void;
  100097. /**
  100098. * Serializes the actions and its related information.
  100099. * @param parent defines the object to serialize in
  100100. * @returns the serialized object
  100101. */
  100102. serialize(parent: any): any;
  100103. }
  100104. /**
  100105. * This defines an action helpful to stop a defined sound on a triggered action.
  100106. */
  100107. export class StopSoundAction extends Action {
  100108. private _sound;
  100109. /**
  100110. * Instantiate the action
  100111. * @param triggerOptions defines the trigger options
  100112. * @param sound defines the sound to stop
  100113. * @param condition defines the trigger related conditions
  100114. */
  100115. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100116. /** @hidden */
  100117. _prepare(): void;
  100118. /**
  100119. * Execute the action and stop the sound.
  100120. */
  100121. execute(): void;
  100122. /**
  100123. * Serializes the actions and its related information.
  100124. * @param parent defines the object to serialize in
  100125. * @returns the serialized object
  100126. */
  100127. serialize(parent: any): any;
  100128. }
  100129. }
  100130. declare module BABYLON {
  100131. /**
  100132. * This defines an action responsible to change the value of a property
  100133. * by interpolating between its current value and the newly set one once triggered.
  100134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100135. */
  100136. export class InterpolateValueAction extends Action {
  100137. /**
  100138. * Defines the path of the property where the value should be interpolated
  100139. */
  100140. propertyPath: string;
  100141. /**
  100142. * Defines the target value at the end of the interpolation.
  100143. */
  100144. value: any;
  100145. /**
  100146. * Defines the time it will take for the property to interpolate to the value.
  100147. */
  100148. duration: number;
  100149. /**
  100150. * Defines if the other scene animations should be stopped when the action has been triggered
  100151. */
  100152. stopOtherAnimations?: boolean;
  100153. /**
  100154. * Defines a callback raised once the interpolation animation has been done.
  100155. */
  100156. onInterpolationDone?: () => void;
  100157. /**
  100158. * Observable triggered once the interpolation animation has been done.
  100159. */
  100160. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100161. private _target;
  100162. private _effectiveTarget;
  100163. private _property;
  100164. /**
  100165. * Instantiate the action
  100166. * @param triggerOptions defines the trigger options
  100167. * @param target defines the object containing the value to interpolate
  100168. * @param propertyPath defines the path to the property in the target object
  100169. * @param value defines the target value at the end of the interpolation
  100170. * @param duration deines the time it will take for the property to interpolate to the value.
  100171. * @param condition defines the trigger related conditions
  100172. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100173. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100174. */
  100175. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100176. /** @hidden */
  100177. _prepare(): void;
  100178. /**
  100179. * Execute the action starts the value interpolation.
  100180. */
  100181. execute(): void;
  100182. /**
  100183. * Serializes the actions and its related information.
  100184. * @param parent defines the object to serialize in
  100185. * @returns the serialized object
  100186. */
  100187. serialize(parent: any): any;
  100188. }
  100189. }
  100190. declare module BABYLON {
  100191. /**
  100192. * Options allowed during the creation of a sound track.
  100193. */
  100194. export interface ISoundTrackOptions {
  100195. /**
  100196. * The volume the sound track should take during creation
  100197. */
  100198. volume?: number;
  100199. /**
  100200. * Define if the sound track is the main sound track of the scene
  100201. */
  100202. mainTrack?: boolean;
  100203. }
  100204. /**
  100205. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100206. * It will be also used in a future release to apply effects on a specific track.
  100207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100208. */
  100209. export class SoundTrack {
  100210. /**
  100211. * The unique identifier of the sound track in the scene.
  100212. */
  100213. id: number;
  100214. /**
  100215. * The list of sounds included in the sound track.
  100216. */
  100217. soundCollection: Array<Sound>;
  100218. private _outputAudioNode;
  100219. private _scene;
  100220. private _isMainTrack;
  100221. private _connectedAnalyser;
  100222. private _options;
  100223. private _isInitialized;
  100224. /**
  100225. * Creates a new sound track.
  100226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100227. * @param scene Define the scene the sound track belongs to
  100228. * @param options
  100229. */
  100230. constructor(scene: Scene, options?: ISoundTrackOptions);
  100231. private _initializeSoundTrackAudioGraph;
  100232. /**
  100233. * Release the sound track and its associated resources
  100234. */
  100235. dispose(): void;
  100236. /**
  100237. * Adds a sound to this sound track
  100238. * @param sound define the cound to add
  100239. * @ignoreNaming
  100240. */
  100241. AddSound(sound: Sound): void;
  100242. /**
  100243. * Removes a sound to this sound track
  100244. * @param sound define the cound to remove
  100245. * @ignoreNaming
  100246. */
  100247. RemoveSound(sound: Sound): void;
  100248. /**
  100249. * Set a global volume for the full sound track.
  100250. * @param newVolume Define the new volume of the sound track
  100251. */
  100252. setVolume(newVolume: number): void;
  100253. /**
  100254. * Switch the panning model to HRTF:
  100255. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100257. */
  100258. switchPanningModelToHRTF(): void;
  100259. /**
  100260. * Switch the panning model to Equal Power:
  100261. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100263. */
  100264. switchPanningModelToEqualPower(): void;
  100265. /**
  100266. * Connect the sound track to an audio analyser allowing some amazing
  100267. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100269. * @param analyser The analyser to connect to the engine
  100270. */
  100271. connectToAnalyser(analyser: Analyser): void;
  100272. }
  100273. }
  100274. declare module BABYLON {
  100275. interface AbstractScene {
  100276. /**
  100277. * The list of sounds used in the scene.
  100278. */
  100279. sounds: Nullable<Array<Sound>>;
  100280. }
  100281. interface Scene {
  100282. /**
  100283. * @hidden
  100284. * Backing field
  100285. */
  100286. _mainSoundTrack: SoundTrack;
  100287. /**
  100288. * The main sound track played by the scene.
  100289. * It cotains your primary collection of sounds.
  100290. */
  100291. mainSoundTrack: SoundTrack;
  100292. /**
  100293. * The list of sound tracks added to the scene
  100294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100295. */
  100296. soundTracks: Nullable<Array<SoundTrack>>;
  100297. /**
  100298. * Gets a sound using a given name
  100299. * @param name defines the name to search for
  100300. * @return the found sound or null if not found at all.
  100301. */
  100302. getSoundByName(name: string): Nullable<Sound>;
  100303. /**
  100304. * Gets or sets if audio support is enabled
  100305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100306. */
  100307. audioEnabled: boolean;
  100308. /**
  100309. * Gets or sets if audio will be output to headphones
  100310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100311. */
  100312. headphone: boolean;
  100313. /**
  100314. * Gets or sets custom audio listener position provider
  100315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100316. */
  100317. audioListenerPositionProvider: Nullable<() => Vector3>;
  100318. }
  100319. /**
  100320. * Defines the sound scene component responsible to manage any sounds
  100321. * in a given scene.
  100322. */
  100323. export class AudioSceneComponent implements ISceneSerializableComponent {
  100324. /**
  100325. * The component name helpfull to identify the component in the list of scene components.
  100326. */
  100327. readonly name: string;
  100328. /**
  100329. * The scene the component belongs to.
  100330. */
  100331. scene: Scene;
  100332. private _audioEnabled;
  100333. /**
  100334. * Gets whether audio is enabled or not.
  100335. * Please use related enable/disable method to switch state.
  100336. */
  100337. readonly audioEnabled: boolean;
  100338. private _headphone;
  100339. /**
  100340. * Gets whether audio is outputing to headphone or not.
  100341. * Please use the according Switch methods to change output.
  100342. */
  100343. readonly headphone: boolean;
  100344. private _audioListenerPositionProvider;
  100345. /**
  100346. * Gets the current audio listener position provider
  100347. */
  100348. /**
  100349. * Sets a custom listener position for all sounds in the scene
  100350. * By default, this is the position of the first active camera
  100351. */
  100352. audioListenerPositionProvider: Nullable<() => Vector3>;
  100353. /**
  100354. * Creates a new instance of the component for the given scene
  100355. * @param scene Defines the scene to register the component in
  100356. */
  100357. constructor(scene: Scene);
  100358. /**
  100359. * Registers the component in a given scene
  100360. */
  100361. register(): void;
  100362. /**
  100363. * Rebuilds the elements related to this component in case of
  100364. * context lost for instance.
  100365. */
  100366. rebuild(): void;
  100367. /**
  100368. * Serializes the component data to the specified json object
  100369. * @param serializationObject The object to serialize to
  100370. */
  100371. serialize(serializationObject: any): void;
  100372. /**
  100373. * Adds all the elements from the container to the scene
  100374. * @param container the container holding the elements
  100375. */
  100376. addFromContainer(container: AbstractScene): void;
  100377. /**
  100378. * Removes all the elements in the container from the scene
  100379. * @param container contains the elements to remove
  100380. * @param dispose if the removed element should be disposed (default: false)
  100381. */
  100382. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100383. /**
  100384. * Disposes the component and the associated ressources.
  100385. */
  100386. dispose(): void;
  100387. /**
  100388. * Disables audio in the associated scene.
  100389. */
  100390. disableAudio(): void;
  100391. /**
  100392. * Enables audio in the associated scene.
  100393. */
  100394. enableAudio(): void;
  100395. /**
  100396. * Switch audio to headphone output.
  100397. */
  100398. switchAudioModeForHeadphones(): void;
  100399. /**
  100400. * Switch audio to normal speakers.
  100401. */
  100402. switchAudioModeForNormalSpeakers(): void;
  100403. private _afterRender;
  100404. }
  100405. }
  100406. declare module BABYLON {
  100407. /**
  100408. * Wraps one or more Sound objects and selects one with random weight for playback.
  100409. */
  100410. export class WeightedSound {
  100411. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100412. loop: boolean;
  100413. private _coneInnerAngle;
  100414. private _coneOuterAngle;
  100415. private _volume;
  100416. /** A Sound is currently playing. */
  100417. isPlaying: boolean;
  100418. /** A Sound is currently paused. */
  100419. isPaused: boolean;
  100420. private _sounds;
  100421. private _weights;
  100422. private _currentIndex?;
  100423. /**
  100424. * Creates a new WeightedSound from the list of sounds given.
  100425. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100426. * @param sounds Array of Sounds that will be selected from.
  100427. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100428. */
  100429. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100430. /**
  100431. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100432. */
  100433. /**
  100434. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100435. */
  100436. directionalConeInnerAngle: number;
  100437. /**
  100438. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100439. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100440. */
  100441. /**
  100442. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100443. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100444. */
  100445. directionalConeOuterAngle: number;
  100446. /**
  100447. * Playback volume.
  100448. */
  100449. /**
  100450. * Playback volume.
  100451. */
  100452. volume: number;
  100453. private _onended;
  100454. /**
  100455. * Suspend playback
  100456. */
  100457. pause(): void;
  100458. /**
  100459. * Stop playback
  100460. */
  100461. stop(): void;
  100462. /**
  100463. * Start playback.
  100464. * @param startOffset Position the clip head at a specific time in seconds.
  100465. */
  100466. play(startOffset?: number): void;
  100467. }
  100468. }
  100469. declare module BABYLON {
  100470. /**
  100471. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100473. */
  100474. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100475. /**
  100476. * Gets the name of the behavior.
  100477. */
  100478. readonly name: string;
  100479. /**
  100480. * The easing function used by animations
  100481. */
  100482. static EasingFunction: BackEase;
  100483. /**
  100484. * The easing mode used by animations
  100485. */
  100486. static EasingMode: number;
  100487. /**
  100488. * The duration of the animation, in milliseconds
  100489. */
  100490. transitionDuration: number;
  100491. /**
  100492. * Length of the distance animated by the transition when lower radius is reached
  100493. */
  100494. lowerRadiusTransitionRange: number;
  100495. /**
  100496. * Length of the distance animated by the transition when upper radius is reached
  100497. */
  100498. upperRadiusTransitionRange: number;
  100499. private _autoTransitionRange;
  100500. /**
  100501. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100502. */
  100503. /**
  100504. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100505. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100506. */
  100507. autoTransitionRange: boolean;
  100508. private _attachedCamera;
  100509. private _onAfterCheckInputsObserver;
  100510. private _onMeshTargetChangedObserver;
  100511. /**
  100512. * Initializes the behavior.
  100513. */
  100514. init(): void;
  100515. /**
  100516. * Attaches the behavior to its arc rotate camera.
  100517. * @param camera Defines the camera to attach the behavior to
  100518. */
  100519. attach(camera: ArcRotateCamera): void;
  100520. /**
  100521. * Detaches the behavior from its current arc rotate camera.
  100522. */
  100523. detach(): void;
  100524. private _radiusIsAnimating;
  100525. private _radiusBounceTransition;
  100526. private _animatables;
  100527. private _cachedWheelPrecision;
  100528. /**
  100529. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100530. * @param radiusLimit The limit to check against.
  100531. * @return Bool to indicate if at limit.
  100532. */
  100533. private _isRadiusAtLimit;
  100534. /**
  100535. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100536. * @param radiusDelta The delta by which to animate to. Can be negative.
  100537. */
  100538. private _applyBoundRadiusAnimation;
  100539. /**
  100540. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100541. */
  100542. protected _clearAnimationLocks(): void;
  100543. /**
  100544. * Stops and removes all animations that have been applied to the camera
  100545. */
  100546. stopAllAnimations(): void;
  100547. }
  100548. }
  100549. declare module BABYLON {
  100550. /**
  100551. * 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.
  100552. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100553. */
  100554. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100555. /**
  100556. * Gets the name of the behavior.
  100557. */
  100558. readonly name: string;
  100559. private _mode;
  100560. private _radiusScale;
  100561. private _positionScale;
  100562. private _defaultElevation;
  100563. private _elevationReturnTime;
  100564. private _elevationReturnWaitTime;
  100565. private _zoomStopsAnimation;
  100566. private _framingTime;
  100567. /**
  100568. * The easing function used by animations
  100569. */
  100570. static EasingFunction: ExponentialEase;
  100571. /**
  100572. * The easing mode used by animations
  100573. */
  100574. static EasingMode: number;
  100575. /**
  100576. * Sets the current mode used by the behavior
  100577. */
  100578. /**
  100579. * Gets current mode used by the behavior.
  100580. */
  100581. mode: number;
  100582. /**
  100583. * Sets the scale applied to the radius (1 by default)
  100584. */
  100585. /**
  100586. * Gets the scale applied to the radius
  100587. */
  100588. radiusScale: number;
  100589. /**
  100590. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100591. */
  100592. /**
  100593. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100594. */
  100595. positionScale: number;
  100596. /**
  100597. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100598. * behaviour is triggered, in radians.
  100599. */
  100600. /**
  100601. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100602. * behaviour is triggered, in radians.
  100603. */
  100604. defaultElevation: number;
  100605. /**
  100606. * Sets the time (in milliseconds) taken to return to the default beta position.
  100607. * Negative value indicates camera should not return to default.
  100608. */
  100609. /**
  100610. * Gets the time (in milliseconds) taken to return to the default beta position.
  100611. * Negative value indicates camera should not return to default.
  100612. */
  100613. elevationReturnTime: number;
  100614. /**
  100615. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100616. */
  100617. /**
  100618. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100619. */
  100620. elevationReturnWaitTime: number;
  100621. /**
  100622. * Sets the flag that indicates if user zooming should stop animation.
  100623. */
  100624. /**
  100625. * Gets the flag that indicates if user zooming should stop animation.
  100626. */
  100627. zoomStopsAnimation: boolean;
  100628. /**
  100629. * Sets the transition time when framing the mesh, in milliseconds
  100630. */
  100631. /**
  100632. * Gets the transition time when framing the mesh, in milliseconds
  100633. */
  100634. framingTime: number;
  100635. /**
  100636. * Define if the behavior should automatically change the configured
  100637. * camera limits and sensibilities.
  100638. */
  100639. autoCorrectCameraLimitsAndSensibility: boolean;
  100640. private _onPrePointerObservableObserver;
  100641. private _onAfterCheckInputsObserver;
  100642. private _onMeshTargetChangedObserver;
  100643. private _attachedCamera;
  100644. private _isPointerDown;
  100645. private _lastInteractionTime;
  100646. /**
  100647. * Initializes the behavior.
  100648. */
  100649. init(): void;
  100650. /**
  100651. * Attaches the behavior to its arc rotate camera.
  100652. * @param camera Defines the camera to attach the behavior to
  100653. */
  100654. attach(camera: ArcRotateCamera): void;
  100655. /**
  100656. * Detaches the behavior from its current arc rotate camera.
  100657. */
  100658. detach(): void;
  100659. private _animatables;
  100660. private _betaIsAnimating;
  100661. private _betaTransition;
  100662. private _radiusTransition;
  100663. private _vectorTransition;
  100664. /**
  100665. * Targets the given mesh and updates zoom level accordingly.
  100666. * @param mesh The mesh to target.
  100667. * @param radius Optional. If a cached radius position already exists, overrides default.
  100668. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100669. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100670. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100671. */
  100672. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100673. /**
  100674. * Targets the given mesh with its children and updates zoom level accordingly.
  100675. * @param mesh The mesh to target.
  100676. * @param radius Optional. If a cached radius position already exists, overrides default.
  100677. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100678. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100679. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100680. */
  100681. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100682. /**
  100683. * Targets the given meshes with their children and updates zoom level accordingly.
  100684. * @param meshes The mesh to target.
  100685. * @param radius Optional. If a cached radius position already exists, overrides default.
  100686. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100687. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100688. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100689. */
  100690. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100691. /**
  100692. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100693. * @param minimumWorld Determines the smaller position of the bounding box extend
  100694. * @param maximumWorld Determines the bigger position of the bounding box extend
  100695. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100696. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100697. */
  100698. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100699. /**
  100700. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100701. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100702. * frustum width.
  100703. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100704. * to fully enclose the mesh in the viewing frustum.
  100705. */
  100706. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100707. /**
  100708. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100709. * is automatically returned to its default position (expected to be above ground plane).
  100710. */
  100711. private _maintainCameraAboveGround;
  100712. /**
  100713. * Returns the frustum slope based on the canvas ratio and camera FOV
  100714. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100715. */
  100716. private _getFrustumSlope;
  100717. /**
  100718. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100719. */
  100720. private _clearAnimationLocks;
  100721. /**
  100722. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100723. */
  100724. private _applyUserInteraction;
  100725. /**
  100726. * Stops and removes all animations that have been applied to the camera
  100727. */
  100728. stopAllAnimations(): void;
  100729. /**
  100730. * Gets a value indicating if the user is moving the camera
  100731. */
  100732. readonly isUserIsMoving: boolean;
  100733. /**
  100734. * The camera can move all the way towards the mesh.
  100735. */
  100736. static IgnoreBoundsSizeMode: number;
  100737. /**
  100738. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100739. */
  100740. static FitFrustumSidesMode: number;
  100741. }
  100742. }
  100743. declare module BABYLON {
  100744. /**
  100745. * Base class for Camera Pointer Inputs.
  100746. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100747. * for example usage.
  100748. */
  100749. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100750. /**
  100751. * Defines the camera the input is attached to.
  100752. */
  100753. abstract camera: Camera;
  100754. /**
  100755. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100756. */
  100757. protected _altKey: boolean;
  100758. protected _ctrlKey: boolean;
  100759. protected _metaKey: boolean;
  100760. protected _shiftKey: boolean;
  100761. /**
  100762. * Which mouse buttons were pressed at time of last mouse event.
  100763. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100764. */
  100765. protected _buttonsPressed: number;
  100766. /**
  100767. * Defines the buttons associated with the input to handle camera move.
  100768. */
  100769. buttons: number[];
  100770. /**
  100771. * Attach the input controls to a specific dom element to get the input from.
  100772. * @param element Defines the element the controls should be listened from
  100773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100774. */
  100775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100776. /**
  100777. * Detach the current controls from the specified dom element.
  100778. * @param element Defines the element to stop listening the inputs from
  100779. */
  100780. detachControl(element: Nullable<HTMLElement>): void;
  100781. /**
  100782. * Gets the class name of the current input.
  100783. * @returns the class name
  100784. */
  100785. getClassName(): string;
  100786. /**
  100787. * Get the friendly name associated with the input class.
  100788. * @returns the input friendly name
  100789. */
  100790. getSimpleName(): string;
  100791. /**
  100792. * Called on pointer POINTERDOUBLETAP event.
  100793. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100794. */
  100795. protected onDoubleTap(type: string): void;
  100796. /**
  100797. * Called on pointer POINTERMOVE event if only a single touch is active.
  100798. * Override this method to provide functionality.
  100799. */
  100800. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100801. /**
  100802. * Called on pointer POINTERMOVE event if multiple touches are active.
  100803. * Override this method to provide functionality.
  100804. */
  100805. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100806. /**
  100807. * Called on JS contextmenu event.
  100808. * Override this method to provide functionality.
  100809. */
  100810. protected onContextMenu(evt: PointerEvent): void;
  100811. /**
  100812. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100813. * press.
  100814. * Override this method to provide functionality.
  100815. */
  100816. protected onButtonDown(evt: PointerEvent): void;
  100817. /**
  100818. * Called each time a new POINTERUP event occurs. Ie, for each button
  100819. * release.
  100820. * Override this method to provide functionality.
  100821. */
  100822. protected onButtonUp(evt: PointerEvent): void;
  100823. /**
  100824. * Called when window becomes inactive.
  100825. * Override this method to provide functionality.
  100826. */
  100827. protected onLostFocus(): void;
  100828. private _pointerInput;
  100829. private _observer;
  100830. private _onLostFocus;
  100831. private pointA;
  100832. private pointB;
  100833. }
  100834. }
  100835. declare module BABYLON {
  100836. /**
  100837. * Manage the pointers inputs to control an arc rotate camera.
  100838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100839. */
  100840. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100841. /**
  100842. * Defines the camera the input is attached to.
  100843. */
  100844. camera: ArcRotateCamera;
  100845. /**
  100846. * Gets the class name of the current input.
  100847. * @returns the class name
  100848. */
  100849. getClassName(): string;
  100850. /**
  100851. * Defines the buttons associated with the input to handle camera move.
  100852. */
  100853. buttons: number[];
  100854. /**
  100855. * Defines the pointer angular sensibility along the X axis or how fast is
  100856. * the camera rotating.
  100857. */
  100858. angularSensibilityX: number;
  100859. /**
  100860. * Defines the pointer angular sensibility along the Y axis or how fast is
  100861. * the camera rotating.
  100862. */
  100863. angularSensibilityY: number;
  100864. /**
  100865. * Defines the pointer pinch precision or how fast is the camera zooming.
  100866. */
  100867. pinchPrecision: number;
  100868. /**
  100869. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100870. * from 0.
  100871. * It defines the percentage of current camera.radius to use as delta when
  100872. * pinch zoom is used.
  100873. */
  100874. pinchDeltaPercentage: number;
  100875. /**
  100876. * Defines the pointer panning sensibility or how fast is the camera moving.
  100877. */
  100878. panningSensibility: number;
  100879. /**
  100880. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100881. */
  100882. multiTouchPanning: boolean;
  100883. /**
  100884. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100885. * zoom (pinch) through multitouch.
  100886. */
  100887. multiTouchPanAndZoom: boolean;
  100888. /**
  100889. * Revers pinch action direction.
  100890. */
  100891. pinchInwards: boolean;
  100892. private _isPanClick;
  100893. private _twoFingerActivityCount;
  100894. private _isPinching;
  100895. /**
  100896. * Called on pointer POINTERMOVE event if only a single touch is active.
  100897. */
  100898. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100899. /**
  100900. * Called on pointer POINTERDOUBLETAP event.
  100901. */
  100902. protected onDoubleTap(type: string): void;
  100903. /**
  100904. * Called on pointer POINTERMOVE event if multiple touches are active.
  100905. */
  100906. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100907. /**
  100908. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100909. * press.
  100910. */
  100911. protected onButtonDown(evt: PointerEvent): void;
  100912. /**
  100913. * Called each time a new POINTERUP event occurs. Ie, for each button
  100914. * release.
  100915. */
  100916. protected onButtonUp(evt: PointerEvent): void;
  100917. /**
  100918. * Called when window becomes inactive.
  100919. */
  100920. protected onLostFocus(): void;
  100921. }
  100922. }
  100923. declare module BABYLON {
  100924. /**
  100925. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100927. */
  100928. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100929. /**
  100930. * Defines the camera the input is attached to.
  100931. */
  100932. camera: ArcRotateCamera;
  100933. /**
  100934. * Defines the list of key codes associated with the up action (increase alpha)
  100935. */
  100936. keysUp: number[];
  100937. /**
  100938. * Defines the list of key codes associated with the down action (decrease alpha)
  100939. */
  100940. keysDown: number[];
  100941. /**
  100942. * Defines the list of key codes associated with the left action (increase beta)
  100943. */
  100944. keysLeft: number[];
  100945. /**
  100946. * Defines the list of key codes associated with the right action (decrease beta)
  100947. */
  100948. keysRight: number[];
  100949. /**
  100950. * Defines the list of key codes associated with the reset action.
  100951. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100952. */
  100953. keysReset: number[];
  100954. /**
  100955. * Defines the panning sensibility of the inputs.
  100956. * (How fast is the camera paning)
  100957. */
  100958. panningSensibility: number;
  100959. /**
  100960. * Defines the zooming sensibility of the inputs.
  100961. * (How fast is the camera zooming)
  100962. */
  100963. zoomingSensibility: number;
  100964. /**
  100965. * Defines wether maintaining the alt key down switch the movement mode from
  100966. * orientation to zoom.
  100967. */
  100968. useAltToZoom: boolean;
  100969. /**
  100970. * Rotation speed of the camera
  100971. */
  100972. angularSpeed: number;
  100973. private _keys;
  100974. private _ctrlPressed;
  100975. private _altPressed;
  100976. private _onCanvasBlurObserver;
  100977. private _onKeyboardObserver;
  100978. private _engine;
  100979. private _scene;
  100980. /**
  100981. * Attach the input controls to a specific dom element to get the input from.
  100982. * @param element Defines the element the controls should be listened from
  100983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100984. */
  100985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100986. /**
  100987. * Detach the current controls from the specified dom element.
  100988. * @param element Defines the element to stop listening the inputs from
  100989. */
  100990. detachControl(element: Nullable<HTMLElement>): void;
  100991. /**
  100992. * Update the current camera state depending on the inputs that have been used this frame.
  100993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100994. */
  100995. checkInputs(): void;
  100996. /**
  100997. * Gets the class name of the current intput.
  100998. * @returns the class name
  100999. */
  101000. getClassName(): string;
  101001. /**
  101002. * Get the friendly name associated with the input class.
  101003. * @returns the input friendly name
  101004. */
  101005. getSimpleName(): string;
  101006. }
  101007. }
  101008. declare module BABYLON {
  101009. /**
  101010. * Manage the mouse wheel inputs to control an arc rotate camera.
  101011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101012. */
  101013. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101014. /**
  101015. * Defines the camera the input is attached to.
  101016. */
  101017. camera: ArcRotateCamera;
  101018. /**
  101019. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101020. */
  101021. wheelPrecision: number;
  101022. /**
  101023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101025. */
  101026. wheelDeltaPercentage: number;
  101027. private _wheel;
  101028. private _observer;
  101029. private computeDeltaFromMouseWheelLegacyEvent;
  101030. /**
  101031. * Attach the input controls to a specific dom element to get the input from.
  101032. * @param element Defines the element the controls should be listened from
  101033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101034. */
  101035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101036. /**
  101037. * Detach the current controls from the specified dom element.
  101038. * @param element Defines the element to stop listening the inputs from
  101039. */
  101040. detachControl(element: Nullable<HTMLElement>): void;
  101041. /**
  101042. * Gets the class name of the current intput.
  101043. * @returns the class name
  101044. */
  101045. getClassName(): string;
  101046. /**
  101047. * Get the friendly name associated with the input class.
  101048. * @returns the input friendly name
  101049. */
  101050. getSimpleName(): string;
  101051. }
  101052. }
  101053. declare module BABYLON {
  101054. /**
  101055. * Default Inputs manager for the ArcRotateCamera.
  101056. * It groups all the default supported inputs for ease of use.
  101057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101058. */
  101059. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101060. /**
  101061. * Instantiates a new ArcRotateCameraInputsManager.
  101062. * @param camera Defines the camera the inputs belong to
  101063. */
  101064. constructor(camera: ArcRotateCamera);
  101065. /**
  101066. * Add mouse wheel input support to the input manager.
  101067. * @returns the current input manager
  101068. */
  101069. addMouseWheel(): ArcRotateCameraInputsManager;
  101070. /**
  101071. * Add pointers input support to the input manager.
  101072. * @returns the current input manager
  101073. */
  101074. addPointers(): ArcRotateCameraInputsManager;
  101075. /**
  101076. * Add keyboard input support to the input manager.
  101077. * @returns the current input manager
  101078. */
  101079. addKeyboard(): ArcRotateCameraInputsManager;
  101080. }
  101081. }
  101082. declare module BABYLON {
  101083. /**
  101084. * This represents an orbital type of camera.
  101085. *
  101086. * 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.
  101087. * 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.
  101088. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101089. */
  101090. export class ArcRotateCamera extends TargetCamera {
  101091. /**
  101092. * Defines the rotation angle of the camera along the longitudinal axis.
  101093. */
  101094. alpha: number;
  101095. /**
  101096. * Defines the rotation angle of the camera along the latitudinal axis.
  101097. */
  101098. beta: number;
  101099. /**
  101100. * Defines the radius of the camera from it s target point.
  101101. */
  101102. radius: number;
  101103. protected _target: Vector3;
  101104. protected _targetHost: Nullable<AbstractMesh>;
  101105. /**
  101106. * Defines the target point of the camera.
  101107. * The camera looks towards it form the radius distance.
  101108. */
  101109. target: Vector3;
  101110. /**
  101111. * Define the current local position of the camera in the scene
  101112. */
  101113. position: Vector3;
  101114. protected _upVector: Vector3;
  101115. protected _upToYMatrix: Matrix;
  101116. protected _YToUpMatrix: Matrix;
  101117. /**
  101118. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101119. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101120. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101121. */
  101122. upVector: Vector3;
  101123. /**
  101124. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101125. */
  101126. setMatUp(): void;
  101127. /**
  101128. * Current inertia value on the longitudinal axis.
  101129. * The bigger this number the longer it will take for the camera to stop.
  101130. */
  101131. inertialAlphaOffset: number;
  101132. /**
  101133. * Current inertia value on the latitudinal axis.
  101134. * The bigger this number the longer it will take for the camera to stop.
  101135. */
  101136. inertialBetaOffset: number;
  101137. /**
  101138. * Current inertia value on the radius axis.
  101139. * The bigger this number the longer it will take for the camera to stop.
  101140. */
  101141. inertialRadiusOffset: number;
  101142. /**
  101143. * Minimum allowed angle on the longitudinal axis.
  101144. * This can help limiting how the Camera is able to move in the scene.
  101145. */
  101146. lowerAlphaLimit: Nullable<number>;
  101147. /**
  101148. * Maximum allowed angle on the longitudinal axis.
  101149. * This can help limiting how the Camera is able to move in the scene.
  101150. */
  101151. upperAlphaLimit: Nullable<number>;
  101152. /**
  101153. * Minimum allowed angle on the latitudinal axis.
  101154. * This can help limiting how the Camera is able to move in the scene.
  101155. */
  101156. lowerBetaLimit: number;
  101157. /**
  101158. * Maximum allowed angle on the latitudinal axis.
  101159. * This can help limiting how the Camera is able to move in the scene.
  101160. */
  101161. upperBetaLimit: number;
  101162. /**
  101163. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101164. * This can help limiting how the Camera is able to move in the scene.
  101165. */
  101166. lowerRadiusLimit: Nullable<number>;
  101167. /**
  101168. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101169. * This can help limiting how the Camera is able to move in the scene.
  101170. */
  101171. upperRadiusLimit: Nullable<number>;
  101172. /**
  101173. * Defines the current inertia value used during panning of the camera along the X axis.
  101174. */
  101175. inertialPanningX: number;
  101176. /**
  101177. * Defines the current inertia value used during panning of the camera along the Y axis.
  101178. */
  101179. inertialPanningY: number;
  101180. /**
  101181. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101182. * Basically if your fingers moves away from more than this distance you will be considered
  101183. * in pinch mode.
  101184. */
  101185. pinchToPanMaxDistance: number;
  101186. /**
  101187. * Defines the maximum distance the camera can pan.
  101188. * This could help keeping the cammera always in your scene.
  101189. */
  101190. panningDistanceLimit: Nullable<number>;
  101191. /**
  101192. * Defines the target of the camera before paning.
  101193. */
  101194. panningOriginTarget: Vector3;
  101195. /**
  101196. * Defines the value of the inertia used during panning.
  101197. * 0 would mean stop inertia and one would mean no decelleration at all.
  101198. */
  101199. panningInertia: number;
  101200. /**
  101201. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101202. */
  101203. angularSensibilityX: number;
  101204. /**
  101205. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101206. */
  101207. angularSensibilityY: number;
  101208. /**
  101209. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101210. */
  101211. pinchPrecision: number;
  101212. /**
  101213. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101214. * It will be used instead of pinchDeltaPrecision if different from 0.
  101215. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101216. */
  101217. pinchDeltaPercentage: number;
  101218. /**
  101219. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101220. */
  101221. panningSensibility: number;
  101222. /**
  101223. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101224. */
  101225. keysUp: number[];
  101226. /**
  101227. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101228. */
  101229. keysDown: number[];
  101230. /**
  101231. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101232. */
  101233. keysLeft: number[];
  101234. /**
  101235. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101236. */
  101237. keysRight: number[];
  101238. /**
  101239. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101240. */
  101241. wheelPrecision: number;
  101242. /**
  101243. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101244. * It will be used instead of pinchDeltaPrecision if different from 0.
  101245. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101246. */
  101247. wheelDeltaPercentage: number;
  101248. /**
  101249. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101250. */
  101251. zoomOnFactor: number;
  101252. /**
  101253. * Defines a screen offset for the camera position.
  101254. */
  101255. targetScreenOffset: Vector2;
  101256. /**
  101257. * Allows the camera to be completely reversed.
  101258. * If false the camera can not arrive upside down.
  101259. */
  101260. allowUpsideDown: boolean;
  101261. /**
  101262. * Define if double tap/click is used to restore the previously saved state of the camera.
  101263. */
  101264. useInputToRestoreState: boolean;
  101265. /** @hidden */
  101266. _viewMatrix: Matrix;
  101267. /** @hidden */
  101268. _useCtrlForPanning: boolean;
  101269. /** @hidden */
  101270. _panningMouseButton: number;
  101271. /**
  101272. * Defines the input associated to the camera.
  101273. */
  101274. inputs: ArcRotateCameraInputsManager;
  101275. /** @hidden */
  101276. _reset: () => void;
  101277. /**
  101278. * Defines the allowed panning axis.
  101279. */
  101280. panningAxis: Vector3;
  101281. protected _localDirection: Vector3;
  101282. protected _transformedDirection: Vector3;
  101283. private _bouncingBehavior;
  101284. /**
  101285. * Gets the bouncing behavior of the camera if it has been enabled.
  101286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101287. */
  101288. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101289. /**
  101290. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101292. */
  101293. useBouncingBehavior: boolean;
  101294. private _framingBehavior;
  101295. /**
  101296. * Gets the framing behavior of the camera if it has been enabled.
  101297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101298. */
  101299. readonly framingBehavior: Nullable<FramingBehavior>;
  101300. /**
  101301. * Defines if the framing behavior of the camera is enabled on the camera.
  101302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101303. */
  101304. useFramingBehavior: boolean;
  101305. private _autoRotationBehavior;
  101306. /**
  101307. * Gets the auto rotation behavior of the camera if it has been enabled.
  101308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101309. */
  101310. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101311. /**
  101312. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101314. */
  101315. useAutoRotationBehavior: boolean;
  101316. /**
  101317. * Observable triggered when the mesh target has been changed on the camera.
  101318. */
  101319. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101320. /**
  101321. * Event raised when the camera is colliding with a mesh.
  101322. */
  101323. onCollide: (collidedMesh: AbstractMesh) => void;
  101324. /**
  101325. * Defines whether the camera should check collision with the objects oh the scene.
  101326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101327. */
  101328. checkCollisions: boolean;
  101329. /**
  101330. * Defines the collision radius of the camera.
  101331. * This simulates a sphere around the camera.
  101332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101333. */
  101334. collisionRadius: Vector3;
  101335. protected _collider: Collider;
  101336. protected _previousPosition: Vector3;
  101337. protected _collisionVelocity: Vector3;
  101338. protected _newPosition: Vector3;
  101339. protected _previousAlpha: number;
  101340. protected _previousBeta: number;
  101341. protected _previousRadius: number;
  101342. protected _collisionTriggered: boolean;
  101343. protected _targetBoundingCenter: Nullable<Vector3>;
  101344. private _computationVector;
  101345. /**
  101346. * Instantiates a new ArcRotateCamera in a given scene
  101347. * @param name Defines the name of the camera
  101348. * @param alpha Defines the camera rotation along the logitudinal axis
  101349. * @param beta Defines the camera rotation along the latitudinal axis
  101350. * @param radius Defines the camera distance from its target
  101351. * @param target Defines the camera target
  101352. * @param scene Defines the scene the camera belongs to
  101353. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101354. */
  101355. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101356. /** @hidden */
  101357. _initCache(): void;
  101358. /** @hidden */
  101359. _updateCache(ignoreParentClass?: boolean): void;
  101360. protected _getTargetPosition(): Vector3;
  101361. private _storedAlpha;
  101362. private _storedBeta;
  101363. private _storedRadius;
  101364. private _storedTarget;
  101365. private _storedTargetScreenOffset;
  101366. /**
  101367. * Stores the current state of the camera (alpha, beta, radius and target)
  101368. * @returns the camera itself
  101369. */
  101370. storeState(): Camera;
  101371. /**
  101372. * @hidden
  101373. * Restored camera state. You must call storeState() first
  101374. */
  101375. _restoreStateValues(): boolean;
  101376. /** @hidden */
  101377. _isSynchronizedViewMatrix(): boolean;
  101378. /**
  101379. * Attached controls to the current camera.
  101380. * @param element Defines the element the controls should be listened from
  101381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101382. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101383. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101384. */
  101385. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101386. /**
  101387. * Detach the current controls from the camera.
  101388. * The camera will stop reacting to inputs.
  101389. * @param element Defines the element to stop listening the inputs from
  101390. */
  101391. detachControl(element: HTMLElement): void;
  101392. /** @hidden */
  101393. _checkInputs(): void;
  101394. protected _checkLimits(): void;
  101395. /**
  101396. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101397. */
  101398. rebuildAnglesAndRadius(): void;
  101399. /**
  101400. * Use a position to define the current camera related information like aplha, beta and radius
  101401. * @param position Defines the position to set the camera at
  101402. */
  101403. setPosition(position: Vector3): void;
  101404. /**
  101405. * Defines the target the camera should look at.
  101406. * This will automatically adapt alpha beta and radius to fit within the new target.
  101407. * @param target Defines the new target as a Vector or a mesh
  101408. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101409. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101410. */
  101411. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101412. /** @hidden */
  101413. _getViewMatrix(): Matrix;
  101414. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101415. /**
  101416. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101417. * @param meshes Defines the mesh to zoom on
  101418. * @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)
  101419. */
  101420. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101421. /**
  101422. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101423. * The target will be changed but the radius
  101424. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101425. * @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)
  101426. */
  101427. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101428. min: Vector3;
  101429. max: Vector3;
  101430. distance: number;
  101431. }, doNotUpdateMaxZ?: boolean): void;
  101432. /**
  101433. * @override
  101434. * Override Camera.createRigCamera
  101435. */
  101436. createRigCamera(name: string, cameraIndex: number): Camera;
  101437. /**
  101438. * @hidden
  101439. * @override
  101440. * Override Camera._updateRigCameras
  101441. */
  101442. _updateRigCameras(): void;
  101443. /**
  101444. * Destroy the camera and release the current resources hold by it.
  101445. */
  101446. dispose(): void;
  101447. /**
  101448. * Gets the current object class name.
  101449. * @return the class name
  101450. */
  101451. getClassName(): string;
  101452. }
  101453. }
  101454. declare module BABYLON {
  101455. /**
  101456. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101457. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101458. */
  101459. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101460. /**
  101461. * Gets the name of the behavior.
  101462. */
  101463. readonly name: string;
  101464. private _zoomStopsAnimation;
  101465. private _idleRotationSpeed;
  101466. private _idleRotationWaitTime;
  101467. private _idleRotationSpinupTime;
  101468. /**
  101469. * Sets the flag that indicates if user zooming should stop animation.
  101470. */
  101471. /**
  101472. * Gets the flag that indicates if user zooming should stop animation.
  101473. */
  101474. zoomStopsAnimation: boolean;
  101475. /**
  101476. * Sets the default speed at which the camera rotates around the model.
  101477. */
  101478. /**
  101479. * Gets the default speed at which the camera rotates around the model.
  101480. */
  101481. idleRotationSpeed: number;
  101482. /**
  101483. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101484. */
  101485. /**
  101486. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101487. */
  101488. idleRotationWaitTime: number;
  101489. /**
  101490. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101491. */
  101492. /**
  101493. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101494. */
  101495. idleRotationSpinupTime: number;
  101496. /**
  101497. * Gets a value indicating if the camera is currently rotating because of this behavior
  101498. */
  101499. readonly rotationInProgress: boolean;
  101500. private _onPrePointerObservableObserver;
  101501. private _onAfterCheckInputsObserver;
  101502. private _attachedCamera;
  101503. private _isPointerDown;
  101504. private _lastFrameTime;
  101505. private _lastInteractionTime;
  101506. private _cameraRotationSpeed;
  101507. /**
  101508. * Initializes the behavior.
  101509. */
  101510. init(): void;
  101511. /**
  101512. * Attaches the behavior to its arc rotate camera.
  101513. * @param camera Defines the camera to attach the behavior to
  101514. */
  101515. attach(camera: ArcRotateCamera): void;
  101516. /**
  101517. * Detaches the behavior from its current arc rotate camera.
  101518. */
  101519. detach(): void;
  101520. /**
  101521. * Returns true if user is scrolling.
  101522. * @return true if user is scrolling.
  101523. */
  101524. private _userIsZooming;
  101525. private _lastFrameRadius;
  101526. private _shouldAnimationStopForInteraction;
  101527. /**
  101528. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101529. */
  101530. private _applyUserInteraction;
  101531. private _userIsMoving;
  101532. }
  101533. }
  101534. declare module BABYLON {
  101535. /**
  101536. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101537. */
  101538. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101539. private ui;
  101540. /**
  101541. * The name of the behavior
  101542. */
  101543. name: string;
  101544. /**
  101545. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101546. */
  101547. distanceAwayFromFace: number;
  101548. /**
  101549. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101550. */
  101551. distanceAwayFromBottomOfFace: number;
  101552. private _faceVectors;
  101553. private _target;
  101554. private _scene;
  101555. private _onRenderObserver;
  101556. private _tmpMatrix;
  101557. private _tmpVector;
  101558. /**
  101559. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  101560. * @param ui The transform node that should be attched to the mesh
  101561. */
  101562. constructor(ui: TransformNode);
  101563. /**
  101564. * Initializes the behavior
  101565. */
  101566. init(): void;
  101567. private _closestFace;
  101568. private _zeroVector;
  101569. private _lookAtTmpMatrix;
  101570. private _lookAtToRef;
  101571. /**
  101572. * Attaches the AttachToBoxBehavior to the passed in mesh
  101573. * @param target The mesh that the specified node will be attached to
  101574. */
  101575. attach(target: Mesh): void;
  101576. /**
  101577. * Detaches the behavior from the mesh
  101578. */
  101579. detach(): void;
  101580. }
  101581. }
  101582. declare module BABYLON {
  101583. /**
  101584. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  101585. */
  101586. export class FadeInOutBehavior implements Behavior<Mesh> {
  101587. /**
  101588. * Time in milliseconds to delay before fading in (Default: 0)
  101589. */
  101590. delay: number;
  101591. /**
  101592. * Time in milliseconds for the mesh to fade in (Default: 300)
  101593. */
  101594. fadeInTime: number;
  101595. private _millisecondsPerFrame;
  101596. private _hovered;
  101597. private _hoverValue;
  101598. private _ownerNode;
  101599. /**
  101600. * Instatiates the FadeInOutBehavior
  101601. */
  101602. constructor();
  101603. /**
  101604. * The name of the behavior
  101605. */
  101606. readonly name: string;
  101607. /**
  101608. * Initializes the behavior
  101609. */
  101610. init(): void;
  101611. /**
  101612. * Attaches the fade behavior on the passed in mesh
  101613. * @param ownerNode The mesh that will be faded in/out once attached
  101614. */
  101615. attach(ownerNode: Mesh): void;
  101616. /**
  101617. * Detaches the behavior from the mesh
  101618. */
  101619. detach(): void;
  101620. /**
  101621. * Triggers the mesh to begin fading in or out
  101622. * @param value if the object should fade in or out (true to fade in)
  101623. */
  101624. fadeIn(value: boolean): void;
  101625. private _update;
  101626. private _setAllVisibility;
  101627. }
  101628. }
  101629. declare module BABYLON {
  101630. /**
  101631. * Class containing a set of static utilities functions for managing Pivots
  101632. * @hidden
  101633. */
  101634. export class PivotTools {
  101635. private static _PivotCached;
  101636. private static _OldPivotPoint;
  101637. private static _PivotTranslation;
  101638. private static _PivotTmpVector;
  101639. /** @hidden */
  101640. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101641. /** @hidden */
  101642. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101643. }
  101644. }
  101645. declare module BABYLON {
  101646. /**
  101647. * Class containing static functions to help procedurally build meshes
  101648. */
  101649. export class PlaneBuilder {
  101650. /**
  101651. * Creates a plane mesh
  101652. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101653. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101654. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101658. * @param name defines the name of the mesh
  101659. * @param options defines the options used to create the mesh
  101660. * @param scene defines the hosting scene
  101661. * @returns the plane mesh
  101662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101663. */
  101664. static CreatePlane(name: string, options: {
  101665. size?: number;
  101666. width?: number;
  101667. height?: number;
  101668. sideOrientation?: number;
  101669. frontUVs?: Vector4;
  101670. backUVs?: Vector4;
  101671. updatable?: boolean;
  101672. sourcePlane?: Plane;
  101673. }, scene?: Nullable<Scene>): Mesh;
  101674. }
  101675. }
  101676. declare module BABYLON {
  101677. /**
  101678. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101679. */
  101680. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101681. private static _AnyMouseID;
  101682. /**
  101683. * Abstract mesh the behavior is set on
  101684. */
  101685. attachedNode: AbstractMesh;
  101686. private _dragPlane;
  101687. private _scene;
  101688. private _pointerObserver;
  101689. private _beforeRenderObserver;
  101690. private static _planeScene;
  101691. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101692. /**
  101693. * 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)
  101694. */
  101695. maxDragAngle: number;
  101696. /**
  101697. * @hidden
  101698. */
  101699. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101700. /**
  101701. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101702. */
  101703. currentDraggingPointerID: number;
  101704. /**
  101705. * The last position where the pointer hit the drag plane in world space
  101706. */
  101707. lastDragPosition: Vector3;
  101708. /**
  101709. * If the behavior is currently in a dragging state
  101710. */
  101711. dragging: boolean;
  101712. /**
  101713. * 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)
  101714. */
  101715. dragDeltaRatio: number;
  101716. /**
  101717. * If the drag plane orientation should be updated during the dragging (Default: true)
  101718. */
  101719. updateDragPlane: boolean;
  101720. private _debugMode;
  101721. private _moving;
  101722. /**
  101723. * Fires each time the attached mesh is dragged with the pointer
  101724. * * delta between last drag position and current drag position in world space
  101725. * * dragDistance along the drag axis
  101726. * * dragPlaneNormal normal of the current drag plane used during the drag
  101727. * * dragPlanePoint in world space where the drag intersects the drag plane
  101728. */
  101729. onDragObservable: Observable<{
  101730. delta: Vector3;
  101731. dragPlanePoint: Vector3;
  101732. dragPlaneNormal: Vector3;
  101733. dragDistance: number;
  101734. pointerId: number;
  101735. }>;
  101736. /**
  101737. * Fires each time a drag begins (eg. mouse down on mesh)
  101738. */
  101739. onDragStartObservable: Observable<{
  101740. dragPlanePoint: Vector3;
  101741. pointerId: number;
  101742. }>;
  101743. /**
  101744. * Fires each time a drag ends (eg. mouse release after drag)
  101745. */
  101746. onDragEndObservable: Observable<{
  101747. dragPlanePoint: Vector3;
  101748. pointerId: number;
  101749. }>;
  101750. /**
  101751. * If the attached mesh should be moved when dragged
  101752. */
  101753. moveAttached: boolean;
  101754. /**
  101755. * If the drag behavior will react to drag events (Default: true)
  101756. */
  101757. enabled: boolean;
  101758. /**
  101759. * If pointer events should start and release the drag (Default: true)
  101760. */
  101761. startAndReleaseDragOnPointerEvents: boolean;
  101762. /**
  101763. * If camera controls should be detached during the drag
  101764. */
  101765. detachCameraControls: boolean;
  101766. /**
  101767. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101768. */
  101769. useObjectOrienationForDragging: boolean;
  101770. private _options;
  101771. /**
  101772. * Creates a pointer drag behavior that can be attached to a mesh
  101773. * @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)
  101774. */
  101775. constructor(options?: {
  101776. dragAxis?: Vector3;
  101777. dragPlaneNormal?: Vector3;
  101778. });
  101779. /**
  101780. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101781. */
  101782. validateDrag: (targetPosition: Vector3) => boolean;
  101783. /**
  101784. * The name of the behavior
  101785. */
  101786. readonly name: string;
  101787. /**
  101788. * Initializes the behavior
  101789. */
  101790. init(): void;
  101791. private _tmpVector;
  101792. private _alternatePickedPoint;
  101793. private _worldDragAxis;
  101794. private _targetPosition;
  101795. private _attachedElement;
  101796. /**
  101797. * Attaches the drag behavior the passed in mesh
  101798. * @param ownerNode The mesh that will be dragged around once attached
  101799. */
  101800. attach(ownerNode: AbstractMesh): void;
  101801. /**
  101802. * Force relase the drag action by code.
  101803. */
  101804. releaseDrag(): void;
  101805. private _startDragRay;
  101806. private _lastPointerRay;
  101807. /**
  101808. * Simulates the start of a pointer drag event on the behavior
  101809. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101810. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101811. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101812. */
  101813. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101814. private _startDrag;
  101815. private _dragDelta;
  101816. private _moveDrag;
  101817. private _pickWithRayOnDragPlane;
  101818. private _pointA;
  101819. private _pointB;
  101820. private _pointC;
  101821. private _lineA;
  101822. private _lineB;
  101823. private _localAxis;
  101824. private _lookAt;
  101825. private _updateDragPlanePosition;
  101826. /**
  101827. * Detaches the behavior from the mesh
  101828. */
  101829. detach(): void;
  101830. }
  101831. }
  101832. declare module BABYLON {
  101833. /**
  101834. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101835. */
  101836. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101837. private _dragBehaviorA;
  101838. private _dragBehaviorB;
  101839. private _startDistance;
  101840. private _initialScale;
  101841. private _targetScale;
  101842. private _ownerNode;
  101843. private _sceneRenderObserver;
  101844. /**
  101845. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101846. */
  101847. constructor();
  101848. /**
  101849. * The name of the behavior
  101850. */
  101851. readonly name: string;
  101852. /**
  101853. * Initializes the behavior
  101854. */
  101855. init(): void;
  101856. private _getCurrentDistance;
  101857. /**
  101858. * Attaches the scale behavior the passed in mesh
  101859. * @param ownerNode The mesh that will be scaled around once attached
  101860. */
  101861. attach(ownerNode: Mesh): void;
  101862. /**
  101863. * Detaches the behavior from the mesh
  101864. */
  101865. detach(): void;
  101866. }
  101867. }
  101868. declare module BABYLON {
  101869. /**
  101870. * 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
  101871. */
  101872. export class SixDofDragBehavior implements Behavior<Mesh> {
  101873. private static _virtualScene;
  101874. private _ownerNode;
  101875. private _sceneRenderObserver;
  101876. private _scene;
  101877. private _targetPosition;
  101878. private _virtualOriginMesh;
  101879. private _virtualDragMesh;
  101880. private _pointerObserver;
  101881. private _moving;
  101882. private _startingOrientation;
  101883. /**
  101884. * 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)
  101885. */
  101886. private zDragFactor;
  101887. /**
  101888. * If the object should rotate to face the drag origin
  101889. */
  101890. rotateDraggedObject: boolean;
  101891. /**
  101892. * If the behavior is currently in a dragging state
  101893. */
  101894. dragging: boolean;
  101895. /**
  101896. * 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)
  101897. */
  101898. dragDeltaRatio: number;
  101899. /**
  101900. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101901. */
  101902. currentDraggingPointerID: number;
  101903. /**
  101904. * If camera controls should be detached during the drag
  101905. */
  101906. detachCameraControls: boolean;
  101907. /**
  101908. * Fires each time a drag starts
  101909. */
  101910. onDragStartObservable: Observable<{}>;
  101911. /**
  101912. * Fires each time a drag ends (eg. mouse release after drag)
  101913. */
  101914. onDragEndObservable: Observable<{}>;
  101915. /**
  101916. * 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
  101917. */
  101918. constructor();
  101919. /**
  101920. * The name of the behavior
  101921. */
  101922. readonly name: string;
  101923. /**
  101924. * Initializes the behavior
  101925. */
  101926. init(): void;
  101927. /**
  101928. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101929. */
  101930. private readonly _pointerCamera;
  101931. /**
  101932. * Attaches the scale behavior the passed in mesh
  101933. * @param ownerNode The mesh that will be scaled around once attached
  101934. */
  101935. attach(ownerNode: Mesh): void;
  101936. /**
  101937. * Detaches the behavior from the mesh
  101938. */
  101939. detach(): void;
  101940. }
  101941. }
  101942. declare module BABYLON {
  101943. /**
  101944. * Class used to apply inverse kinematics to bones
  101945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101946. */
  101947. export class BoneIKController {
  101948. private static _tmpVecs;
  101949. private static _tmpQuat;
  101950. private static _tmpMats;
  101951. /**
  101952. * Gets or sets the target mesh
  101953. */
  101954. targetMesh: AbstractMesh;
  101955. /** Gets or sets the mesh used as pole */
  101956. poleTargetMesh: AbstractMesh;
  101957. /**
  101958. * Gets or sets the bone used as pole
  101959. */
  101960. poleTargetBone: Nullable<Bone>;
  101961. /**
  101962. * Gets or sets the target position
  101963. */
  101964. targetPosition: Vector3;
  101965. /**
  101966. * Gets or sets the pole target position
  101967. */
  101968. poleTargetPosition: Vector3;
  101969. /**
  101970. * Gets or sets the pole target local offset
  101971. */
  101972. poleTargetLocalOffset: Vector3;
  101973. /**
  101974. * Gets or sets the pole angle
  101975. */
  101976. poleAngle: number;
  101977. /**
  101978. * Gets or sets the mesh associated with the controller
  101979. */
  101980. mesh: AbstractMesh;
  101981. /**
  101982. * 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)
  101983. */
  101984. slerpAmount: number;
  101985. private _bone1Quat;
  101986. private _bone1Mat;
  101987. private _bone2Ang;
  101988. private _bone1;
  101989. private _bone2;
  101990. private _bone1Length;
  101991. private _bone2Length;
  101992. private _maxAngle;
  101993. private _maxReach;
  101994. private _rightHandedSystem;
  101995. private _bendAxis;
  101996. private _slerping;
  101997. private _adjustRoll;
  101998. /**
  101999. * Gets or sets maximum allowed angle
  102000. */
  102001. maxAngle: number;
  102002. /**
  102003. * Creates a new BoneIKController
  102004. * @param mesh defines the mesh to control
  102005. * @param bone defines the bone to control
  102006. * @param options defines options to set up the controller
  102007. */
  102008. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102009. targetMesh?: AbstractMesh;
  102010. poleTargetMesh?: AbstractMesh;
  102011. poleTargetBone?: Bone;
  102012. poleTargetLocalOffset?: Vector3;
  102013. poleAngle?: number;
  102014. bendAxis?: Vector3;
  102015. maxAngle?: number;
  102016. slerpAmount?: number;
  102017. });
  102018. private _setMaxAngle;
  102019. /**
  102020. * Force the controller to update the bones
  102021. */
  102022. update(): void;
  102023. }
  102024. }
  102025. declare module BABYLON {
  102026. /**
  102027. * Class used to make a bone look toward a point in space
  102028. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102029. */
  102030. export class BoneLookController {
  102031. private static _tmpVecs;
  102032. private static _tmpQuat;
  102033. private static _tmpMats;
  102034. /**
  102035. * The target Vector3 that the bone will look at
  102036. */
  102037. target: Vector3;
  102038. /**
  102039. * The mesh that the bone is attached to
  102040. */
  102041. mesh: AbstractMesh;
  102042. /**
  102043. * The bone that will be looking to the target
  102044. */
  102045. bone: Bone;
  102046. /**
  102047. * The up axis of the coordinate system that is used when the bone is rotated
  102048. */
  102049. upAxis: Vector3;
  102050. /**
  102051. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102052. */
  102053. upAxisSpace: Space;
  102054. /**
  102055. * Used to make an adjustment to the yaw of the bone
  102056. */
  102057. adjustYaw: number;
  102058. /**
  102059. * Used to make an adjustment to the pitch of the bone
  102060. */
  102061. adjustPitch: number;
  102062. /**
  102063. * Used to make an adjustment to the roll of the bone
  102064. */
  102065. adjustRoll: number;
  102066. /**
  102067. * 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)
  102068. */
  102069. slerpAmount: number;
  102070. private _minYaw;
  102071. private _maxYaw;
  102072. private _minPitch;
  102073. private _maxPitch;
  102074. private _minYawSin;
  102075. private _minYawCos;
  102076. private _maxYawSin;
  102077. private _maxYawCos;
  102078. private _midYawConstraint;
  102079. private _minPitchTan;
  102080. private _maxPitchTan;
  102081. private _boneQuat;
  102082. private _slerping;
  102083. private _transformYawPitch;
  102084. private _transformYawPitchInv;
  102085. private _firstFrameSkipped;
  102086. private _yawRange;
  102087. private _fowardAxis;
  102088. /**
  102089. * Gets or sets the minimum yaw angle that the bone can look to
  102090. */
  102091. minYaw: number;
  102092. /**
  102093. * Gets or sets the maximum yaw angle that the bone can look to
  102094. */
  102095. maxYaw: number;
  102096. /**
  102097. * Gets or sets the minimum pitch angle that the bone can look to
  102098. */
  102099. minPitch: number;
  102100. /**
  102101. * Gets or sets the maximum pitch angle that the bone can look to
  102102. */
  102103. maxPitch: number;
  102104. /**
  102105. * Create a BoneLookController
  102106. * @param mesh the mesh that the bone belongs to
  102107. * @param bone the bone that will be looking to the target
  102108. * @param target the target Vector3 to look at
  102109. * @param options optional settings:
  102110. * * maxYaw: the maximum angle the bone will yaw to
  102111. * * minYaw: the minimum angle the bone will yaw to
  102112. * * maxPitch: the maximum angle the bone will pitch to
  102113. * * minPitch: the minimum angle the bone will yaw to
  102114. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102115. * * upAxis: the up axis of the coordinate system
  102116. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102117. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102118. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102119. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102120. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102121. * * adjustRoll: used to make an adjustment to the roll of the bone
  102122. **/
  102123. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102124. maxYaw?: number;
  102125. minYaw?: number;
  102126. maxPitch?: number;
  102127. minPitch?: number;
  102128. slerpAmount?: number;
  102129. upAxis?: Vector3;
  102130. upAxisSpace?: Space;
  102131. yawAxis?: Vector3;
  102132. pitchAxis?: Vector3;
  102133. adjustYaw?: number;
  102134. adjustPitch?: number;
  102135. adjustRoll?: number;
  102136. });
  102137. /**
  102138. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102139. */
  102140. update(): void;
  102141. private _getAngleDiff;
  102142. private _getAngleBetween;
  102143. private _isAngleBetween;
  102144. }
  102145. }
  102146. declare module BABYLON {
  102147. /**
  102148. * Manage the gamepad inputs to control an arc rotate camera.
  102149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102150. */
  102151. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102152. /**
  102153. * Defines the camera the input is attached to.
  102154. */
  102155. camera: ArcRotateCamera;
  102156. /**
  102157. * Defines the gamepad the input is gathering event from.
  102158. */
  102159. gamepad: Nullable<Gamepad>;
  102160. /**
  102161. * Defines the gamepad rotation sensiblity.
  102162. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102163. */
  102164. gamepadRotationSensibility: number;
  102165. /**
  102166. * Defines the gamepad move sensiblity.
  102167. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102168. */
  102169. gamepadMoveSensibility: number;
  102170. private _onGamepadConnectedObserver;
  102171. private _onGamepadDisconnectedObserver;
  102172. /**
  102173. * Attach the input controls to a specific dom element to get the input from.
  102174. * @param element Defines the element the controls should be listened from
  102175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102176. */
  102177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102178. /**
  102179. * Detach the current controls from the specified dom element.
  102180. * @param element Defines the element to stop listening the inputs from
  102181. */
  102182. detachControl(element: Nullable<HTMLElement>): void;
  102183. /**
  102184. * Update the current camera state depending on the inputs that have been used this frame.
  102185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102186. */
  102187. checkInputs(): void;
  102188. /**
  102189. * Gets the class name of the current intput.
  102190. * @returns the class name
  102191. */
  102192. getClassName(): string;
  102193. /**
  102194. * Get the friendly name associated with the input class.
  102195. * @returns the input friendly name
  102196. */
  102197. getSimpleName(): string;
  102198. }
  102199. }
  102200. declare module BABYLON {
  102201. interface ArcRotateCameraInputsManager {
  102202. /**
  102203. * Add orientation input support to the input manager.
  102204. * @returns the current input manager
  102205. */
  102206. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102207. }
  102208. /**
  102209. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102211. */
  102212. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102213. /**
  102214. * Defines the camera the input is attached to.
  102215. */
  102216. camera: ArcRotateCamera;
  102217. /**
  102218. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102219. */
  102220. alphaCorrection: number;
  102221. /**
  102222. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102223. */
  102224. gammaCorrection: number;
  102225. private _alpha;
  102226. private _gamma;
  102227. private _dirty;
  102228. private _deviceOrientationHandler;
  102229. /**
  102230. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102231. */
  102232. constructor();
  102233. /**
  102234. * Attach the input controls to a specific dom element to get the input from.
  102235. * @param element Defines the element the controls should be listened from
  102236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102237. */
  102238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102239. /** @hidden */
  102240. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102241. /**
  102242. * Update the current camera state depending on the inputs that have been used this frame.
  102243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102244. */
  102245. checkInputs(): void;
  102246. /**
  102247. * Detach the current controls from the specified dom element.
  102248. * @param element Defines the element to stop listening the inputs from
  102249. */
  102250. detachControl(element: Nullable<HTMLElement>): void;
  102251. /**
  102252. * Gets the class name of the current intput.
  102253. * @returns the class name
  102254. */
  102255. getClassName(): string;
  102256. /**
  102257. * Get the friendly name associated with the input class.
  102258. * @returns the input friendly name
  102259. */
  102260. getSimpleName(): string;
  102261. }
  102262. }
  102263. declare module BABYLON {
  102264. /**
  102265. * Listen to mouse events to control the camera.
  102266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102267. */
  102268. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102269. /**
  102270. * Defines the camera the input is attached to.
  102271. */
  102272. camera: FlyCamera;
  102273. /**
  102274. * Defines if touch is enabled. (Default is true.)
  102275. */
  102276. touchEnabled: boolean;
  102277. /**
  102278. * Defines the buttons associated with the input to handle camera rotation.
  102279. */
  102280. buttons: number[];
  102281. /**
  102282. * Assign buttons for Yaw control.
  102283. */
  102284. buttonsYaw: number[];
  102285. /**
  102286. * Assign buttons for Pitch control.
  102287. */
  102288. buttonsPitch: number[];
  102289. /**
  102290. * Assign buttons for Roll control.
  102291. */
  102292. buttonsRoll: number[];
  102293. /**
  102294. * Detect if any button is being pressed while mouse is moved.
  102295. * -1 = Mouse locked.
  102296. * 0 = Left button.
  102297. * 1 = Middle Button.
  102298. * 2 = Right Button.
  102299. */
  102300. activeButton: number;
  102301. /**
  102302. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102303. * Higher values reduce its sensitivity.
  102304. */
  102305. angularSensibility: number;
  102306. private _mousemoveCallback;
  102307. private _observer;
  102308. private _rollObserver;
  102309. private previousPosition;
  102310. private noPreventDefault;
  102311. private element;
  102312. /**
  102313. * Listen to mouse events to control the camera.
  102314. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102316. */
  102317. constructor(touchEnabled?: boolean);
  102318. /**
  102319. * Attach the mouse control to the HTML DOM element.
  102320. * @param element Defines the element that listens to the input events.
  102321. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102322. */
  102323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102324. /**
  102325. * Detach the current controls from the specified dom element.
  102326. * @param element Defines the element to stop listening the inputs from
  102327. */
  102328. detachControl(element: Nullable<HTMLElement>): void;
  102329. /**
  102330. * Gets the class name of the current input.
  102331. * @returns the class name.
  102332. */
  102333. getClassName(): string;
  102334. /**
  102335. * Get the friendly name associated with the input class.
  102336. * @returns the input's friendly name.
  102337. */
  102338. getSimpleName(): string;
  102339. private _pointerInput;
  102340. private _onMouseMove;
  102341. /**
  102342. * Rotate camera by mouse offset.
  102343. */
  102344. private rotateCamera;
  102345. }
  102346. }
  102347. declare module BABYLON {
  102348. /**
  102349. * Default Inputs manager for the FlyCamera.
  102350. * It groups all the default supported inputs for ease of use.
  102351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102352. */
  102353. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102354. /**
  102355. * Instantiates a new FlyCameraInputsManager.
  102356. * @param camera Defines the camera the inputs belong to.
  102357. */
  102358. constructor(camera: FlyCamera);
  102359. /**
  102360. * Add keyboard input support to the input manager.
  102361. * @returns the new FlyCameraKeyboardMoveInput().
  102362. */
  102363. addKeyboard(): FlyCameraInputsManager;
  102364. /**
  102365. * Add mouse input support to the input manager.
  102366. * @param touchEnabled Enable touch screen support.
  102367. * @returns the new FlyCameraMouseInput().
  102368. */
  102369. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102370. }
  102371. }
  102372. declare module BABYLON {
  102373. /**
  102374. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102375. * such as in a 3D Space Shooter or a Flight Simulator.
  102376. */
  102377. export class FlyCamera extends TargetCamera {
  102378. /**
  102379. * Define the collision ellipsoid of the camera.
  102380. * This is helpful for simulating a camera body, like a player's body.
  102381. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102382. */
  102383. ellipsoid: Vector3;
  102384. /**
  102385. * Define an offset for the position of the ellipsoid around the camera.
  102386. * This can be helpful if the camera is attached away from the player's body center,
  102387. * such as at its head.
  102388. */
  102389. ellipsoidOffset: Vector3;
  102390. /**
  102391. * Enable or disable collisions of the camera with the rest of the scene objects.
  102392. */
  102393. checkCollisions: boolean;
  102394. /**
  102395. * Enable or disable gravity on the camera.
  102396. */
  102397. applyGravity: boolean;
  102398. /**
  102399. * Define the current direction the camera is moving to.
  102400. */
  102401. cameraDirection: Vector3;
  102402. /**
  102403. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102404. * This overrides and empties cameraRotation.
  102405. */
  102406. rotationQuaternion: Quaternion;
  102407. /**
  102408. * Track Roll to maintain the wanted Rolling when looking around.
  102409. */
  102410. _trackRoll: number;
  102411. /**
  102412. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102413. */
  102414. rollCorrect: number;
  102415. /**
  102416. * Mimic a banked turn, Rolling the camera when Yawing.
  102417. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102418. */
  102419. bankedTurn: boolean;
  102420. /**
  102421. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102422. */
  102423. bankedTurnLimit: number;
  102424. /**
  102425. * Value of 0 disables the banked Roll.
  102426. * Value of 1 is equal to the Yaw angle in radians.
  102427. */
  102428. bankedTurnMultiplier: number;
  102429. /**
  102430. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102431. */
  102432. inputs: FlyCameraInputsManager;
  102433. /**
  102434. * Gets the input sensibility for mouse input.
  102435. * Higher values reduce sensitivity.
  102436. */
  102437. /**
  102438. * Sets the input sensibility for a mouse input.
  102439. * Higher values reduce sensitivity.
  102440. */
  102441. angularSensibility: number;
  102442. /**
  102443. * Get the keys for camera movement forward.
  102444. */
  102445. /**
  102446. * Set the keys for camera movement forward.
  102447. */
  102448. keysForward: number[];
  102449. /**
  102450. * Get the keys for camera movement backward.
  102451. */
  102452. keysBackward: number[];
  102453. /**
  102454. * Get the keys for camera movement up.
  102455. */
  102456. /**
  102457. * Set the keys for camera movement up.
  102458. */
  102459. keysUp: number[];
  102460. /**
  102461. * Get the keys for camera movement down.
  102462. */
  102463. /**
  102464. * Set the keys for camera movement down.
  102465. */
  102466. keysDown: number[];
  102467. /**
  102468. * Get the keys for camera movement left.
  102469. */
  102470. /**
  102471. * Set the keys for camera movement left.
  102472. */
  102473. keysLeft: number[];
  102474. /**
  102475. * Set the keys for camera movement right.
  102476. */
  102477. /**
  102478. * Set the keys for camera movement right.
  102479. */
  102480. keysRight: number[];
  102481. /**
  102482. * Event raised when the camera collides with a mesh in the scene.
  102483. */
  102484. onCollide: (collidedMesh: AbstractMesh) => void;
  102485. private _collider;
  102486. private _needMoveForGravity;
  102487. private _oldPosition;
  102488. private _diffPosition;
  102489. private _newPosition;
  102490. /** @hidden */
  102491. _localDirection: Vector3;
  102492. /** @hidden */
  102493. _transformedDirection: Vector3;
  102494. /**
  102495. * Instantiates a FlyCamera.
  102496. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102497. * such as in a 3D Space Shooter or a Flight Simulator.
  102498. * @param name Define the name of the camera in the scene.
  102499. * @param position Define the starting position of the camera in the scene.
  102500. * @param scene Define the scene the camera belongs to.
  102501. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102502. */
  102503. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102504. /**
  102505. * Attach a control to the HTML DOM element.
  102506. * @param element Defines the element that listens to the input events.
  102507. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102508. */
  102509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102510. /**
  102511. * Detach a control from the HTML DOM element.
  102512. * The camera will stop reacting to that input.
  102513. * @param element Defines the element that listens to the input events.
  102514. */
  102515. detachControl(element: HTMLElement): void;
  102516. private _collisionMask;
  102517. /**
  102518. * Get the mask that the camera ignores in collision events.
  102519. */
  102520. /**
  102521. * Set the mask that the camera ignores in collision events.
  102522. */
  102523. collisionMask: number;
  102524. /** @hidden */
  102525. _collideWithWorld(displacement: Vector3): void;
  102526. /** @hidden */
  102527. private _onCollisionPositionChange;
  102528. /** @hidden */
  102529. _checkInputs(): void;
  102530. /** @hidden */
  102531. _decideIfNeedsToMove(): boolean;
  102532. /** @hidden */
  102533. _updatePosition(): void;
  102534. /**
  102535. * Restore the Roll to its target value at the rate specified.
  102536. * @param rate - Higher means slower restoring.
  102537. * @hidden
  102538. */
  102539. restoreRoll(rate: number): void;
  102540. /**
  102541. * Destroy the camera and release the current resources held by it.
  102542. */
  102543. dispose(): void;
  102544. /**
  102545. * Get the current object class name.
  102546. * @returns the class name.
  102547. */
  102548. getClassName(): string;
  102549. }
  102550. }
  102551. declare module BABYLON {
  102552. /**
  102553. * Listen to keyboard events to control the camera.
  102554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102555. */
  102556. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  102557. /**
  102558. * Defines the camera the input is attached to.
  102559. */
  102560. camera: FlyCamera;
  102561. /**
  102562. * The list of keyboard keys used to control the forward move of the camera.
  102563. */
  102564. keysForward: number[];
  102565. /**
  102566. * The list of keyboard keys used to control the backward move of the camera.
  102567. */
  102568. keysBackward: number[];
  102569. /**
  102570. * The list of keyboard keys used to control the forward move of the camera.
  102571. */
  102572. keysUp: number[];
  102573. /**
  102574. * The list of keyboard keys used to control the backward move of the camera.
  102575. */
  102576. keysDown: number[];
  102577. /**
  102578. * The list of keyboard keys used to control the right strafe move of the camera.
  102579. */
  102580. keysRight: number[];
  102581. /**
  102582. * The list of keyboard keys used to control the left strafe move of the camera.
  102583. */
  102584. keysLeft: number[];
  102585. private _keys;
  102586. private _onCanvasBlurObserver;
  102587. private _onKeyboardObserver;
  102588. private _engine;
  102589. private _scene;
  102590. /**
  102591. * Attach the input controls to a specific dom element to get the input from.
  102592. * @param element Defines the element the controls should be listened from
  102593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102594. */
  102595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102596. /**
  102597. * Detach the current controls from the specified dom element.
  102598. * @param element Defines the element to stop listening the inputs from
  102599. */
  102600. detachControl(element: Nullable<HTMLElement>): void;
  102601. /**
  102602. * Gets the class name of the current intput.
  102603. * @returns the class name
  102604. */
  102605. getClassName(): string;
  102606. /** @hidden */
  102607. _onLostFocus(e: FocusEvent): void;
  102608. /**
  102609. * Get the friendly name associated with the input class.
  102610. * @returns the input friendly name
  102611. */
  102612. getSimpleName(): string;
  102613. /**
  102614. * Update the current camera state depending on the inputs that have been used this frame.
  102615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102616. */
  102617. checkInputs(): void;
  102618. }
  102619. }
  102620. declare module BABYLON {
  102621. /**
  102622. * Manage the mouse wheel inputs to control a follow camera.
  102623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102624. */
  102625. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102626. /**
  102627. * Defines the camera the input is attached to.
  102628. */
  102629. camera: FollowCamera;
  102630. /**
  102631. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102632. */
  102633. axisControlRadius: boolean;
  102634. /**
  102635. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102636. */
  102637. axisControlHeight: boolean;
  102638. /**
  102639. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102640. */
  102641. axisControlRotation: boolean;
  102642. /**
  102643. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102644. * relation to mouseWheel events.
  102645. */
  102646. wheelPrecision: number;
  102647. /**
  102648. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102649. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102650. */
  102651. wheelDeltaPercentage: number;
  102652. private _wheel;
  102653. private _observer;
  102654. /**
  102655. * Attach the input controls to a specific dom element to get the input from.
  102656. * @param element Defines the element the controls should be listened from
  102657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102658. */
  102659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102660. /**
  102661. * Detach the current controls from the specified dom element.
  102662. * @param element Defines the element to stop listening the inputs from
  102663. */
  102664. detachControl(element: Nullable<HTMLElement>): void;
  102665. /**
  102666. * Gets the class name of the current intput.
  102667. * @returns the class name
  102668. */
  102669. getClassName(): string;
  102670. /**
  102671. * Get the friendly name associated with the input class.
  102672. * @returns the input friendly name
  102673. */
  102674. getSimpleName(): string;
  102675. }
  102676. }
  102677. declare module BABYLON {
  102678. /**
  102679. * Manage the pointers inputs to control an follow camera.
  102680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102681. */
  102682. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102683. /**
  102684. * Defines the camera the input is attached to.
  102685. */
  102686. camera: FollowCamera;
  102687. /**
  102688. * Gets the class name of the current input.
  102689. * @returns the class name
  102690. */
  102691. getClassName(): string;
  102692. /**
  102693. * Defines the pointer angular sensibility along the X axis or how fast is
  102694. * the camera rotating.
  102695. * A negative number will reverse the axis direction.
  102696. */
  102697. angularSensibilityX: number;
  102698. /**
  102699. * Defines the pointer angular sensibility along the Y axis or how fast is
  102700. * the camera rotating.
  102701. * A negative number will reverse the axis direction.
  102702. */
  102703. angularSensibilityY: number;
  102704. /**
  102705. * Defines the pointer pinch precision or how fast is the camera zooming.
  102706. * A negative number will reverse the axis direction.
  102707. */
  102708. pinchPrecision: number;
  102709. /**
  102710. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102711. * from 0.
  102712. * It defines the percentage of current camera.radius to use as delta when
  102713. * pinch zoom is used.
  102714. */
  102715. pinchDeltaPercentage: number;
  102716. /**
  102717. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102718. */
  102719. axisXControlRadius: boolean;
  102720. /**
  102721. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102722. */
  102723. axisXControlHeight: boolean;
  102724. /**
  102725. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102726. */
  102727. axisXControlRotation: boolean;
  102728. /**
  102729. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102730. */
  102731. axisYControlRadius: boolean;
  102732. /**
  102733. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102734. */
  102735. axisYControlHeight: boolean;
  102736. /**
  102737. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102738. */
  102739. axisYControlRotation: boolean;
  102740. /**
  102741. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102742. */
  102743. axisPinchControlRadius: boolean;
  102744. /**
  102745. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102746. */
  102747. axisPinchControlHeight: boolean;
  102748. /**
  102749. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102750. */
  102751. axisPinchControlRotation: boolean;
  102752. /**
  102753. * Log error messages if basic misconfiguration has occurred.
  102754. */
  102755. warningEnable: boolean;
  102756. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102757. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102758. private _warningCounter;
  102759. private _warning;
  102760. }
  102761. }
  102762. declare module BABYLON {
  102763. /**
  102764. * Default Inputs manager for the FollowCamera.
  102765. * It groups all the default supported inputs for ease of use.
  102766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102767. */
  102768. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102769. /**
  102770. * Instantiates a new FollowCameraInputsManager.
  102771. * @param camera Defines the camera the inputs belong to
  102772. */
  102773. constructor(camera: FollowCamera);
  102774. /**
  102775. * Add keyboard input support to the input manager.
  102776. * @returns the current input manager
  102777. */
  102778. addKeyboard(): FollowCameraInputsManager;
  102779. /**
  102780. * Add mouse wheel input support to the input manager.
  102781. * @returns the current input manager
  102782. */
  102783. addMouseWheel(): FollowCameraInputsManager;
  102784. /**
  102785. * Add pointers input support to the input manager.
  102786. * @returns the current input manager
  102787. */
  102788. addPointers(): FollowCameraInputsManager;
  102789. /**
  102790. * Add orientation input support to the input manager.
  102791. * @returns the current input manager
  102792. */
  102793. addVRDeviceOrientation(): FollowCameraInputsManager;
  102794. }
  102795. }
  102796. declare module BABYLON {
  102797. /**
  102798. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102799. * an arc rotate version arcFollowCamera are available.
  102800. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102801. */
  102802. export class FollowCamera extends TargetCamera {
  102803. /**
  102804. * Distance the follow camera should follow an object at
  102805. */
  102806. radius: number;
  102807. /**
  102808. * Minimum allowed distance of the camera to the axis of rotation
  102809. * (The camera can not get closer).
  102810. * This can help limiting how the Camera is able to move in the scene.
  102811. */
  102812. lowerRadiusLimit: Nullable<number>;
  102813. /**
  102814. * Maximum allowed distance of the camera to the axis of rotation
  102815. * (The camera can not get further).
  102816. * This can help limiting how the Camera is able to move in the scene.
  102817. */
  102818. upperRadiusLimit: Nullable<number>;
  102819. /**
  102820. * Define a rotation offset between the camera and the object it follows
  102821. */
  102822. rotationOffset: number;
  102823. /**
  102824. * Minimum allowed angle to camera position relative to target object.
  102825. * This can help limiting how the Camera is able to move in the scene.
  102826. */
  102827. lowerRotationOffsetLimit: Nullable<number>;
  102828. /**
  102829. * Maximum allowed angle to camera position relative to target object.
  102830. * This can help limiting how the Camera is able to move in the scene.
  102831. */
  102832. upperRotationOffsetLimit: Nullable<number>;
  102833. /**
  102834. * Define a height offset between the camera and the object it follows.
  102835. * It can help following an object from the top (like a car chaing a plane)
  102836. */
  102837. heightOffset: number;
  102838. /**
  102839. * Minimum allowed height of camera position relative to target object.
  102840. * This can help limiting how the Camera is able to move in the scene.
  102841. */
  102842. lowerHeightOffsetLimit: Nullable<number>;
  102843. /**
  102844. * Maximum allowed height of camera position relative to target object.
  102845. * This can help limiting how the Camera is able to move in the scene.
  102846. */
  102847. upperHeightOffsetLimit: Nullable<number>;
  102848. /**
  102849. * Define how fast the camera can accelerate to follow it s target.
  102850. */
  102851. cameraAcceleration: number;
  102852. /**
  102853. * Define the speed limit of the camera following an object.
  102854. */
  102855. maxCameraSpeed: number;
  102856. /**
  102857. * Define the target of the camera.
  102858. */
  102859. lockedTarget: Nullable<AbstractMesh>;
  102860. /**
  102861. * Defines the input associated with the camera.
  102862. */
  102863. inputs: FollowCameraInputsManager;
  102864. /**
  102865. * Instantiates the follow camera.
  102866. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102867. * @param name Define the name of the camera in the scene
  102868. * @param position Define the position of the camera
  102869. * @param scene Define the scene the camera belong to
  102870. * @param lockedTarget Define the target of the camera
  102871. */
  102872. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102873. private _follow;
  102874. /**
  102875. * Attached controls to the current camera.
  102876. * @param element Defines the element the controls should be listened from
  102877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102878. */
  102879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102880. /**
  102881. * Detach the current controls from the camera.
  102882. * The camera will stop reacting to inputs.
  102883. * @param element Defines the element to stop listening the inputs from
  102884. */
  102885. detachControl(element: HTMLElement): void;
  102886. /** @hidden */
  102887. _checkInputs(): void;
  102888. private _checkLimits;
  102889. /**
  102890. * Gets the camera class name.
  102891. * @returns the class name
  102892. */
  102893. getClassName(): string;
  102894. }
  102895. /**
  102896. * Arc Rotate version of the follow camera.
  102897. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102898. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102899. */
  102900. export class ArcFollowCamera extends TargetCamera {
  102901. /** The longitudinal angle of the camera */
  102902. alpha: number;
  102903. /** The latitudinal angle of the camera */
  102904. beta: number;
  102905. /** The radius of the camera from its target */
  102906. radius: number;
  102907. /** Define the camera target (the messh it should follow) */
  102908. target: Nullable<AbstractMesh>;
  102909. private _cartesianCoordinates;
  102910. /**
  102911. * Instantiates a new ArcFollowCamera
  102912. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102913. * @param name Define the name of the camera
  102914. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102915. * @param beta Define the rotation angle of the camera around the elevation axis
  102916. * @param radius Define the radius of the camera from its target point
  102917. * @param target Define the target of the camera
  102918. * @param scene Define the scene the camera belongs to
  102919. */
  102920. constructor(name: string,
  102921. /** The longitudinal angle of the camera */
  102922. alpha: number,
  102923. /** The latitudinal angle of the camera */
  102924. beta: number,
  102925. /** The radius of the camera from its target */
  102926. radius: number,
  102927. /** Define the camera target (the messh it should follow) */
  102928. target: Nullable<AbstractMesh>, scene: Scene);
  102929. private _follow;
  102930. /** @hidden */
  102931. _checkInputs(): void;
  102932. /**
  102933. * Returns the class name of the object.
  102934. * It is mostly used internally for serialization purposes.
  102935. */
  102936. getClassName(): string;
  102937. }
  102938. }
  102939. declare module BABYLON {
  102940. /**
  102941. * Manage the keyboard inputs to control the movement of a follow camera.
  102942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102943. */
  102944. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102945. /**
  102946. * Defines the camera the input is attached to.
  102947. */
  102948. camera: FollowCamera;
  102949. /**
  102950. * Defines the list of key codes associated with the up action (increase heightOffset)
  102951. */
  102952. keysHeightOffsetIncr: number[];
  102953. /**
  102954. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102955. */
  102956. keysHeightOffsetDecr: number[];
  102957. /**
  102958. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102959. */
  102960. keysHeightOffsetModifierAlt: boolean;
  102961. /**
  102962. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102963. */
  102964. keysHeightOffsetModifierCtrl: boolean;
  102965. /**
  102966. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102967. */
  102968. keysHeightOffsetModifierShift: boolean;
  102969. /**
  102970. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102971. */
  102972. keysRotationOffsetIncr: number[];
  102973. /**
  102974. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102975. */
  102976. keysRotationOffsetDecr: number[];
  102977. /**
  102978. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102979. */
  102980. keysRotationOffsetModifierAlt: boolean;
  102981. /**
  102982. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102983. */
  102984. keysRotationOffsetModifierCtrl: boolean;
  102985. /**
  102986. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102987. */
  102988. keysRotationOffsetModifierShift: boolean;
  102989. /**
  102990. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102991. */
  102992. keysRadiusIncr: number[];
  102993. /**
  102994. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102995. */
  102996. keysRadiusDecr: number[];
  102997. /**
  102998. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102999. */
  103000. keysRadiusModifierAlt: boolean;
  103001. /**
  103002. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103003. */
  103004. keysRadiusModifierCtrl: boolean;
  103005. /**
  103006. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103007. */
  103008. keysRadiusModifierShift: boolean;
  103009. /**
  103010. * Defines the rate of change of heightOffset.
  103011. */
  103012. heightSensibility: number;
  103013. /**
  103014. * Defines the rate of change of rotationOffset.
  103015. */
  103016. rotationSensibility: number;
  103017. /**
  103018. * Defines the rate of change of radius.
  103019. */
  103020. radiusSensibility: number;
  103021. private _keys;
  103022. private _ctrlPressed;
  103023. private _altPressed;
  103024. private _shiftPressed;
  103025. private _onCanvasBlurObserver;
  103026. private _onKeyboardObserver;
  103027. private _engine;
  103028. private _scene;
  103029. /**
  103030. * Attach the input controls to a specific dom element to get the input from.
  103031. * @param element Defines the element the controls should be listened from
  103032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103033. */
  103034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103035. /**
  103036. * Detach the current controls from the specified dom element.
  103037. * @param element Defines the element to stop listening the inputs from
  103038. */
  103039. detachControl(element: Nullable<HTMLElement>): void;
  103040. /**
  103041. * Update the current camera state depending on the inputs that have been used this frame.
  103042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103043. */
  103044. checkInputs(): void;
  103045. /**
  103046. * Gets the class name of the current input.
  103047. * @returns the class name
  103048. */
  103049. getClassName(): string;
  103050. /**
  103051. * Get the friendly name associated with the input class.
  103052. * @returns the input friendly name
  103053. */
  103054. getSimpleName(): string;
  103055. /**
  103056. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103057. * allow modification of the heightOffset value.
  103058. */
  103059. private _modifierHeightOffset;
  103060. /**
  103061. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103062. * allow modification of the rotationOffset value.
  103063. */
  103064. private _modifierRotationOffset;
  103065. /**
  103066. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103067. * allow modification of the radius value.
  103068. */
  103069. private _modifierRadius;
  103070. }
  103071. }
  103072. declare module BABYLON {
  103073. interface FreeCameraInputsManager {
  103074. /**
  103075. * @hidden
  103076. */
  103077. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103078. /**
  103079. * Add orientation input support to the input manager.
  103080. * @returns the current input manager
  103081. */
  103082. addDeviceOrientation(): FreeCameraInputsManager;
  103083. }
  103084. /**
  103085. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103086. * Screen rotation is taken into account.
  103087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103088. */
  103089. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103090. private _camera;
  103091. private _screenOrientationAngle;
  103092. private _constantTranform;
  103093. private _screenQuaternion;
  103094. private _alpha;
  103095. private _beta;
  103096. private _gamma;
  103097. /**
  103098. * Can be used to detect if a device orientation sensor is availible on a device
  103099. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103100. * @returns a promise that will resolve on orientation change
  103101. */
  103102. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103103. /**
  103104. * @hidden
  103105. */
  103106. _onDeviceOrientationChangedObservable: Observable<void>;
  103107. /**
  103108. * Instantiates a new input
  103109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103110. */
  103111. constructor();
  103112. /**
  103113. * Define the camera controlled by the input.
  103114. */
  103115. camera: FreeCamera;
  103116. /**
  103117. * Attach the input controls to a specific dom element to get the input from.
  103118. * @param element Defines the element the controls should be listened from
  103119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103120. */
  103121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103122. private _orientationChanged;
  103123. private _deviceOrientation;
  103124. /**
  103125. * Detach the current controls from the specified dom element.
  103126. * @param element Defines the element to stop listening the inputs from
  103127. */
  103128. detachControl(element: Nullable<HTMLElement>): void;
  103129. /**
  103130. * Update the current camera state depending on the inputs that have been used this frame.
  103131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103132. */
  103133. checkInputs(): void;
  103134. /**
  103135. * Gets the class name of the current intput.
  103136. * @returns the class name
  103137. */
  103138. getClassName(): string;
  103139. /**
  103140. * Get the friendly name associated with the input class.
  103141. * @returns the input friendly name
  103142. */
  103143. getSimpleName(): string;
  103144. }
  103145. }
  103146. declare module BABYLON {
  103147. /**
  103148. * Manage the gamepad inputs to control a free camera.
  103149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103150. */
  103151. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103152. /**
  103153. * Define the camera the input is attached to.
  103154. */
  103155. camera: FreeCamera;
  103156. /**
  103157. * Define the Gamepad controlling the input
  103158. */
  103159. gamepad: Nullable<Gamepad>;
  103160. /**
  103161. * Defines the gamepad rotation sensiblity.
  103162. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103163. */
  103164. gamepadAngularSensibility: number;
  103165. /**
  103166. * Defines the gamepad move sensiblity.
  103167. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103168. */
  103169. gamepadMoveSensibility: number;
  103170. private _onGamepadConnectedObserver;
  103171. private _onGamepadDisconnectedObserver;
  103172. private _cameraTransform;
  103173. private _deltaTransform;
  103174. private _vector3;
  103175. private _vector2;
  103176. /**
  103177. * Attach the input controls to a specific dom element to get the input from.
  103178. * @param element Defines the element the controls should be listened from
  103179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103180. */
  103181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103182. /**
  103183. * Detach the current controls from the specified dom element.
  103184. * @param element Defines the element to stop listening the inputs from
  103185. */
  103186. detachControl(element: Nullable<HTMLElement>): void;
  103187. /**
  103188. * Update the current camera state depending on the inputs that have been used this frame.
  103189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103190. */
  103191. checkInputs(): void;
  103192. /**
  103193. * Gets the class name of the current intput.
  103194. * @returns the class name
  103195. */
  103196. getClassName(): string;
  103197. /**
  103198. * Get the friendly name associated with the input class.
  103199. * @returns the input friendly name
  103200. */
  103201. getSimpleName(): string;
  103202. }
  103203. }
  103204. declare module BABYLON {
  103205. /**
  103206. * Defines the potential axis of a Joystick
  103207. */
  103208. export enum JoystickAxis {
  103209. /** X axis */
  103210. X = 0,
  103211. /** Y axis */
  103212. Y = 1,
  103213. /** Z axis */
  103214. Z = 2
  103215. }
  103216. /**
  103217. * Class used to define virtual joystick (used in touch mode)
  103218. */
  103219. export class VirtualJoystick {
  103220. /**
  103221. * Gets or sets a boolean indicating that left and right values must be inverted
  103222. */
  103223. reverseLeftRight: boolean;
  103224. /**
  103225. * Gets or sets a boolean indicating that up and down values must be inverted
  103226. */
  103227. reverseUpDown: boolean;
  103228. /**
  103229. * Gets the offset value for the position (ie. the change of the position value)
  103230. */
  103231. deltaPosition: Vector3;
  103232. /**
  103233. * Gets a boolean indicating if the virtual joystick was pressed
  103234. */
  103235. pressed: boolean;
  103236. /**
  103237. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103238. */
  103239. static Canvas: Nullable<HTMLCanvasElement>;
  103240. private static _globalJoystickIndex;
  103241. private static vjCanvasContext;
  103242. private static vjCanvasWidth;
  103243. private static vjCanvasHeight;
  103244. private static halfWidth;
  103245. private _action;
  103246. private _axisTargetedByLeftAndRight;
  103247. private _axisTargetedByUpAndDown;
  103248. private _joystickSensibility;
  103249. private _inversedSensibility;
  103250. private _joystickPointerID;
  103251. private _joystickColor;
  103252. private _joystickPointerPos;
  103253. private _joystickPreviousPointerPos;
  103254. private _joystickPointerStartPos;
  103255. private _deltaJoystickVector;
  103256. private _leftJoystick;
  103257. private _touches;
  103258. private _onPointerDownHandlerRef;
  103259. private _onPointerMoveHandlerRef;
  103260. private _onPointerUpHandlerRef;
  103261. private _onResize;
  103262. /**
  103263. * Creates a new virtual joystick
  103264. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103265. */
  103266. constructor(leftJoystick?: boolean);
  103267. /**
  103268. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103269. * @param newJoystickSensibility defines the new sensibility
  103270. */
  103271. setJoystickSensibility(newJoystickSensibility: number): void;
  103272. private _onPointerDown;
  103273. private _onPointerMove;
  103274. private _onPointerUp;
  103275. /**
  103276. * Change the color of the virtual joystick
  103277. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103278. */
  103279. setJoystickColor(newColor: string): void;
  103280. /**
  103281. * Defines a callback to call when the joystick is touched
  103282. * @param action defines the callback
  103283. */
  103284. setActionOnTouch(action: () => any): void;
  103285. /**
  103286. * Defines which axis you'd like to control for left & right
  103287. * @param axis defines the axis to use
  103288. */
  103289. setAxisForLeftRight(axis: JoystickAxis): void;
  103290. /**
  103291. * Defines which axis you'd like to control for up & down
  103292. * @param axis defines the axis to use
  103293. */
  103294. setAxisForUpDown(axis: JoystickAxis): void;
  103295. private _drawVirtualJoystick;
  103296. /**
  103297. * Release internal HTML canvas
  103298. */
  103299. releaseCanvas(): void;
  103300. }
  103301. }
  103302. declare module BABYLON {
  103303. interface FreeCameraInputsManager {
  103304. /**
  103305. * Add virtual joystick input support to the input manager.
  103306. * @returns the current input manager
  103307. */
  103308. addVirtualJoystick(): FreeCameraInputsManager;
  103309. }
  103310. /**
  103311. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103313. */
  103314. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103315. /**
  103316. * Defines the camera the input is attached to.
  103317. */
  103318. camera: FreeCamera;
  103319. private _leftjoystick;
  103320. private _rightjoystick;
  103321. /**
  103322. * Gets the left stick of the virtual joystick.
  103323. * @returns The virtual Joystick
  103324. */
  103325. getLeftJoystick(): VirtualJoystick;
  103326. /**
  103327. * Gets the right stick of the virtual joystick.
  103328. * @returns The virtual Joystick
  103329. */
  103330. getRightJoystick(): VirtualJoystick;
  103331. /**
  103332. * Update the current camera state depending on the inputs that have been used this frame.
  103333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103334. */
  103335. checkInputs(): void;
  103336. /**
  103337. * Attach the input controls to a specific dom element to get the input from.
  103338. * @param element Defines the element the controls should be listened from
  103339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103340. */
  103341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103342. /**
  103343. * Detach the current controls from the specified dom element.
  103344. * @param element Defines the element to stop listening the inputs from
  103345. */
  103346. detachControl(element: Nullable<HTMLElement>): void;
  103347. /**
  103348. * Gets the class name of the current intput.
  103349. * @returns the class name
  103350. */
  103351. getClassName(): string;
  103352. /**
  103353. * Get the friendly name associated with the input class.
  103354. * @returns the input friendly name
  103355. */
  103356. getSimpleName(): string;
  103357. }
  103358. }
  103359. declare module BABYLON {
  103360. /**
  103361. * This represents a FPS type of camera controlled by touch.
  103362. * This is like a universal camera minus the Gamepad controls.
  103363. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103364. */
  103365. export class TouchCamera extends FreeCamera {
  103366. /**
  103367. * Defines the touch sensibility for rotation.
  103368. * The higher the faster.
  103369. */
  103370. touchAngularSensibility: number;
  103371. /**
  103372. * Defines the touch sensibility for move.
  103373. * The higher the faster.
  103374. */
  103375. touchMoveSensibility: number;
  103376. /**
  103377. * Instantiates a new touch camera.
  103378. * This represents a FPS type of camera controlled by touch.
  103379. * This is like a universal camera minus the Gamepad controls.
  103380. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103381. * @param name Define the name of the camera in the scene
  103382. * @param position Define the start position of the camera in the scene
  103383. * @param scene Define the scene the camera belongs to
  103384. */
  103385. constructor(name: string, position: Vector3, scene: Scene);
  103386. /**
  103387. * Gets the current object class name.
  103388. * @return the class name
  103389. */
  103390. getClassName(): string;
  103391. /** @hidden */
  103392. _setupInputs(): void;
  103393. }
  103394. }
  103395. declare module BABYLON {
  103396. /**
  103397. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103398. * being tilted forward or back and left or right.
  103399. */
  103400. export class DeviceOrientationCamera extends FreeCamera {
  103401. private _initialQuaternion;
  103402. private _quaternionCache;
  103403. private _tmpDragQuaternion;
  103404. private _disablePointerInputWhenUsingDeviceOrientation;
  103405. /**
  103406. * Creates a new device orientation camera
  103407. * @param name The name of the camera
  103408. * @param position The start position camera
  103409. * @param scene The scene the camera belongs to
  103410. */
  103411. constructor(name: string, position: Vector3, scene: Scene);
  103412. /**
  103413. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103414. */
  103415. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103416. private _dragFactor;
  103417. /**
  103418. * Enabled turning on the y axis when the orientation sensor is active
  103419. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103420. */
  103421. enableHorizontalDragging(dragFactor?: number): void;
  103422. /**
  103423. * Gets the current instance class name ("DeviceOrientationCamera").
  103424. * This helps avoiding instanceof at run time.
  103425. * @returns the class name
  103426. */
  103427. getClassName(): string;
  103428. /**
  103429. * @hidden
  103430. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103431. */
  103432. _checkInputs(): void;
  103433. /**
  103434. * Reset the camera to its default orientation on the specified axis only.
  103435. * @param axis The axis to reset
  103436. */
  103437. resetToCurrentRotation(axis?: Axis): void;
  103438. }
  103439. }
  103440. declare module BABYLON {
  103441. /**
  103442. * Defines supported buttons for XBox360 compatible gamepads
  103443. */
  103444. export enum Xbox360Button {
  103445. /** A */
  103446. A = 0,
  103447. /** B */
  103448. B = 1,
  103449. /** X */
  103450. X = 2,
  103451. /** Y */
  103452. Y = 3,
  103453. /** Start */
  103454. Start = 4,
  103455. /** Back */
  103456. Back = 5,
  103457. /** Left button */
  103458. LB = 6,
  103459. /** Right button */
  103460. RB = 7,
  103461. /** Left stick */
  103462. LeftStick = 8,
  103463. /** Right stick */
  103464. RightStick = 9
  103465. }
  103466. /** Defines values for XBox360 DPad */
  103467. export enum Xbox360Dpad {
  103468. /** Up */
  103469. Up = 0,
  103470. /** Down */
  103471. Down = 1,
  103472. /** Left */
  103473. Left = 2,
  103474. /** Right */
  103475. Right = 3
  103476. }
  103477. /**
  103478. * Defines a XBox360 gamepad
  103479. */
  103480. export class Xbox360Pad extends Gamepad {
  103481. private _leftTrigger;
  103482. private _rightTrigger;
  103483. private _onlefttriggerchanged;
  103484. private _onrighttriggerchanged;
  103485. private _onbuttondown;
  103486. private _onbuttonup;
  103487. private _ondpaddown;
  103488. private _ondpadup;
  103489. /** Observable raised when a button is pressed */
  103490. onButtonDownObservable: Observable<Xbox360Button>;
  103491. /** Observable raised when a button is released */
  103492. onButtonUpObservable: Observable<Xbox360Button>;
  103493. /** Observable raised when a pad is pressed */
  103494. onPadDownObservable: Observable<Xbox360Dpad>;
  103495. /** Observable raised when a pad is released */
  103496. onPadUpObservable: Observable<Xbox360Dpad>;
  103497. private _buttonA;
  103498. private _buttonB;
  103499. private _buttonX;
  103500. private _buttonY;
  103501. private _buttonBack;
  103502. private _buttonStart;
  103503. private _buttonLB;
  103504. private _buttonRB;
  103505. private _buttonLeftStick;
  103506. private _buttonRightStick;
  103507. private _dPadUp;
  103508. private _dPadDown;
  103509. private _dPadLeft;
  103510. private _dPadRight;
  103511. private _isXboxOnePad;
  103512. /**
  103513. * Creates a new XBox360 gamepad object
  103514. * @param id defines the id of this gamepad
  103515. * @param index defines its index
  103516. * @param gamepad defines the internal HTML gamepad object
  103517. * @param xboxOne defines if it is a XBox One gamepad
  103518. */
  103519. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103520. /**
  103521. * Defines the callback to call when left trigger is pressed
  103522. * @param callback defines the callback to use
  103523. */
  103524. onlefttriggerchanged(callback: (value: number) => void): void;
  103525. /**
  103526. * Defines the callback to call when right trigger is pressed
  103527. * @param callback defines the callback to use
  103528. */
  103529. onrighttriggerchanged(callback: (value: number) => void): void;
  103530. /**
  103531. * Gets the left trigger value
  103532. */
  103533. /**
  103534. * Sets the left trigger value
  103535. */
  103536. leftTrigger: number;
  103537. /**
  103538. * Gets the right trigger value
  103539. */
  103540. /**
  103541. * Sets the right trigger value
  103542. */
  103543. rightTrigger: number;
  103544. /**
  103545. * Defines the callback to call when a button is pressed
  103546. * @param callback defines the callback to use
  103547. */
  103548. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103549. /**
  103550. * Defines the callback to call when a button is released
  103551. * @param callback defines the callback to use
  103552. */
  103553. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103554. /**
  103555. * Defines the callback to call when a pad is pressed
  103556. * @param callback defines the callback to use
  103557. */
  103558. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  103559. /**
  103560. * Defines the callback to call when a pad is released
  103561. * @param callback defines the callback to use
  103562. */
  103563. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  103564. private _setButtonValue;
  103565. private _setDPadValue;
  103566. /**
  103567. * Gets the value of the `A` button
  103568. */
  103569. /**
  103570. * Sets the value of the `A` button
  103571. */
  103572. buttonA: number;
  103573. /**
  103574. * Gets the value of the `B` button
  103575. */
  103576. /**
  103577. * Sets the value of the `B` button
  103578. */
  103579. buttonB: number;
  103580. /**
  103581. * Gets the value of the `X` button
  103582. */
  103583. /**
  103584. * Sets the value of the `X` button
  103585. */
  103586. buttonX: number;
  103587. /**
  103588. * Gets the value of the `Y` button
  103589. */
  103590. /**
  103591. * Sets the value of the `Y` button
  103592. */
  103593. buttonY: number;
  103594. /**
  103595. * Gets the value of the `Start` button
  103596. */
  103597. /**
  103598. * Sets the value of the `Start` button
  103599. */
  103600. buttonStart: number;
  103601. /**
  103602. * Gets the value of the `Back` button
  103603. */
  103604. /**
  103605. * Sets the value of the `Back` button
  103606. */
  103607. buttonBack: number;
  103608. /**
  103609. * Gets the value of the `Left` button
  103610. */
  103611. /**
  103612. * Sets the value of the `Left` button
  103613. */
  103614. buttonLB: number;
  103615. /**
  103616. * Gets the value of the `Right` button
  103617. */
  103618. /**
  103619. * Sets the value of the `Right` button
  103620. */
  103621. buttonRB: number;
  103622. /**
  103623. * Gets the value of the Left joystick
  103624. */
  103625. /**
  103626. * Sets the value of the Left joystick
  103627. */
  103628. buttonLeftStick: number;
  103629. /**
  103630. * Gets the value of the Right joystick
  103631. */
  103632. /**
  103633. * Sets the value of the Right joystick
  103634. */
  103635. buttonRightStick: number;
  103636. /**
  103637. * Gets the value of D-pad up
  103638. */
  103639. /**
  103640. * Sets the value of D-pad up
  103641. */
  103642. dPadUp: number;
  103643. /**
  103644. * Gets the value of D-pad down
  103645. */
  103646. /**
  103647. * Sets the value of D-pad down
  103648. */
  103649. dPadDown: number;
  103650. /**
  103651. * Gets the value of D-pad left
  103652. */
  103653. /**
  103654. * Sets the value of D-pad left
  103655. */
  103656. dPadLeft: number;
  103657. /**
  103658. * Gets the value of D-pad right
  103659. */
  103660. /**
  103661. * Sets the value of D-pad right
  103662. */
  103663. dPadRight: number;
  103664. /**
  103665. * Force the gamepad to synchronize with device values
  103666. */
  103667. update(): void;
  103668. /**
  103669. * Disposes the gamepad
  103670. */
  103671. dispose(): void;
  103672. }
  103673. }
  103674. declare module BABYLON {
  103675. /**
  103676. * Defines supported buttons for DualShock compatible gamepads
  103677. */
  103678. export enum DualShockButton {
  103679. /** Cross */
  103680. Cross = 0,
  103681. /** Circle */
  103682. Circle = 1,
  103683. /** Square */
  103684. Square = 2,
  103685. /** Triangle */
  103686. Triangle = 3,
  103687. /** Options */
  103688. Options = 4,
  103689. /** Share */
  103690. Share = 5,
  103691. /** L1 */
  103692. L1 = 6,
  103693. /** R1 */
  103694. R1 = 7,
  103695. /** Left stick */
  103696. LeftStick = 8,
  103697. /** Right stick */
  103698. RightStick = 9
  103699. }
  103700. /** Defines values for DualShock DPad */
  103701. export enum DualShockDpad {
  103702. /** Up */
  103703. Up = 0,
  103704. /** Down */
  103705. Down = 1,
  103706. /** Left */
  103707. Left = 2,
  103708. /** Right */
  103709. Right = 3
  103710. }
  103711. /**
  103712. * Defines a DualShock gamepad
  103713. */
  103714. export class DualShockPad extends Gamepad {
  103715. private _leftTrigger;
  103716. private _rightTrigger;
  103717. private _onlefttriggerchanged;
  103718. private _onrighttriggerchanged;
  103719. private _onbuttondown;
  103720. private _onbuttonup;
  103721. private _ondpaddown;
  103722. private _ondpadup;
  103723. /** Observable raised when a button is pressed */
  103724. onButtonDownObservable: Observable<DualShockButton>;
  103725. /** Observable raised when a button is released */
  103726. onButtonUpObservable: Observable<DualShockButton>;
  103727. /** Observable raised when a pad is pressed */
  103728. onPadDownObservable: Observable<DualShockDpad>;
  103729. /** Observable raised when a pad is released */
  103730. onPadUpObservable: Observable<DualShockDpad>;
  103731. private _buttonCross;
  103732. private _buttonCircle;
  103733. private _buttonSquare;
  103734. private _buttonTriangle;
  103735. private _buttonShare;
  103736. private _buttonOptions;
  103737. private _buttonL1;
  103738. private _buttonR1;
  103739. private _buttonLeftStick;
  103740. private _buttonRightStick;
  103741. private _dPadUp;
  103742. private _dPadDown;
  103743. private _dPadLeft;
  103744. private _dPadRight;
  103745. /**
  103746. * Creates a new DualShock gamepad object
  103747. * @param id defines the id of this gamepad
  103748. * @param index defines its index
  103749. * @param gamepad defines the internal HTML gamepad object
  103750. */
  103751. constructor(id: string, index: number, gamepad: any);
  103752. /**
  103753. * Defines the callback to call when left trigger is pressed
  103754. * @param callback defines the callback to use
  103755. */
  103756. onlefttriggerchanged(callback: (value: number) => void): void;
  103757. /**
  103758. * Defines the callback to call when right trigger is pressed
  103759. * @param callback defines the callback to use
  103760. */
  103761. onrighttriggerchanged(callback: (value: number) => void): void;
  103762. /**
  103763. * Gets the left trigger value
  103764. */
  103765. /**
  103766. * Sets the left trigger value
  103767. */
  103768. leftTrigger: number;
  103769. /**
  103770. * Gets the right trigger value
  103771. */
  103772. /**
  103773. * Sets the right trigger value
  103774. */
  103775. rightTrigger: number;
  103776. /**
  103777. * Defines the callback to call when a button is pressed
  103778. * @param callback defines the callback to use
  103779. */
  103780. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103781. /**
  103782. * Defines the callback to call when a button is released
  103783. * @param callback defines the callback to use
  103784. */
  103785. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103786. /**
  103787. * Defines the callback to call when a pad is pressed
  103788. * @param callback defines the callback to use
  103789. */
  103790. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103791. /**
  103792. * Defines the callback to call when a pad is released
  103793. * @param callback defines the callback to use
  103794. */
  103795. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103796. private _setButtonValue;
  103797. private _setDPadValue;
  103798. /**
  103799. * Gets the value of the `Cross` button
  103800. */
  103801. /**
  103802. * Sets the value of the `Cross` button
  103803. */
  103804. buttonCross: number;
  103805. /**
  103806. * Gets the value of the `Circle` button
  103807. */
  103808. /**
  103809. * Sets the value of the `Circle` button
  103810. */
  103811. buttonCircle: number;
  103812. /**
  103813. * Gets the value of the `Square` button
  103814. */
  103815. /**
  103816. * Sets the value of the `Square` button
  103817. */
  103818. buttonSquare: number;
  103819. /**
  103820. * Gets the value of the `Triangle` button
  103821. */
  103822. /**
  103823. * Sets the value of the `Triangle` button
  103824. */
  103825. buttonTriangle: number;
  103826. /**
  103827. * Gets the value of the `Options` button
  103828. */
  103829. /**
  103830. * Sets the value of the `Options` button
  103831. */
  103832. buttonOptions: number;
  103833. /**
  103834. * Gets the value of the `Share` button
  103835. */
  103836. /**
  103837. * Sets the value of the `Share` button
  103838. */
  103839. buttonShare: number;
  103840. /**
  103841. * Gets the value of the `L1` button
  103842. */
  103843. /**
  103844. * Sets the value of the `L1` button
  103845. */
  103846. buttonL1: number;
  103847. /**
  103848. * Gets the value of the `R1` button
  103849. */
  103850. /**
  103851. * Sets the value of the `R1` button
  103852. */
  103853. buttonR1: number;
  103854. /**
  103855. * Gets the value of the Left joystick
  103856. */
  103857. /**
  103858. * Sets the value of the Left joystick
  103859. */
  103860. buttonLeftStick: number;
  103861. /**
  103862. * Gets the value of the Right joystick
  103863. */
  103864. /**
  103865. * Sets the value of the Right joystick
  103866. */
  103867. buttonRightStick: number;
  103868. /**
  103869. * Gets the value of D-pad up
  103870. */
  103871. /**
  103872. * Sets the value of D-pad up
  103873. */
  103874. dPadUp: number;
  103875. /**
  103876. * Gets the value of D-pad down
  103877. */
  103878. /**
  103879. * Sets the value of D-pad down
  103880. */
  103881. dPadDown: number;
  103882. /**
  103883. * Gets the value of D-pad left
  103884. */
  103885. /**
  103886. * Sets the value of D-pad left
  103887. */
  103888. dPadLeft: number;
  103889. /**
  103890. * Gets the value of D-pad right
  103891. */
  103892. /**
  103893. * Sets the value of D-pad right
  103894. */
  103895. dPadRight: number;
  103896. /**
  103897. * Force the gamepad to synchronize with device values
  103898. */
  103899. update(): void;
  103900. /**
  103901. * Disposes the gamepad
  103902. */
  103903. dispose(): void;
  103904. }
  103905. }
  103906. declare module BABYLON {
  103907. /**
  103908. * Manager for handling gamepads
  103909. */
  103910. export class GamepadManager {
  103911. private _scene?;
  103912. private _babylonGamepads;
  103913. private _oneGamepadConnected;
  103914. /** @hidden */
  103915. _isMonitoring: boolean;
  103916. private _gamepadEventSupported;
  103917. private _gamepadSupport;
  103918. /**
  103919. * observable to be triggered when the gamepad controller has been connected
  103920. */
  103921. onGamepadConnectedObservable: Observable<Gamepad>;
  103922. /**
  103923. * observable to be triggered when the gamepad controller has been disconnected
  103924. */
  103925. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103926. private _onGamepadConnectedEvent;
  103927. private _onGamepadDisconnectedEvent;
  103928. /**
  103929. * Initializes the gamepad manager
  103930. * @param _scene BabylonJS scene
  103931. */
  103932. constructor(_scene?: Scene | undefined);
  103933. /**
  103934. * The gamepads in the game pad manager
  103935. */
  103936. readonly gamepads: Gamepad[];
  103937. /**
  103938. * Get the gamepad controllers based on type
  103939. * @param type The type of gamepad controller
  103940. * @returns Nullable gamepad
  103941. */
  103942. getGamepadByType(type?: number): Nullable<Gamepad>;
  103943. /**
  103944. * Disposes the gamepad manager
  103945. */
  103946. dispose(): void;
  103947. private _addNewGamepad;
  103948. private _startMonitoringGamepads;
  103949. private _stopMonitoringGamepads;
  103950. /** @hidden */
  103951. _checkGamepadsStatus(): void;
  103952. private _updateGamepadObjects;
  103953. }
  103954. }
  103955. declare module BABYLON {
  103956. interface Scene {
  103957. /** @hidden */
  103958. _gamepadManager: Nullable<GamepadManager>;
  103959. /**
  103960. * Gets the gamepad manager associated with the scene
  103961. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103962. */
  103963. gamepadManager: GamepadManager;
  103964. }
  103965. /**
  103966. * Interface representing a free camera inputs manager
  103967. */
  103968. interface FreeCameraInputsManager {
  103969. /**
  103970. * Adds gamepad input support to the FreeCameraInputsManager.
  103971. * @returns the FreeCameraInputsManager
  103972. */
  103973. addGamepad(): FreeCameraInputsManager;
  103974. }
  103975. /**
  103976. * Interface representing an arc rotate camera inputs manager
  103977. */
  103978. interface ArcRotateCameraInputsManager {
  103979. /**
  103980. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103981. * @returns the camera inputs manager
  103982. */
  103983. addGamepad(): ArcRotateCameraInputsManager;
  103984. }
  103985. /**
  103986. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103987. */
  103988. export class GamepadSystemSceneComponent implements ISceneComponent {
  103989. /**
  103990. * The component name helpfull to identify the component in the list of scene components.
  103991. */
  103992. readonly name: string;
  103993. /**
  103994. * The scene the component belongs to.
  103995. */
  103996. scene: Scene;
  103997. /**
  103998. * Creates a new instance of the component for the given scene
  103999. * @param scene Defines the scene to register the component in
  104000. */
  104001. constructor(scene: Scene);
  104002. /**
  104003. * Registers the component in a given scene
  104004. */
  104005. register(): void;
  104006. /**
  104007. * Rebuilds the elements related to this component in case of
  104008. * context lost for instance.
  104009. */
  104010. rebuild(): void;
  104011. /**
  104012. * Disposes the component and the associated ressources
  104013. */
  104014. dispose(): void;
  104015. private _beforeCameraUpdate;
  104016. }
  104017. }
  104018. declare module BABYLON {
  104019. /**
  104020. * 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,
  104021. * which still works and will still be found in many Playgrounds.
  104022. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104023. */
  104024. export class UniversalCamera extends TouchCamera {
  104025. /**
  104026. * Defines the gamepad rotation sensiblity.
  104027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104028. */
  104029. gamepadAngularSensibility: number;
  104030. /**
  104031. * Defines the gamepad move sensiblity.
  104032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104033. */
  104034. gamepadMoveSensibility: number;
  104035. /**
  104036. * 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,
  104037. * which still works and will still be found in many Playgrounds.
  104038. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104039. * @param name Define the name of the camera in the scene
  104040. * @param position Define the start position of the camera in the scene
  104041. * @param scene Define the scene the camera belongs to
  104042. */
  104043. constructor(name: string, position: Vector3, scene: Scene);
  104044. /**
  104045. * Gets the current object class name.
  104046. * @return the class name
  104047. */
  104048. getClassName(): string;
  104049. }
  104050. }
  104051. declare module BABYLON {
  104052. /**
  104053. * This represents a FPS type of camera. This is only here for back compat purpose.
  104054. * Please use the UniversalCamera instead as both are identical.
  104055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104056. */
  104057. export class GamepadCamera extends UniversalCamera {
  104058. /**
  104059. * Instantiates a new Gamepad Camera
  104060. * This represents a FPS type of camera. This is only here for back compat purpose.
  104061. * Please use the UniversalCamera instead as both are identical.
  104062. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104063. * @param name Define the name of the camera in the scene
  104064. * @param position Define the start position of the camera in the scene
  104065. * @param scene Define the scene the camera belongs to
  104066. */
  104067. constructor(name: string, position: Vector3, scene: Scene);
  104068. /**
  104069. * Gets the current object class name.
  104070. * @return the class name
  104071. */
  104072. getClassName(): string;
  104073. }
  104074. }
  104075. declare module BABYLON {
  104076. /** @hidden */
  104077. export var passPixelShader: {
  104078. name: string;
  104079. shader: string;
  104080. };
  104081. }
  104082. declare module BABYLON {
  104083. /** @hidden */
  104084. export var passCubePixelShader: {
  104085. name: string;
  104086. shader: string;
  104087. };
  104088. }
  104089. declare module BABYLON {
  104090. /**
  104091. * PassPostProcess which produces an output the same as it's input
  104092. */
  104093. export class PassPostProcess extends PostProcess {
  104094. /**
  104095. * Creates the PassPostProcess
  104096. * @param name The name of the effect.
  104097. * @param options The required width/height ratio to downsize to before computing the render pass.
  104098. * @param camera The camera to apply the render pass to.
  104099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104100. * @param engine The engine which the post process will be applied. (default: current engine)
  104101. * @param reusable If the post process can be reused on the same frame. (default: false)
  104102. * @param textureType The type of texture to be used when performing the post processing.
  104103. * @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)
  104104. */
  104105. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104106. }
  104107. /**
  104108. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104109. */
  104110. export class PassCubePostProcess extends PostProcess {
  104111. private _face;
  104112. /**
  104113. * Gets or sets the cube face to display.
  104114. * * 0 is +X
  104115. * * 1 is -X
  104116. * * 2 is +Y
  104117. * * 3 is -Y
  104118. * * 4 is +Z
  104119. * * 5 is -Z
  104120. */
  104121. face: number;
  104122. /**
  104123. * Creates the PassCubePostProcess
  104124. * @param name The name of the effect.
  104125. * @param options The required width/height ratio to downsize to before computing the render pass.
  104126. * @param camera The camera to apply the render pass to.
  104127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104128. * @param engine The engine which the post process will be applied. (default: current engine)
  104129. * @param reusable If the post process can be reused on the same frame. (default: false)
  104130. * @param textureType The type of texture to be used when performing the post processing.
  104131. * @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)
  104132. */
  104133. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104134. }
  104135. }
  104136. declare module BABYLON {
  104137. /** @hidden */
  104138. export var anaglyphPixelShader: {
  104139. name: string;
  104140. shader: string;
  104141. };
  104142. }
  104143. declare module BABYLON {
  104144. /**
  104145. * Postprocess used to generate anaglyphic rendering
  104146. */
  104147. export class AnaglyphPostProcess extends PostProcess {
  104148. private _passedProcess;
  104149. /**
  104150. * Creates a new AnaglyphPostProcess
  104151. * @param name defines postprocess name
  104152. * @param options defines creation options or target ratio scale
  104153. * @param rigCameras defines cameras using this postprocess
  104154. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104155. * @param engine defines hosting engine
  104156. * @param reusable defines if the postprocess will be reused multiple times per frame
  104157. */
  104158. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104159. }
  104160. }
  104161. declare module BABYLON {
  104162. /**
  104163. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104164. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104165. */
  104166. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104167. /**
  104168. * Creates a new AnaglyphArcRotateCamera
  104169. * @param name defines camera name
  104170. * @param alpha defines alpha angle (in radians)
  104171. * @param beta defines beta angle (in radians)
  104172. * @param radius defines radius
  104173. * @param target defines camera target
  104174. * @param interaxialDistance defines distance between each color axis
  104175. * @param scene defines the hosting scene
  104176. */
  104177. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104178. /**
  104179. * Gets camera class name
  104180. * @returns AnaglyphArcRotateCamera
  104181. */
  104182. getClassName(): string;
  104183. }
  104184. }
  104185. declare module BABYLON {
  104186. /**
  104187. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104188. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104189. */
  104190. export class AnaglyphFreeCamera extends FreeCamera {
  104191. /**
  104192. * Creates a new AnaglyphFreeCamera
  104193. * @param name defines camera name
  104194. * @param position defines initial position
  104195. * @param interaxialDistance defines distance between each color axis
  104196. * @param scene defines the hosting scene
  104197. */
  104198. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104199. /**
  104200. * Gets camera class name
  104201. * @returns AnaglyphFreeCamera
  104202. */
  104203. getClassName(): string;
  104204. }
  104205. }
  104206. declare module BABYLON {
  104207. /**
  104208. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104209. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104210. */
  104211. export class AnaglyphGamepadCamera extends GamepadCamera {
  104212. /**
  104213. * Creates a new AnaglyphGamepadCamera
  104214. * @param name defines camera name
  104215. * @param position defines initial position
  104216. * @param interaxialDistance defines distance between each color axis
  104217. * @param scene defines the hosting scene
  104218. */
  104219. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104220. /**
  104221. * Gets camera class name
  104222. * @returns AnaglyphGamepadCamera
  104223. */
  104224. getClassName(): string;
  104225. }
  104226. }
  104227. declare module BABYLON {
  104228. /**
  104229. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104230. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104231. */
  104232. export class AnaglyphUniversalCamera extends UniversalCamera {
  104233. /**
  104234. * Creates a new AnaglyphUniversalCamera
  104235. * @param name defines camera name
  104236. * @param position defines initial position
  104237. * @param interaxialDistance defines distance between each color axis
  104238. * @param scene defines the hosting scene
  104239. */
  104240. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104241. /**
  104242. * Gets camera class name
  104243. * @returns AnaglyphUniversalCamera
  104244. */
  104245. getClassName(): string;
  104246. }
  104247. }
  104248. declare module BABYLON {
  104249. /** @hidden */
  104250. export var stereoscopicInterlacePixelShader: {
  104251. name: string;
  104252. shader: string;
  104253. };
  104254. }
  104255. declare module BABYLON {
  104256. /**
  104257. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104258. */
  104259. export class StereoscopicInterlacePostProcess extends PostProcess {
  104260. private _stepSize;
  104261. private _passedProcess;
  104262. /**
  104263. * Initializes a StereoscopicInterlacePostProcess
  104264. * @param name The name of the effect.
  104265. * @param rigCameras The rig cameras to be appled to the post process
  104266. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104268. * @param engine The engine which the post process will be applied. (default: current engine)
  104269. * @param reusable If the post process can be reused on the same frame. (default: false)
  104270. */
  104271. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104272. }
  104273. }
  104274. declare module BABYLON {
  104275. /**
  104276. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104277. * @see http://doc.babylonjs.com/features/cameras
  104278. */
  104279. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104280. /**
  104281. * Creates a new StereoscopicArcRotateCamera
  104282. * @param name defines camera name
  104283. * @param alpha defines alpha angle (in radians)
  104284. * @param beta defines beta angle (in radians)
  104285. * @param radius defines radius
  104286. * @param target defines camera target
  104287. * @param interaxialDistance defines distance between each color axis
  104288. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104289. * @param scene defines the hosting scene
  104290. */
  104291. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104292. /**
  104293. * Gets camera class name
  104294. * @returns StereoscopicArcRotateCamera
  104295. */
  104296. getClassName(): string;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104302. * @see http://doc.babylonjs.com/features/cameras
  104303. */
  104304. export class StereoscopicFreeCamera extends FreeCamera {
  104305. /**
  104306. * Creates a new StereoscopicFreeCamera
  104307. * @param name defines camera name
  104308. * @param position defines initial position
  104309. * @param interaxialDistance defines distance between each color axis
  104310. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104311. * @param scene defines the hosting scene
  104312. */
  104313. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104314. /**
  104315. * Gets camera class name
  104316. * @returns StereoscopicFreeCamera
  104317. */
  104318. getClassName(): string;
  104319. }
  104320. }
  104321. declare module BABYLON {
  104322. /**
  104323. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104324. * @see http://doc.babylonjs.com/features/cameras
  104325. */
  104326. export class StereoscopicGamepadCamera extends GamepadCamera {
  104327. /**
  104328. * Creates a new StereoscopicGamepadCamera
  104329. * @param name defines camera name
  104330. * @param position defines initial position
  104331. * @param interaxialDistance defines distance between each color axis
  104332. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104333. * @param scene defines the hosting scene
  104334. */
  104335. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104336. /**
  104337. * Gets camera class name
  104338. * @returns StereoscopicGamepadCamera
  104339. */
  104340. getClassName(): string;
  104341. }
  104342. }
  104343. declare module BABYLON {
  104344. /**
  104345. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104346. * @see http://doc.babylonjs.com/features/cameras
  104347. */
  104348. export class StereoscopicUniversalCamera extends UniversalCamera {
  104349. /**
  104350. * Creates a new StereoscopicUniversalCamera
  104351. * @param name defines camera name
  104352. * @param position defines initial position
  104353. * @param interaxialDistance defines distance between each color axis
  104354. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104355. * @param scene defines the hosting scene
  104356. */
  104357. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104358. /**
  104359. * Gets camera class name
  104360. * @returns StereoscopicUniversalCamera
  104361. */
  104362. getClassName(): string;
  104363. }
  104364. }
  104365. declare module BABYLON {
  104366. /**
  104367. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104370. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104371. */
  104372. export class VirtualJoysticksCamera extends FreeCamera {
  104373. /**
  104374. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104375. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104376. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104377. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104378. * @param name Define the name of the camera in the scene
  104379. * @param position Define the start position of the camera in the scene
  104380. * @param scene Define the scene the camera belongs to
  104381. */
  104382. constructor(name: string, position: Vector3, scene: Scene);
  104383. /**
  104384. * Gets the current object class name.
  104385. * @return the class name
  104386. */
  104387. getClassName(): string;
  104388. }
  104389. }
  104390. declare module BABYLON {
  104391. /**
  104392. * This represents all the required metrics to create a VR camera.
  104393. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104394. */
  104395. export class VRCameraMetrics {
  104396. /**
  104397. * Define the horizontal resolution off the screen.
  104398. */
  104399. hResolution: number;
  104400. /**
  104401. * Define the vertical resolution off the screen.
  104402. */
  104403. vResolution: number;
  104404. /**
  104405. * Define the horizontal screen size.
  104406. */
  104407. hScreenSize: number;
  104408. /**
  104409. * Define the vertical screen size.
  104410. */
  104411. vScreenSize: number;
  104412. /**
  104413. * Define the vertical screen center position.
  104414. */
  104415. vScreenCenter: number;
  104416. /**
  104417. * Define the distance of the eyes to the screen.
  104418. */
  104419. eyeToScreenDistance: number;
  104420. /**
  104421. * Define the distance between both lenses
  104422. */
  104423. lensSeparationDistance: number;
  104424. /**
  104425. * Define the distance between both viewer's eyes.
  104426. */
  104427. interpupillaryDistance: number;
  104428. /**
  104429. * Define the distortion factor of the VR postprocess.
  104430. * Please, touch with care.
  104431. */
  104432. distortionK: number[];
  104433. /**
  104434. * Define the chromatic aberration correction factors for the VR post process.
  104435. */
  104436. chromaAbCorrection: number[];
  104437. /**
  104438. * Define the scale factor of the post process.
  104439. * The smaller the better but the slower.
  104440. */
  104441. postProcessScaleFactor: number;
  104442. /**
  104443. * Define an offset for the lens center.
  104444. */
  104445. lensCenterOffset: number;
  104446. /**
  104447. * Define if the current vr camera should compensate the distortion of the lense or not.
  104448. */
  104449. compensateDistortion: boolean;
  104450. /**
  104451. * Defines if multiview should be enabled when rendering (Default: false)
  104452. */
  104453. multiviewEnabled: boolean;
  104454. /**
  104455. * Gets the rendering aspect ratio based on the provided resolutions.
  104456. */
  104457. readonly aspectRatio: number;
  104458. /**
  104459. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104460. */
  104461. readonly aspectRatioFov: number;
  104462. /**
  104463. * @hidden
  104464. */
  104465. readonly leftHMatrix: Matrix;
  104466. /**
  104467. * @hidden
  104468. */
  104469. readonly rightHMatrix: Matrix;
  104470. /**
  104471. * @hidden
  104472. */
  104473. readonly leftPreViewMatrix: Matrix;
  104474. /**
  104475. * @hidden
  104476. */
  104477. readonly rightPreViewMatrix: Matrix;
  104478. /**
  104479. * Get the default VRMetrics based on the most generic setup.
  104480. * @returns the default vr metrics
  104481. */
  104482. static GetDefault(): VRCameraMetrics;
  104483. }
  104484. }
  104485. declare module BABYLON {
  104486. /** @hidden */
  104487. export var vrDistortionCorrectionPixelShader: {
  104488. name: string;
  104489. shader: string;
  104490. };
  104491. }
  104492. declare module BABYLON {
  104493. /**
  104494. * VRDistortionCorrectionPostProcess used for mobile VR
  104495. */
  104496. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104497. private _isRightEye;
  104498. private _distortionFactors;
  104499. private _postProcessScaleFactor;
  104500. private _lensCenterOffset;
  104501. private _scaleIn;
  104502. private _scaleFactor;
  104503. private _lensCenter;
  104504. /**
  104505. * Initializes the VRDistortionCorrectionPostProcess
  104506. * @param name The name of the effect.
  104507. * @param camera The camera to apply the render pass to.
  104508. * @param isRightEye If this is for the right eye distortion
  104509. * @param vrMetrics All the required metrics for the VR camera
  104510. */
  104511. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104512. }
  104513. }
  104514. declare module BABYLON {
  104515. /**
  104516. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104517. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104518. */
  104519. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104520. /**
  104521. * Creates a new VRDeviceOrientationArcRotateCamera
  104522. * @param name defines camera name
  104523. * @param alpha defines the camera rotation along the logitudinal axis
  104524. * @param beta defines the camera rotation along the latitudinal axis
  104525. * @param radius defines the camera distance from its target
  104526. * @param target defines the camera target
  104527. * @param scene defines the scene the camera belongs to
  104528. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104529. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104530. */
  104531. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104532. /**
  104533. * Gets camera class name
  104534. * @returns VRDeviceOrientationArcRotateCamera
  104535. */
  104536. getClassName(): string;
  104537. }
  104538. }
  104539. declare module BABYLON {
  104540. /**
  104541. * Camera used to simulate VR rendering (based on FreeCamera)
  104542. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104543. */
  104544. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104545. /**
  104546. * Creates a new VRDeviceOrientationFreeCamera
  104547. * @param name defines camera name
  104548. * @param position defines the start position of the camera
  104549. * @param scene defines the scene the camera belongs to
  104550. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104551. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104552. */
  104553. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104554. /**
  104555. * Gets camera class name
  104556. * @returns VRDeviceOrientationFreeCamera
  104557. */
  104558. getClassName(): string;
  104559. }
  104560. }
  104561. declare module BABYLON {
  104562. /**
  104563. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  104564. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104565. */
  104566. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  104567. /**
  104568. * Creates a new VRDeviceOrientationGamepadCamera
  104569. * @param name defines camera name
  104570. * @param position defines the start position of the camera
  104571. * @param scene defines the scene the camera belongs to
  104572. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104573. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104574. */
  104575. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104576. /**
  104577. * Gets camera class name
  104578. * @returns VRDeviceOrientationGamepadCamera
  104579. */
  104580. getClassName(): string;
  104581. }
  104582. }
  104583. declare module BABYLON {
  104584. /**
  104585. * Base class of materials working in push mode in babylon JS
  104586. * @hidden
  104587. */
  104588. export class PushMaterial extends Material {
  104589. protected _activeEffect: Effect;
  104590. protected _normalMatrix: Matrix;
  104591. /**
  104592. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  104593. * This means that the material can keep using a previous shader while a new one is being compiled.
  104594. * This is mostly used when shader parallel compilation is supported (true by default)
  104595. */
  104596. allowShaderHotSwapping: boolean;
  104597. constructor(name: string, scene: Scene);
  104598. getEffect(): Effect;
  104599. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104600. /**
  104601. * Binds the given world matrix to the active effect
  104602. *
  104603. * @param world the matrix to bind
  104604. */
  104605. bindOnlyWorldMatrix(world: Matrix): void;
  104606. /**
  104607. * Binds the given normal matrix to the active effect
  104608. *
  104609. * @param normalMatrix the matrix to bind
  104610. */
  104611. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104612. bind(world: Matrix, mesh?: Mesh): void;
  104613. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104614. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104615. }
  104616. }
  104617. declare module BABYLON {
  104618. /**
  104619. * This groups all the flags used to control the materials channel.
  104620. */
  104621. export class MaterialFlags {
  104622. private static _DiffuseTextureEnabled;
  104623. /**
  104624. * Are diffuse textures enabled in the application.
  104625. */
  104626. static DiffuseTextureEnabled: boolean;
  104627. private static _AmbientTextureEnabled;
  104628. /**
  104629. * Are ambient textures enabled in the application.
  104630. */
  104631. static AmbientTextureEnabled: boolean;
  104632. private static _OpacityTextureEnabled;
  104633. /**
  104634. * Are opacity textures enabled in the application.
  104635. */
  104636. static OpacityTextureEnabled: boolean;
  104637. private static _ReflectionTextureEnabled;
  104638. /**
  104639. * Are reflection textures enabled in the application.
  104640. */
  104641. static ReflectionTextureEnabled: boolean;
  104642. private static _EmissiveTextureEnabled;
  104643. /**
  104644. * Are emissive textures enabled in the application.
  104645. */
  104646. static EmissiveTextureEnabled: boolean;
  104647. private static _SpecularTextureEnabled;
  104648. /**
  104649. * Are specular textures enabled in the application.
  104650. */
  104651. static SpecularTextureEnabled: boolean;
  104652. private static _BumpTextureEnabled;
  104653. /**
  104654. * Are bump textures enabled in the application.
  104655. */
  104656. static BumpTextureEnabled: boolean;
  104657. private static _LightmapTextureEnabled;
  104658. /**
  104659. * Are lightmap textures enabled in the application.
  104660. */
  104661. static LightmapTextureEnabled: boolean;
  104662. private static _RefractionTextureEnabled;
  104663. /**
  104664. * Are refraction textures enabled in the application.
  104665. */
  104666. static RefractionTextureEnabled: boolean;
  104667. private static _ColorGradingTextureEnabled;
  104668. /**
  104669. * Are color grading textures enabled in the application.
  104670. */
  104671. static ColorGradingTextureEnabled: boolean;
  104672. private static _FresnelEnabled;
  104673. /**
  104674. * Are fresnels enabled in the application.
  104675. */
  104676. static FresnelEnabled: boolean;
  104677. private static _ClearCoatTextureEnabled;
  104678. /**
  104679. * Are clear coat textures enabled in the application.
  104680. */
  104681. static ClearCoatTextureEnabled: boolean;
  104682. private static _ClearCoatBumpTextureEnabled;
  104683. /**
  104684. * Are clear coat bump textures enabled in the application.
  104685. */
  104686. static ClearCoatBumpTextureEnabled: boolean;
  104687. private static _ClearCoatTintTextureEnabled;
  104688. /**
  104689. * Are clear coat tint textures enabled in the application.
  104690. */
  104691. static ClearCoatTintTextureEnabled: boolean;
  104692. private static _SheenTextureEnabled;
  104693. /**
  104694. * Are sheen textures enabled in the application.
  104695. */
  104696. static SheenTextureEnabled: boolean;
  104697. private static _AnisotropicTextureEnabled;
  104698. /**
  104699. * Are anisotropic textures enabled in the application.
  104700. */
  104701. static AnisotropicTextureEnabled: boolean;
  104702. private static _ThicknessTextureEnabled;
  104703. /**
  104704. * Are thickness textures enabled in the application.
  104705. */
  104706. static ThicknessTextureEnabled: boolean;
  104707. }
  104708. }
  104709. declare module BABYLON {
  104710. /** @hidden */
  104711. export var defaultFragmentDeclaration: {
  104712. name: string;
  104713. shader: string;
  104714. };
  104715. }
  104716. declare module BABYLON {
  104717. /** @hidden */
  104718. export var defaultUboDeclaration: {
  104719. name: string;
  104720. shader: string;
  104721. };
  104722. }
  104723. declare module BABYLON {
  104724. /** @hidden */
  104725. export var lightFragmentDeclaration: {
  104726. name: string;
  104727. shader: string;
  104728. };
  104729. }
  104730. declare module BABYLON {
  104731. /** @hidden */
  104732. export var lightUboDeclaration: {
  104733. name: string;
  104734. shader: string;
  104735. };
  104736. }
  104737. declare module BABYLON {
  104738. /** @hidden */
  104739. export var lightsFragmentFunctions: {
  104740. name: string;
  104741. shader: string;
  104742. };
  104743. }
  104744. declare module BABYLON {
  104745. /** @hidden */
  104746. export var shadowsFragmentFunctions: {
  104747. name: string;
  104748. shader: string;
  104749. };
  104750. }
  104751. declare module BABYLON {
  104752. /** @hidden */
  104753. export var fresnelFunction: {
  104754. name: string;
  104755. shader: string;
  104756. };
  104757. }
  104758. declare module BABYLON {
  104759. /** @hidden */
  104760. export var reflectionFunction: {
  104761. name: string;
  104762. shader: string;
  104763. };
  104764. }
  104765. declare module BABYLON {
  104766. /** @hidden */
  104767. export var bumpFragmentFunctions: {
  104768. name: string;
  104769. shader: string;
  104770. };
  104771. }
  104772. declare module BABYLON {
  104773. /** @hidden */
  104774. export var logDepthDeclaration: {
  104775. name: string;
  104776. shader: string;
  104777. };
  104778. }
  104779. declare module BABYLON {
  104780. /** @hidden */
  104781. export var bumpFragment: {
  104782. name: string;
  104783. shader: string;
  104784. };
  104785. }
  104786. declare module BABYLON {
  104787. /** @hidden */
  104788. export var depthPrePass: {
  104789. name: string;
  104790. shader: string;
  104791. };
  104792. }
  104793. declare module BABYLON {
  104794. /** @hidden */
  104795. export var lightFragment: {
  104796. name: string;
  104797. shader: string;
  104798. };
  104799. }
  104800. declare module BABYLON {
  104801. /** @hidden */
  104802. export var logDepthFragment: {
  104803. name: string;
  104804. shader: string;
  104805. };
  104806. }
  104807. declare module BABYLON {
  104808. /** @hidden */
  104809. export var defaultPixelShader: {
  104810. name: string;
  104811. shader: string;
  104812. };
  104813. }
  104814. declare module BABYLON {
  104815. /** @hidden */
  104816. export var defaultVertexDeclaration: {
  104817. name: string;
  104818. shader: string;
  104819. };
  104820. }
  104821. declare module BABYLON {
  104822. /** @hidden */
  104823. export var bumpVertexDeclaration: {
  104824. name: string;
  104825. shader: string;
  104826. };
  104827. }
  104828. declare module BABYLON {
  104829. /** @hidden */
  104830. export var bumpVertex: {
  104831. name: string;
  104832. shader: string;
  104833. };
  104834. }
  104835. declare module BABYLON {
  104836. /** @hidden */
  104837. export var fogVertex: {
  104838. name: string;
  104839. shader: string;
  104840. };
  104841. }
  104842. declare module BABYLON {
  104843. /** @hidden */
  104844. export var shadowsVertex: {
  104845. name: string;
  104846. shader: string;
  104847. };
  104848. }
  104849. declare module BABYLON {
  104850. /** @hidden */
  104851. export var pointCloudVertex: {
  104852. name: string;
  104853. shader: string;
  104854. };
  104855. }
  104856. declare module BABYLON {
  104857. /** @hidden */
  104858. export var logDepthVertex: {
  104859. name: string;
  104860. shader: string;
  104861. };
  104862. }
  104863. declare module BABYLON {
  104864. /** @hidden */
  104865. export var defaultVertexShader: {
  104866. name: string;
  104867. shader: string;
  104868. };
  104869. }
  104870. declare module BABYLON {
  104871. /** @hidden */
  104872. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104873. MAINUV1: boolean;
  104874. MAINUV2: boolean;
  104875. DIFFUSE: boolean;
  104876. DIFFUSEDIRECTUV: number;
  104877. AMBIENT: boolean;
  104878. AMBIENTDIRECTUV: number;
  104879. OPACITY: boolean;
  104880. OPACITYDIRECTUV: number;
  104881. OPACITYRGB: boolean;
  104882. REFLECTION: boolean;
  104883. EMISSIVE: boolean;
  104884. EMISSIVEDIRECTUV: number;
  104885. SPECULAR: boolean;
  104886. SPECULARDIRECTUV: number;
  104887. BUMP: boolean;
  104888. BUMPDIRECTUV: number;
  104889. PARALLAX: boolean;
  104890. PARALLAXOCCLUSION: boolean;
  104891. SPECULAROVERALPHA: boolean;
  104892. CLIPPLANE: boolean;
  104893. CLIPPLANE2: boolean;
  104894. CLIPPLANE3: boolean;
  104895. CLIPPLANE4: boolean;
  104896. ALPHATEST: boolean;
  104897. DEPTHPREPASS: boolean;
  104898. ALPHAFROMDIFFUSE: boolean;
  104899. POINTSIZE: boolean;
  104900. FOG: boolean;
  104901. SPECULARTERM: boolean;
  104902. DIFFUSEFRESNEL: boolean;
  104903. OPACITYFRESNEL: boolean;
  104904. REFLECTIONFRESNEL: boolean;
  104905. REFRACTIONFRESNEL: boolean;
  104906. EMISSIVEFRESNEL: boolean;
  104907. FRESNEL: boolean;
  104908. NORMAL: boolean;
  104909. UV1: boolean;
  104910. UV2: boolean;
  104911. VERTEXCOLOR: boolean;
  104912. VERTEXALPHA: boolean;
  104913. NUM_BONE_INFLUENCERS: number;
  104914. BonesPerMesh: number;
  104915. BONETEXTURE: boolean;
  104916. INSTANCES: boolean;
  104917. GLOSSINESS: boolean;
  104918. ROUGHNESS: boolean;
  104919. EMISSIVEASILLUMINATION: boolean;
  104920. LINKEMISSIVEWITHDIFFUSE: boolean;
  104921. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104922. LIGHTMAP: boolean;
  104923. LIGHTMAPDIRECTUV: number;
  104924. OBJECTSPACE_NORMALMAP: boolean;
  104925. USELIGHTMAPASSHADOWMAP: boolean;
  104926. REFLECTIONMAP_3D: boolean;
  104927. REFLECTIONMAP_SPHERICAL: boolean;
  104928. REFLECTIONMAP_PLANAR: boolean;
  104929. REFLECTIONMAP_CUBIC: boolean;
  104930. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104931. REFLECTIONMAP_PROJECTION: boolean;
  104932. REFLECTIONMAP_SKYBOX: boolean;
  104933. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104934. REFLECTIONMAP_EXPLICIT: boolean;
  104935. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104936. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104937. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104938. INVERTCUBICMAP: boolean;
  104939. LOGARITHMICDEPTH: boolean;
  104940. REFRACTION: boolean;
  104941. REFRACTIONMAP_3D: boolean;
  104942. REFLECTIONOVERALPHA: boolean;
  104943. TWOSIDEDLIGHTING: boolean;
  104944. SHADOWFLOAT: boolean;
  104945. MORPHTARGETS: boolean;
  104946. MORPHTARGETS_NORMAL: boolean;
  104947. MORPHTARGETS_TANGENT: boolean;
  104948. MORPHTARGETS_UV: boolean;
  104949. NUM_MORPH_INFLUENCERS: number;
  104950. NONUNIFORMSCALING: boolean;
  104951. PREMULTIPLYALPHA: boolean;
  104952. IMAGEPROCESSING: boolean;
  104953. VIGNETTE: boolean;
  104954. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104955. VIGNETTEBLENDMODEOPAQUE: boolean;
  104956. TONEMAPPING: boolean;
  104957. TONEMAPPING_ACES: boolean;
  104958. CONTRAST: boolean;
  104959. COLORCURVES: boolean;
  104960. COLORGRADING: boolean;
  104961. COLORGRADING3D: boolean;
  104962. SAMPLER3DGREENDEPTH: boolean;
  104963. SAMPLER3DBGRMAP: boolean;
  104964. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104965. MULTIVIEW: boolean;
  104966. /**
  104967. * If the reflection texture on this material is in linear color space
  104968. * @hidden
  104969. */
  104970. IS_REFLECTION_LINEAR: boolean;
  104971. /**
  104972. * If the refraction texture on this material is in linear color space
  104973. * @hidden
  104974. */
  104975. IS_REFRACTION_LINEAR: boolean;
  104976. EXPOSURE: boolean;
  104977. constructor();
  104978. setReflectionMode(modeToEnable: string): void;
  104979. }
  104980. /**
  104981. * This is the default material used in Babylon. It is the best trade off between quality
  104982. * and performances.
  104983. * @see http://doc.babylonjs.com/babylon101/materials
  104984. */
  104985. export class StandardMaterial extends PushMaterial {
  104986. private _diffuseTexture;
  104987. /**
  104988. * The basic texture of the material as viewed under a light.
  104989. */
  104990. diffuseTexture: Nullable<BaseTexture>;
  104991. private _ambientTexture;
  104992. /**
  104993. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104994. */
  104995. ambientTexture: Nullable<BaseTexture>;
  104996. private _opacityTexture;
  104997. /**
  104998. * Define the transparency of the material from a texture.
  104999. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105000. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105001. */
  105002. opacityTexture: Nullable<BaseTexture>;
  105003. private _reflectionTexture;
  105004. /**
  105005. * Define the texture used to display the reflection.
  105006. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105007. */
  105008. reflectionTexture: Nullable<BaseTexture>;
  105009. private _emissiveTexture;
  105010. /**
  105011. * Define texture of the material as if self lit.
  105012. * This will be mixed in the final result even in the absence of light.
  105013. */
  105014. emissiveTexture: Nullable<BaseTexture>;
  105015. private _specularTexture;
  105016. /**
  105017. * Define how the color and intensity of the highlight given by the light in the material.
  105018. */
  105019. specularTexture: Nullable<BaseTexture>;
  105020. private _bumpTexture;
  105021. /**
  105022. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105023. * 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.
  105024. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105025. */
  105026. bumpTexture: Nullable<BaseTexture>;
  105027. private _lightmapTexture;
  105028. /**
  105029. * Complex lighting can be computationally expensive to compute at runtime.
  105030. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105031. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105032. */
  105033. lightmapTexture: Nullable<BaseTexture>;
  105034. private _refractionTexture;
  105035. /**
  105036. * Define the texture used to display the refraction.
  105037. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105038. */
  105039. refractionTexture: Nullable<BaseTexture>;
  105040. /**
  105041. * The color of the material lit by the environmental background lighting.
  105042. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105043. */
  105044. ambientColor: Color3;
  105045. /**
  105046. * The basic color of the material as viewed under a light.
  105047. */
  105048. diffuseColor: Color3;
  105049. /**
  105050. * Define how the color and intensity of the highlight given by the light in the material.
  105051. */
  105052. specularColor: Color3;
  105053. /**
  105054. * Define the color of the material as if self lit.
  105055. * This will be mixed in the final result even in the absence of light.
  105056. */
  105057. emissiveColor: Color3;
  105058. /**
  105059. * Defines how sharp are the highlights in the material.
  105060. * The bigger the value the sharper giving a more glossy feeling to the result.
  105061. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105062. */
  105063. specularPower: number;
  105064. private _useAlphaFromDiffuseTexture;
  105065. /**
  105066. * Does the transparency come from the diffuse texture alpha channel.
  105067. */
  105068. useAlphaFromDiffuseTexture: boolean;
  105069. private _useEmissiveAsIllumination;
  105070. /**
  105071. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105072. */
  105073. useEmissiveAsIllumination: boolean;
  105074. private _linkEmissiveWithDiffuse;
  105075. /**
  105076. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105077. * the emissive level when the final color is close to one.
  105078. */
  105079. linkEmissiveWithDiffuse: boolean;
  105080. private _useSpecularOverAlpha;
  105081. /**
  105082. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105083. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105084. */
  105085. useSpecularOverAlpha: boolean;
  105086. private _useReflectionOverAlpha;
  105087. /**
  105088. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105089. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105090. */
  105091. useReflectionOverAlpha: boolean;
  105092. private _disableLighting;
  105093. /**
  105094. * Does lights from the scene impacts this material.
  105095. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105096. */
  105097. disableLighting: boolean;
  105098. private _useObjectSpaceNormalMap;
  105099. /**
  105100. * Allows using an object space normal map (instead of tangent space).
  105101. */
  105102. useObjectSpaceNormalMap: boolean;
  105103. private _useParallax;
  105104. /**
  105105. * Is parallax enabled or not.
  105106. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105107. */
  105108. useParallax: boolean;
  105109. private _useParallaxOcclusion;
  105110. /**
  105111. * Is parallax occlusion enabled or not.
  105112. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105113. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105114. */
  105115. useParallaxOcclusion: boolean;
  105116. /**
  105117. * 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.
  105118. */
  105119. parallaxScaleBias: number;
  105120. private _roughness;
  105121. /**
  105122. * Helps to define how blurry the reflections should appears in the material.
  105123. */
  105124. roughness: number;
  105125. /**
  105126. * In case of refraction, define the value of the index of refraction.
  105127. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105128. */
  105129. indexOfRefraction: number;
  105130. /**
  105131. * Invert the refraction texture alongside the y axis.
  105132. * It can be useful with procedural textures or probe for instance.
  105133. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105134. */
  105135. invertRefractionY: boolean;
  105136. /**
  105137. * Defines the alpha limits in alpha test mode.
  105138. */
  105139. alphaCutOff: number;
  105140. private _useLightmapAsShadowmap;
  105141. /**
  105142. * In case of light mapping, define whether the map contains light or shadow informations.
  105143. */
  105144. useLightmapAsShadowmap: boolean;
  105145. private _diffuseFresnelParameters;
  105146. /**
  105147. * Define the diffuse fresnel parameters of the material.
  105148. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105149. */
  105150. diffuseFresnelParameters: FresnelParameters;
  105151. private _opacityFresnelParameters;
  105152. /**
  105153. * Define the opacity fresnel parameters of the material.
  105154. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105155. */
  105156. opacityFresnelParameters: FresnelParameters;
  105157. private _reflectionFresnelParameters;
  105158. /**
  105159. * Define the reflection fresnel parameters of the material.
  105160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105161. */
  105162. reflectionFresnelParameters: FresnelParameters;
  105163. private _refractionFresnelParameters;
  105164. /**
  105165. * Define the refraction fresnel parameters of the material.
  105166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105167. */
  105168. refractionFresnelParameters: FresnelParameters;
  105169. private _emissiveFresnelParameters;
  105170. /**
  105171. * Define the emissive fresnel parameters of the material.
  105172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105173. */
  105174. emissiveFresnelParameters: FresnelParameters;
  105175. private _useReflectionFresnelFromSpecular;
  105176. /**
  105177. * If true automatically deducts the fresnels values from the material specularity.
  105178. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105179. */
  105180. useReflectionFresnelFromSpecular: boolean;
  105181. private _useGlossinessFromSpecularMapAlpha;
  105182. /**
  105183. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105184. */
  105185. useGlossinessFromSpecularMapAlpha: boolean;
  105186. private _maxSimultaneousLights;
  105187. /**
  105188. * Defines the maximum number of lights that can be used in the material
  105189. */
  105190. maxSimultaneousLights: number;
  105191. private _invertNormalMapX;
  105192. /**
  105193. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105194. */
  105195. invertNormalMapX: boolean;
  105196. private _invertNormalMapY;
  105197. /**
  105198. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105199. */
  105200. invertNormalMapY: boolean;
  105201. private _twoSidedLighting;
  105202. /**
  105203. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105204. */
  105205. twoSidedLighting: boolean;
  105206. /**
  105207. * Default configuration related to image processing available in the standard Material.
  105208. */
  105209. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105210. /**
  105211. * Gets the image processing configuration used either in this material.
  105212. */
  105213. /**
  105214. * Sets the Default image processing configuration used either in the this material.
  105215. *
  105216. * If sets to null, the scene one is in use.
  105217. */
  105218. imageProcessingConfiguration: ImageProcessingConfiguration;
  105219. /**
  105220. * Keep track of the image processing observer to allow dispose and replace.
  105221. */
  105222. private _imageProcessingObserver;
  105223. /**
  105224. * Attaches a new image processing configuration to the Standard Material.
  105225. * @param configuration
  105226. */
  105227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105228. /**
  105229. * Gets wether the color curves effect is enabled.
  105230. */
  105231. /**
  105232. * Sets wether the color curves effect is enabled.
  105233. */
  105234. cameraColorCurvesEnabled: boolean;
  105235. /**
  105236. * Gets wether the color grading effect is enabled.
  105237. */
  105238. /**
  105239. * Gets wether the color grading effect is enabled.
  105240. */
  105241. cameraColorGradingEnabled: boolean;
  105242. /**
  105243. * Gets wether tonemapping is enabled or not.
  105244. */
  105245. /**
  105246. * Sets wether tonemapping is enabled or not
  105247. */
  105248. cameraToneMappingEnabled: boolean;
  105249. /**
  105250. * The camera exposure used on this material.
  105251. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105252. * This corresponds to a photographic exposure.
  105253. */
  105254. /**
  105255. * The camera exposure used on this material.
  105256. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105257. * This corresponds to a photographic exposure.
  105258. */
  105259. cameraExposure: number;
  105260. /**
  105261. * Gets The camera contrast used on this material.
  105262. */
  105263. /**
  105264. * Sets The camera contrast used on this material.
  105265. */
  105266. cameraContrast: number;
  105267. /**
  105268. * Gets the Color Grading 2D Lookup Texture.
  105269. */
  105270. /**
  105271. * Sets the Color Grading 2D Lookup Texture.
  105272. */
  105273. cameraColorGradingTexture: Nullable<BaseTexture>;
  105274. /**
  105275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105277. * 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;
  105278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105279. */
  105280. /**
  105281. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105282. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105283. * 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;
  105284. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105285. */
  105286. cameraColorCurves: Nullable<ColorCurves>;
  105287. /**
  105288. * Custom callback helping to override the default shader used in the material.
  105289. */
  105290. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105291. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105292. protected _worldViewProjectionMatrix: Matrix;
  105293. protected _globalAmbientColor: Color3;
  105294. protected _useLogarithmicDepth: boolean;
  105295. protected _rebuildInParallel: boolean;
  105296. /**
  105297. * Instantiates a new standard material.
  105298. * This is the default material used in Babylon. It is the best trade off between quality
  105299. * and performances.
  105300. * @see http://doc.babylonjs.com/babylon101/materials
  105301. * @param name Define the name of the material in the scene
  105302. * @param scene Define the scene the material belong to
  105303. */
  105304. constructor(name: string, scene: Scene);
  105305. /**
  105306. * Gets a boolean indicating that current material needs to register RTT
  105307. */
  105308. readonly hasRenderTargetTextures: boolean;
  105309. /**
  105310. * Gets the current class name of the material e.g. "StandardMaterial"
  105311. * Mainly use in serialization.
  105312. * @returns the class name
  105313. */
  105314. getClassName(): string;
  105315. /**
  105316. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105317. * You can try switching to logarithmic depth.
  105318. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105319. */
  105320. useLogarithmicDepth: boolean;
  105321. /**
  105322. * Specifies if the material will require alpha blending
  105323. * @returns a boolean specifying if alpha blending is needed
  105324. */
  105325. needAlphaBlending(): boolean;
  105326. /**
  105327. * Specifies if this material should be rendered in alpha test mode
  105328. * @returns a boolean specifying if an alpha test is needed.
  105329. */
  105330. needAlphaTesting(): boolean;
  105331. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105332. /**
  105333. * Get the texture used for alpha test purpose.
  105334. * @returns the diffuse texture in case of the standard material.
  105335. */
  105336. getAlphaTestTexture(): Nullable<BaseTexture>;
  105337. /**
  105338. * Get if the submesh is ready to be used and all its information available.
  105339. * Child classes can use it to update shaders
  105340. * @param mesh defines the mesh to check
  105341. * @param subMesh defines which submesh to check
  105342. * @param useInstances specifies that instances should be used
  105343. * @returns a boolean indicating that the submesh is ready or not
  105344. */
  105345. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105346. /**
  105347. * Builds the material UBO layouts.
  105348. * Used internally during the effect preparation.
  105349. */
  105350. buildUniformLayout(): void;
  105351. /**
  105352. * Unbinds the material from the mesh
  105353. */
  105354. unbind(): void;
  105355. /**
  105356. * Binds the submesh to this material by preparing the effect and shader to draw
  105357. * @param world defines the world transformation matrix
  105358. * @param mesh defines the mesh containing the submesh
  105359. * @param subMesh defines the submesh to bind the material to
  105360. */
  105361. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105362. /**
  105363. * Get the list of animatables in the material.
  105364. * @returns the list of animatables object used in the material
  105365. */
  105366. getAnimatables(): IAnimatable[];
  105367. /**
  105368. * Gets the active textures from the material
  105369. * @returns an array of textures
  105370. */
  105371. getActiveTextures(): BaseTexture[];
  105372. /**
  105373. * Specifies if the material uses a texture
  105374. * @param texture defines the texture to check against the material
  105375. * @returns a boolean specifying if the material uses the texture
  105376. */
  105377. hasTexture(texture: BaseTexture): boolean;
  105378. /**
  105379. * Disposes the material
  105380. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105381. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105382. */
  105383. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105384. /**
  105385. * Makes a duplicate of the material, and gives it a new name
  105386. * @param name defines the new name for the duplicated material
  105387. * @returns the cloned material
  105388. */
  105389. clone(name: string): StandardMaterial;
  105390. /**
  105391. * Serializes this material in a JSON representation
  105392. * @returns the serialized material object
  105393. */
  105394. serialize(): any;
  105395. /**
  105396. * Creates a standard material from parsed material data
  105397. * @param source defines the JSON representation of the material
  105398. * @param scene defines the hosting scene
  105399. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105400. * @returns a new standard material
  105401. */
  105402. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105403. /**
  105404. * Are diffuse textures enabled in the application.
  105405. */
  105406. static DiffuseTextureEnabled: boolean;
  105407. /**
  105408. * Are ambient textures enabled in the application.
  105409. */
  105410. static AmbientTextureEnabled: boolean;
  105411. /**
  105412. * Are opacity textures enabled in the application.
  105413. */
  105414. static OpacityTextureEnabled: boolean;
  105415. /**
  105416. * Are reflection textures enabled in the application.
  105417. */
  105418. static ReflectionTextureEnabled: boolean;
  105419. /**
  105420. * Are emissive textures enabled in the application.
  105421. */
  105422. static EmissiveTextureEnabled: boolean;
  105423. /**
  105424. * Are specular textures enabled in the application.
  105425. */
  105426. static SpecularTextureEnabled: boolean;
  105427. /**
  105428. * Are bump textures enabled in the application.
  105429. */
  105430. static BumpTextureEnabled: boolean;
  105431. /**
  105432. * Are lightmap textures enabled in the application.
  105433. */
  105434. static LightmapTextureEnabled: boolean;
  105435. /**
  105436. * Are refraction textures enabled in the application.
  105437. */
  105438. static RefractionTextureEnabled: boolean;
  105439. /**
  105440. * Are color grading textures enabled in the application.
  105441. */
  105442. static ColorGradingTextureEnabled: boolean;
  105443. /**
  105444. * Are fresnels enabled in the application.
  105445. */
  105446. static FresnelEnabled: boolean;
  105447. }
  105448. }
  105449. declare module BABYLON {
  105450. /**
  105451. * A class extending Texture allowing drawing on a texture
  105452. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105453. */
  105454. export class DynamicTexture extends Texture {
  105455. private _generateMipMaps;
  105456. private _canvas;
  105457. private _context;
  105458. private _engine;
  105459. /**
  105460. * Creates a DynamicTexture
  105461. * @param name defines the name of the texture
  105462. * @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
  105463. * @param scene defines the scene where you want the texture
  105464. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105465. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105466. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105467. */
  105468. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105469. /**
  105470. * Get the current class name of the texture useful for serialization or dynamic coding.
  105471. * @returns "DynamicTexture"
  105472. */
  105473. getClassName(): string;
  105474. /**
  105475. * Gets the current state of canRescale
  105476. */
  105477. readonly canRescale: boolean;
  105478. private _recreate;
  105479. /**
  105480. * Scales the texture
  105481. * @param ratio the scale factor to apply to both width and height
  105482. */
  105483. scale(ratio: number): void;
  105484. /**
  105485. * Resizes the texture
  105486. * @param width the new width
  105487. * @param height the new height
  105488. */
  105489. scaleTo(width: number, height: number): void;
  105490. /**
  105491. * Gets the context of the canvas used by the texture
  105492. * @returns the canvas context of the dynamic texture
  105493. */
  105494. getContext(): CanvasRenderingContext2D;
  105495. /**
  105496. * Clears the texture
  105497. */
  105498. clear(): void;
  105499. /**
  105500. * Updates the texture
  105501. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105502. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105503. */
  105504. update(invertY?: boolean, premulAlpha?: boolean): void;
  105505. /**
  105506. * Draws text onto the texture
  105507. * @param text defines the text to be drawn
  105508. * @param x defines the placement of the text from the left
  105509. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105510. * @param font defines the font to be used with font-style, font-size, font-name
  105511. * @param color defines the color used for the text
  105512. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105513. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105514. * @param update defines whether texture is immediately update (default is true)
  105515. */
  105516. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105517. /**
  105518. * Clones the texture
  105519. * @returns the clone of the texture.
  105520. */
  105521. clone(): DynamicTexture;
  105522. /**
  105523. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105524. * @returns a serialized dynamic texture object
  105525. */
  105526. serialize(): any;
  105527. /** @hidden */
  105528. _rebuild(): void;
  105529. }
  105530. }
  105531. declare module BABYLON {
  105532. /** @hidden */
  105533. export var imageProcessingPixelShader: {
  105534. name: string;
  105535. shader: string;
  105536. };
  105537. }
  105538. declare module BABYLON {
  105539. /**
  105540. * ImageProcessingPostProcess
  105541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105542. */
  105543. export class ImageProcessingPostProcess extends PostProcess {
  105544. /**
  105545. * Default configuration related to image processing available in the PBR Material.
  105546. */
  105547. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105548. /**
  105549. * Gets the image processing configuration used either in this material.
  105550. */
  105551. /**
  105552. * Sets the Default image processing configuration used either in the this material.
  105553. *
  105554. * If sets to null, the scene one is in use.
  105555. */
  105556. imageProcessingConfiguration: ImageProcessingConfiguration;
  105557. /**
  105558. * Keep track of the image processing observer to allow dispose and replace.
  105559. */
  105560. private _imageProcessingObserver;
  105561. /**
  105562. * Attaches a new image processing configuration to the PBR Material.
  105563. * @param configuration
  105564. */
  105565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  105566. /**
  105567. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105568. */
  105569. /**
  105570. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105571. */
  105572. colorCurves: Nullable<ColorCurves>;
  105573. /**
  105574. * Gets wether the color curves effect is enabled.
  105575. */
  105576. /**
  105577. * Sets wether the color curves effect is enabled.
  105578. */
  105579. colorCurvesEnabled: boolean;
  105580. /**
  105581. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105582. */
  105583. /**
  105584. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105585. */
  105586. colorGradingTexture: Nullable<BaseTexture>;
  105587. /**
  105588. * Gets wether the color grading effect is enabled.
  105589. */
  105590. /**
  105591. * Gets wether the color grading effect is enabled.
  105592. */
  105593. colorGradingEnabled: boolean;
  105594. /**
  105595. * Gets exposure used in the effect.
  105596. */
  105597. /**
  105598. * Sets exposure used in the effect.
  105599. */
  105600. exposure: number;
  105601. /**
  105602. * Gets wether tonemapping is enabled or not.
  105603. */
  105604. /**
  105605. * Sets wether tonemapping is enabled or not
  105606. */
  105607. toneMappingEnabled: boolean;
  105608. /**
  105609. * Gets the type of tone mapping effect.
  105610. */
  105611. /**
  105612. * Sets the type of tone mapping effect.
  105613. */
  105614. toneMappingType: number;
  105615. /**
  105616. * Gets contrast used in the effect.
  105617. */
  105618. /**
  105619. * Sets contrast used in the effect.
  105620. */
  105621. contrast: number;
  105622. /**
  105623. * Gets Vignette stretch size.
  105624. */
  105625. /**
  105626. * Sets Vignette stretch size.
  105627. */
  105628. vignetteStretch: number;
  105629. /**
  105630. * Gets Vignette centre X Offset.
  105631. */
  105632. /**
  105633. * Sets Vignette centre X Offset.
  105634. */
  105635. vignetteCentreX: number;
  105636. /**
  105637. * Gets Vignette centre Y Offset.
  105638. */
  105639. /**
  105640. * Sets Vignette centre Y Offset.
  105641. */
  105642. vignetteCentreY: number;
  105643. /**
  105644. * Gets Vignette weight or intensity of the vignette effect.
  105645. */
  105646. /**
  105647. * Sets Vignette weight or intensity of the vignette effect.
  105648. */
  105649. vignetteWeight: number;
  105650. /**
  105651. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105652. * if vignetteEnabled is set to true.
  105653. */
  105654. /**
  105655. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105656. * if vignetteEnabled is set to true.
  105657. */
  105658. vignetteColor: Color4;
  105659. /**
  105660. * Gets Camera field of view used by the Vignette effect.
  105661. */
  105662. /**
  105663. * Sets Camera field of view used by the Vignette effect.
  105664. */
  105665. vignetteCameraFov: number;
  105666. /**
  105667. * Gets the vignette blend mode allowing different kind of effect.
  105668. */
  105669. /**
  105670. * Sets the vignette blend mode allowing different kind of effect.
  105671. */
  105672. vignetteBlendMode: number;
  105673. /**
  105674. * Gets wether the vignette effect is enabled.
  105675. */
  105676. /**
  105677. * Sets wether the vignette effect is enabled.
  105678. */
  105679. vignetteEnabled: boolean;
  105680. private _fromLinearSpace;
  105681. /**
  105682. * Gets wether the input of the processing is in Gamma or Linear Space.
  105683. */
  105684. /**
  105685. * Sets wether the input of the processing is in Gamma or Linear Space.
  105686. */
  105687. fromLinearSpace: boolean;
  105688. /**
  105689. * Defines cache preventing GC.
  105690. */
  105691. private _defines;
  105692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105693. /**
  105694. * "ImageProcessingPostProcess"
  105695. * @returns "ImageProcessingPostProcess"
  105696. */
  105697. getClassName(): string;
  105698. protected _updateParameters(): void;
  105699. dispose(camera?: Camera): void;
  105700. }
  105701. }
  105702. declare module BABYLON {
  105703. /**
  105704. * Class containing static functions to help procedurally build meshes
  105705. */
  105706. export class GroundBuilder {
  105707. /**
  105708. * Creates a ground mesh
  105709. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105710. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105712. * @param name defines the name of the mesh
  105713. * @param options defines the options used to create the mesh
  105714. * @param scene defines the hosting scene
  105715. * @returns the ground mesh
  105716. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105717. */
  105718. static CreateGround(name: string, options: {
  105719. width?: number;
  105720. height?: number;
  105721. subdivisions?: number;
  105722. subdivisionsX?: number;
  105723. subdivisionsY?: number;
  105724. updatable?: boolean;
  105725. }, scene: any): Mesh;
  105726. /**
  105727. * Creates a tiled ground mesh
  105728. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105729. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105730. * * 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
  105731. * * 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
  105732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105733. * @param name defines the name of the mesh
  105734. * @param options defines the options used to create the mesh
  105735. * @param scene defines the hosting scene
  105736. * @returns the tiled ground mesh
  105737. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105738. */
  105739. static CreateTiledGround(name: string, options: {
  105740. xmin: number;
  105741. zmin: number;
  105742. xmax: number;
  105743. zmax: number;
  105744. subdivisions?: {
  105745. w: number;
  105746. h: number;
  105747. };
  105748. precision?: {
  105749. w: number;
  105750. h: number;
  105751. };
  105752. updatable?: boolean;
  105753. }, scene?: Nullable<Scene>): Mesh;
  105754. /**
  105755. * Creates a ground mesh from a height map
  105756. * * The parameter `url` sets the URL of the height map image resource.
  105757. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105758. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105759. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105760. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105761. * * 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.
  105762. * * 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).
  105763. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105765. * @param name defines the name of the mesh
  105766. * @param url defines the url to the height map
  105767. * @param options defines the options used to create the mesh
  105768. * @param scene defines the hosting scene
  105769. * @returns the ground mesh
  105770. * @see https://doc.babylonjs.com/babylon101/height_map
  105771. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105772. */
  105773. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105774. width?: number;
  105775. height?: number;
  105776. subdivisions?: number;
  105777. minHeight?: number;
  105778. maxHeight?: number;
  105779. colorFilter?: Color3;
  105780. alphaFilter?: number;
  105781. updatable?: boolean;
  105782. onReady?: (mesh: GroundMesh) => void;
  105783. }, scene?: Nullable<Scene>): GroundMesh;
  105784. }
  105785. }
  105786. declare module BABYLON {
  105787. /**
  105788. * Class containing static functions to help procedurally build meshes
  105789. */
  105790. export class TorusBuilder {
  105791. /**
  105792. * Creates a torus mesh
  105793. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105794. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105795. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105799. * @param name defines the name of the mesh
  105800. * @param options defines the options used to create the mesh
  105801. * @param scene defines the hosting scene
  105802. * @returns the torus mesh
  105803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105804. */
  105805. static CreateTorus(name: string, options: {
  105806. diameter?: number;
  105807. thickness?: number;
  105808. tessellation?: number;
  105809. updatable?: boolean;
  105810. sideOrientation?: number;
  105811. frontUVs?: Vector4;
  105812. backUVs?: Vector4;
  105813. }, scene: any): Mesh;
  105814. }
  105815. }
  105816. declare module BABYLON {
  105817. /**
  105818. * Class containing static functions to help procedurally build meshes
  105819. */
  105820. export class CylinderBuilder {
  105821. /**
  105822. * Creates a cylinder or a cone mesh
  105823. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105824. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105825. * * 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.
  105826. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105827. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105828. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105829. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105830. * * 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).
  105831. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105832. * * 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).
  105833. * * 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
  105834. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105835. * * 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
  105836. * * 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.
  105837. * * If `enclose` is false, a ring surface is one element.
  105838. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105839. * * 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
  105840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105843. * @param name defines the name of the mesh
  105844. * @param options defines the options used to create the mesh
  105845. * @param scene defines the hosting scene
  105846. * @returns the cylinder mesh
  105847. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105848. */
  105849. static CreateCylinder(name: string, options: {
  105850. height?: number;
  105851. diameterTop?: number;
  105852. diameterBottom?: number;
  105853. diameter?: number;
  105854. tessellation?: number;
  105855. subdivisions?: number;
  105856. arc?: number;
  105857. faceColors?: Color4[];
  105858. faceUV?: Vector4[];
  105859. updatable?: boolean;
  105860. hasRings?: boolean;
  105861. enclose?: boolean;
  105862. cap?: number;
  105863. sideOrientation?: number;
  105864. frontUVs?: Vector4;
  105865. backUVs?: Vector4;
  105866. }, scene: any): Mesh;
  105867. }
  105868. }
  105869. declare module BABYLON {
  105870. /**
  105871. * Options to modify the vr teleportation behavior.
  105872. */
  105873. export interface VRTeleportationOptions {
  105874. /**
  105875. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105876. */
  105877. floorMeshName?: string;
  105878. /**
  105879. * A list of meshes to be used as the teleportation floor. (default: empty)
  105880. */
  105881. floorMeshes?: Mesh[];
  105882. }
  105883. /**
  105884. * Options to modify the vr experience helper's behavior.
  105885. */
  105886. export interface VRExperienceHelperOptions extends WebVROptions {
  105887. /**
  105888. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105889. */
  105890. createDeviceOrientationCamera?: boolean;
  105891. /**
  105892. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105893. */
  105894. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105895. /**
  105896. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105897. */
  105898. laserToggle?: boolean;
  105899. /**
  105900. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105901. */
  105902. floorMeshes?: Mesh[];
  105903. /**
  105904. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105905. */
  105906. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105907. }
  105908. /**
  105909. * Event containing information after VR has been entered
  105910. */
  105911. export class OnAfterEnteringVRObservableEvent {
  105912. /**
  105913. * If entering vr was successful
  105914. */
  105915. success: boolean;
  105916. }
  105917. /**
  105918. * Helps to quickly add VR support to an existing scene.
  105919. * See http://doc.babylonjs.com/how_to/webvr_helper
  105920. */
  105921. export class VRExperienceHelper {
  105922. /** Options to modify the vr experience helper's behavior. */
  105923. webVROptions: VRExperienceHelperOptions;
  105924. private _scene;
  105925. private _position;
  105926. private _btnVR;
  105927. private _btnVRDisplayed;
  105928. private _webVRsupported;
  105929. private _webVRready;
  105930. private _webVRrequesting;
  105931. private _webVRpresenting;
  105932. private _hasEnteredVR;
  105933. private _fullscreenVRpresenting;
  105934. private _canvas;
  105935. private _webVRCamera;
  105936. private _vrDeviceOrientationCamera;
  105937. private _deviceOrientationCamera;
  105938. private _existingCamera;
  105939. private _onKeyDown;
  105940. private _onVrDisplayPresentChange;
  105941. private _onVRDisplayChanged;
  105942. private _onVRRequestPresentStart;
  105943. private _onVRRequestPresentComplete;
  105944. /**
  105945. * 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)
  105946. */
  105947. enableGazeEvenWhenNoPointerLock: boolean;
  105948. /**
  105949. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105950. */
  105951. exitVROnDoubleTap: boolean;
  105952. /**
  105953. * Observable raised right before entering VR.
  105954. */
  105955. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105956. /**
  105957. * Observable raised when entering VR has completed.
  105958. */
  105959. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105960. /**
  105961. * Observable raised when exiting VR.
  105962. */
  105963. onExitingVRObservable: Observable<VRExperienceHelper>;
  105964. /**
  105965. * Observable raised when controller mesh is loaded.
  105966. */
  105967. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105968. /** Return this.onEnteringVRObservable
  105969. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105970. */
  105971. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105972. /** Return this.onExitingVRObservable
  105973. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105974. */
  105975. readonly onExitingVR: Observable<VRExperienceHelper>;
  105976. /** Return this.onControllerMeshLoadedObservable
  105977. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105978. */
  105979. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105980. private _rayLength;
  105981. private _useCustomVRButton;
  105982. private _teleportationRequested;
  105983. private _teleportActive;
  105984. private _floorMeshName;
  105985. private _floorMeshesCollection;
  105986. private _rotationAllowed;
  105987. private _teleportBackwardsVector;
  105988. private _teleportationTarget;
  105989. private _isDefaultTeleportationTarget;
  105990. private _postProcessMove;
  105991. private _teleportationFillColor;
  105992. private _teleportationBorderColor;
  105993. private _rotationAngle;
  105994. private _haloCenter;
  105995. private _cameraGazer;
  105996. private _padSensibilityUp;
  105997. private _padSensibilityDown;
  105998. private _leftController;
  105999. private _rightController;
  106000. /**
  106001. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106002. */
  106003. onNewMeshSelected: Observable<AbstractMesh>;
  106004. /**
  106005. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106006. * This observable will provide the mesh and the controller used to select the mesh
  106007. */
  106008. onMeshSelectedWithController: Observable<{
  106009. mesh: AbstractMesh;
  106010. controller: WebVRController;
  106011. }>;
  106012. /**
  106013. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106014. */
  106015. onNewMeshPicked: Observable<PickingInfo>;
  106016. private _circleEase;
  106017. /**
  106018. * Observable raised before camera teleportation
  106019. */
  106020. onBeforeCameraTeleport: Observable<Vector3>;
  106021. /**
  106022. * Observable raised after camera teleportation
  106023. */
  106024. onAfterCameraTeleport: Observable<Vector3>;
  106025. /**
  106026. * Observable raised when current selected mesh gets unselected
  106027. */
  106028. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106029. private _raySelectionPredicate;
  106030. /**
  106031. * To be optionaly changed by user to define custom ray selection
  106032. */
  106033. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106034. /**
  106035. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106036. */
  106037. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106038. /**
  106039. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106040. */
  106041. teleportationEnabled: boolean;
  106042. private _defaultHeight;
  106043. private _teleportationInitialized;
  106044. private _interactionsEnabled;
  106045. private _interactionsRequested;
  106046. private _displayGaze;
  106047. private _displayLaserPointer;
  106048. /**
  106049. * The mesh used to display where the user is going to teleport.
  106050. */
  106051. /**
  106052. * Sets the mesh to be used to display where the user is going to teleport.
  106053. */
  106054. teleportationTarget: Mesh;
  106055. /**
  106056. * 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
  106057. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106058. * See http://doc.babylonjs.com/resources/baking_transformations
  106059. */
  106060. gazeTrackerMesh: Mesh;
  106061. /**
  106062. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106063. */
  106064. updateGazeTrackerScale: boolean;
  106065. /**
  106066. * If the gaze trackers color should be updated when selecting meshes
  106067. */
  106068. updateGazeTrackerColor: boolean;
  106069. /**
  106070. * The gaze tracking mesh corresponding to the left controller
  106071. */
  106072. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106073. /**
  106074. * The gaze tracking mesh corresponding to the right controller
  106075. */
  106076. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106077. /**
  106078. * If the ray of the gaze should be displayed.
  106079. */
  106080. /**
  106081. * Sets if the ray of the gaze should be displayed.
  106082. */
  106083. displayGaze: boolean;
  106084. /**
  106085. * If the ray of the LaserPointer should be displayed.
  106086. */
  106087. /**
  106088. * Sets if the ray of the LaserPointer should be displayed.
  106089. */
  106090. displayLaserPointer: boolean;
  106091. /**
  106092. * The deviceOrientationCamera used as the camera when not in VR.
  106093. */
  106094. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106095. /**
  106096. * Based on the current WebVR support, returns the current VR camera used.
  106097. */
  106098. readonly currentVRCamera: Nullable<Camera>;
  106099. /**
  106100. * The webVRCamera which is used when in VR.
  106101. */
  106102. readonly webVRCamera: WebVRFreeCamera;
  106103. /**
  106104. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106105. */
  106106. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106107. /**
  106108. * The html button that is used to trigger entering into VR.
  106109. */
  106110. readonly vrButton: Nullable<HTMLButtonElement>;
  106111. private readonly _teleportationRequestInitiated;
  106112. /**
  106113. * Defines wether or not Pointer lock should be requested when switching to
  106114. * full screen.
  106115. */
  106116. requestPointerLockOnFullScreen: boolean;
  106117. /**
  106118. * Instantiates a VRExperienceHelper.
  106119. * Helps to quickly add VR support to an existing scene.
  106120. * @param scene The scene the VRExperienceHelper belongs to.
  106121. * @param webVROptions Options to modify the vr experience helper's behavior.
  106122. */
  106123. constructor(scene: Scene,
  106124. /** Options to modify the vr experience helper's behavior. */
  106125. webVROptions?: VRExperienceHelperOptions);
  106126. private _onDefaultMeshLoaded;
  106127. private _onResize;
  106128. private _onFullscreenChange;
  106129. /**
  106130. * Gets a value indicating if we are currently in VR mode.
  106131. */
  106132. readonly isInVRMode: boolean;
  106133. private onVrDisplayPresentChange;
  106134. private onVRDisplayChanged;
  106135. private moveButtonToBottomRight;
  106136. private displayVRButton;
  106137. private updateButtonVisibility;
  106138. private _cachedAngularSensibility;
  106139. /**
  106140. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106141. * Otherwise, will use the fullscreen API.
  106142. */
  106143. enterVR(): void;
  106144. /**
  106145. * Attempt to exit VR, or fullscreen.
  106146. */
  106147. exitVR(): void;
  106148. /**
  106149. * The position of the vr experience helper.
  106150. */
  106151. /**
  106152. * Sets the position of the vr experience helper.
  106153. */
  106154. position: Vector3;
  106155. /**
  106156. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106157. */
  106158. enableInteractions(): void;
  106159. private readonly _noControllerIsActive;
  106160. private beforeRender;
  106161. private _isTeleportationFloor;
  106162. /**
  106163. * Adds a floor mesh to be used for teleportation.
  106164. * @param floorMesh the mesh to be used for teleportation.
  106165. */
  106166. addFloorMesh(floorMesh: Mesh): void;
  106167. /**
  106168. * Removes a floor mesh from being used for teleportation.
  106169. * @param floorMesh the mesh to be removed.
  106170. */
  106171. removeFloorMesh(floorMesh: Mesh): void;
  106172. /**
  106173. * Enables interactions and teleportation using the VR controllers and gaze.
  106174. * @param vrTeleportationOptions options to modify teleportation behavior.
  106175. */
  106176. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106177. private _onNewGamepadConnected;
  106178. private _tryEnableInteractionOnController;
  106179. private _onNewGamepadDisconnected;
  106180. private _enableInteractionOnController;
  106181. private _checkTeleportWithRay;
  106182. private _checkRotate;
  106183. private _checkTeleportBackwards;
  106184. private _enableTeleportationOnController;
  106185. private _createTeleportationCircles;
  106186. private _displayTeleportationTarget;
  106187. private _hideTeleportationTarget;
  106188. private _rotateCamera;
  106189. private _moveTeleportationSelectorTo;
  106190. private _workingVector;
  106191. private _workingQuaternion;
  106192. private _workingMatrix;
  106193. /**
  106194. * Teleports the users feet to the desired location
  106195. * @param location The location where the user's feet should be placed
  106196. */
  106197. teleportCamera(location: Vector3): void;
  106198. private _convertNormalToDirectionOfRay;
  106199. private _castRayAndSelectObject;
  106200. private _notifySelectedMeshUnselected;
  106201. /**
  106202. * Sets the color of the laser ray from the vr controllers.
  106203. * @param color new color for the ray.
  106204. */
  106205. changeLaserColor(color: Color3): void;
  106206. /**
  106207. * Sets the color of the ray from the vr headsets gaze.
  106208. * @param color new color for the ray.
  106209. */
  106210. changeGazeColor(color: Color3): void;
  106211. /**
  106212. * Exits VR and disposes of the vr experience helper
  106213. */
  106214. dispose(): void;
  106215. /**
  106216. * Gets the name of the VRExperienceHelper class
  106217. * @returns "VRExperienceHelper"
  106218. */
  106219. getClassName(): string;
  106220. }
  106221. }
  106222. declare module BABYLON {
  106223. /**
  106224. * Manages an XRSession to work with Babylon's engine
  106225. * @see https://doc.babylonjs.com/how_to/webxr
  106226. */
  106227. export class WebXRSessionManager implements IDisposable {
  106228. private scene;
  106229. /**
  106230. * Fires every time a new xrFrame arrives which can be used to update the camera
  106231. */
  106232. onXRFrameObservable: Observable<any>;
  106233. /**
  106234. * Fires when the xr session is ended either by the device or manually done
  106235. */
  106236. onXRSessionEnded: Observable<any>;
  106237. /**
  106238. * Underlying xr session
  106239. */
  106240. session: XRSession;
  106241. /**
  106242. * Type of reference space used when creating the session
  106243. */
  106244. referenceSpace: XRReferenceSpace;
  106245. /** @hidden */
  106246. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106247. /**
  106248. * Current XR frame
  106249. */
  106250. currentFrame: Nullable<XRFrame>;
  106251. private _xrNavigator;
  106252. private baseLayer;
  106253. /**
  106254. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106255. * @param scene The scene which the session should be created for
  106256. */
  106257. constructor(scene: Scene);
  106258. /**
  106259. * Initializes the manager
  106260. * After initialization enterXR can be called to start an XR session
  106261. * @returns Promise which resolves after it is initialized
  106262. */
  106263. initializeAsync(): Promise<void>;
  106264. /**
  106265. * Initializes an xr session
  106266. * @param xrSessionMode mode to initialize
  106267. * @returns a promise which will resolve once the session has been initialized
  106268. */
  106269. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106270. /**
  106271. * Sets the reference space on the xr session
  106272. * @param referenceSpace space to set
  106273. * @returns a promise that will resolve once the reference space has been set
  106274. */
  106275. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106276. /**
  106277. * Updates the render state of the session
  106278. * @param state state to set
  106279. * @returns a promise that resolves once the render state has been updated
  106280. */
  106281. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106282. /**
  106283. * Starts rendering to the xr layer
  106284. * @returns a promise that will resolve once rendering has started
  106285. */
  106286. startRenderingToXRAsync(): Promise<void>;
  106287. /**
  106288. * Stops the xrSession and restores the renderloop
  106289. * @returns Promise which resolves after it exits XR
  106290. */
  106291. exitXRAsync(): Promise<unknown>;
  106292. /**
  106293. * Checks if a session would be supported for the creation options specified
  106294. * @param sessionMode session mode to check if supported eg. immersive-vr
  106295. * @returns true if supported
  106296. */
  106297. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106298. /**
  106299. * @hidden
  106300. * Converts the render layer of xrSession to a render target
  106301. * @param session session to create render target for
  106302. * @param scene scene the new render target should be created for
  106303. */
  106304. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106305. /**
  106306. * Disposes of the session manager
  106307. */
  106308. dispose(): void;
  106309. }
  106310. }
  106311. declare module BABYLON {
  106312. /**
  106313. * WebXR Camera which holds the views for the xrSession
  106314. * @see https://doc.babylonjs.com/how_to/webxr
  106315. */
  106316. export class WebXRCamera extends FreeCamera {
  106317. private static _TmpMatrix;
  106318. /**
  106319. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106320. * @param name the name of the camera
  106321. * @param scene the scene to add the camera to
  106322. */
  106323. constructor(name: string, scene: Scene);
  106324. private _updateNumberOfRigCameras;
  106325. /** @hidden */
  106326. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106327. /**
  106328. * Updates the cameras position from the current pose information of the XR session
  106329. * @param xrSessionManager the session containing pose information
  106330. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106331. */
  106332. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106333. }
  106334. }
  106335. declare module BABYLON {
  106336. /**
  106337. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106338. */
  106339. export class WebXRManagedOutputCanvas implements IDisposable {
  106340. private helper;
  106341. private _canvas;
  106342. /**
  106343. * xrpresent context of the canvas which can be used to display/mirror xr content
  106344. */
  106345. canvasContext: WebGLRenderingContext;
  106346. /**
  106347. * xr layer for the canvas
  106348. */
  106349. xrLayer: Nullable<XRWebGLLayer>;
  106350. /**
  106351. * Initializes the xr layer for the session
  106352. * @param xrSession xr session
  106353. * @returns a promise that will resolve once the XR Layer has been created
  106354. */
  106355. initializeXRLayerAsync(xrSession: any): any;
  106356. /**
  106357. * Initializes the canvas to be added/removed upon entering/exiting xr
  106358. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106359. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106360. */
  106361. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106362. /**
  106363. * Disposes of the object
  106364. */
  106365. dispose(): void;
  106366. private _setManagedOutputCanvas;
  106367. private _addCanvas;
  106368. private _removeCanvas;
  106369. }
  106370. }
  106371. declare module BABYLON {
  106372. /**
  106373. * States of the webXR experience
  106374. */
  106375. export enum WebXRState {
  106376. /**
  106377. * Transitioning to being in XR mode
  106378. */
  106379. ENTERING_XR = 0,
  106380. /**
  106381. * Transitioning to non XR mode
  106382. */
  106383. EXITING_XR = 1,
  106384. /**
  106385. * In XR mode and presenting
  106386. */
  106387. IN_XR = 2,
  106388. /**
  106389. * Not entered XR mode
  106390. */
  106391. NOT_IN_XR = 3
  106392. }
  106393. /**
  106394. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106395. * @see https://doc.babylonjs.com/how_to/webxr
  106396. */
  106397. export class WebXRExperienceHelper implements IDisposable {
  106398. private scene;
  106399. /**
  106400. * 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
  106401. */
  106402. container: AbstractMesh;
  106403. /**
  106404. * Camera used to render xr content
  106405. */
  106406. camera: WebXRCamera;
  106407. /**
  106408. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106409. */
  106410. state: WebXRState;
  106411. private _setState;
  106412. private static _TmpVector;
  106413. /**
  106414. * Fires when the state of the experience helper has changed
  106415. */
  106416. onStateChangedObservable: Observable<WebXRState>;
  106417. /** Session manager used to keep track of xr session */
  106418. sessionManager: WebXRSessionManager;
  106419. private _nonVRCamera;
  106420. private _originalSceneAutoClear;
  106421. private _supported;
  106422. /**
  106423. * Creates the experience helper
  106424. * @param scene the scene to attach the experience helper to
  106425. * @returns a promise for the experience helper
  106426. */
  106427. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106428. /**
  106429. * Creates a WebXRExperienceHelper
  106430. * @param scene The scene the helper should be created in
  106431. */
  106432. private constructor();
  106433. /**
  106434. * Exits XR mode and returns the scene to its original state
  106435. * @returns promise that resolves after xr mode has exited
  106436. */
  106437. exitXRAsync(): Promise<unknown>;
  106438. /**
  106439. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  106440. * @param sessionCreationOptions options for the XR session
  106441. * @param referenceSpaceType frame of reference of the XR session
  106442. * @param outputCanvas the output canvas that will be used to enter XR mode
  106443. * @returns promise that resolves after xr mode has entered
  106444. */
  106445. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  106446. /**
  106447. * Updates the global position of the camera by moving the camera's container
  106448. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106449. * @param position The desired global position of the camera
  106450. */
  106451. setPositionOfCameraUsingContainer(position: Vector3): void;
  106452. /**
  106453. * Rotates the xr camera by rotating the camera's container around the camera's position
  106454. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106455. * @param rotation the desired quaternion rotation to apply to the camera
  106456. */
  106457. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106458. /**
  106459. * Disposes of the experience helper
  106460. */
  106461. dispose(): void;
  106462. }
  106463. }
  106464. declare module BABYLON {
  106465. /**
  106466. * Button which can be used to enter a different mode of XR
  106467. */
  106468. export class WebXREnterExitUIButton {
  106469. /** button element */
  106470. element: HTMLElement;
  106471. /** XR initialization options for the button */
  106472. sessionMode: XRSessionMode;
  106473. /** Reference space type */
  106474. referenceSpaceType: XRReferenceSpaceType;
  106475. /**
  106476. * Creates a WebXREnterExitUIButton
  106477. * @param element button element
  106478. * @param sessionMode XR initialization session mode
  106479. * @param referenceSpaceType the type of reference space to be used
  106480. */
  106481. constructor(
  106482. /** button element */
  106483. element: HTMLElement,
  106484. /** XR initialization options for the button */
  106485. sessionMode: XRSessionMode,
  106486. /** Reference space type */
  106487. referenceSpaceType: XRReferenceSpaceType);
  106488. /**
  106489. * Overwritable function which can be used to update the button's visuals when the state changes
  106490. * @param activeButton the current active button in the UI
  106491. */
  106492. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106493. }
  106494. /**
  106495. * Options to create the webXR UI
  106496. */
  106497. export class WebXREnterExitUIOptions {
  106498. /**
  106499. * Context to enter xr with
  106500. */
  106501. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106502. /**
  106503. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106504. */
  106505. customButtons?: Array<WebXREnterExitUIButton>;
  106506. }
  106507. /**
  106508. * UI to allow the user to enter/exit XR mode
  106509. */
  106510. export class WebXREnterExitUI implements IDisposable {
  106511. private scene;
  106512. private _overlay;
  106513. private _buttons;
  106514. private _activeButton;
  106515. /**
  106516. * Fired every time the active button is changed.
  106517. *
  106518. * When xr is entered via a button that launches xr that button will be the callback parameter
  106519. *
  106520. * When exiting xr the callback parameter will be null)
  106521. */
  106522. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106523. /**
  106524. * Creates UI to allow the user to enter/exit XR mode
  106525. * @param scene the scene to add the ui to
  106526. * @param helper the xr experience helper to enter/exit xr with
  106527. * @param options options to configure the UI
  106528. * @returns the created ui
  106529. */
  106530. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106531. private constructor();
  106532. private _updateButtons;
  106533. /**
  106534. * Disposes of the object
  106535. */
  106536. dispose(): void;
  106537. }
  106538. }
  106539. declare module BABYLON {
  106540. /**
  106541. * Represents an XR input
  106542. */
  106543. export class WebXRController {
  106544. private scene;
  106545. /** The underlying input source for the controller */
  106546. inputSource: XRInputSource;
  106547. private parentContainer;
  106548. /**
  106549. * 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
  106550. */
  106551. grip?: AbstractMesh;
  106552. /**
  106553. * Pointer which can be used to select objects or attach a visible laser to
  106554. */
  106555. pointer: AbstractMesh;
  106556. /**
  106557. * Event that fires when the controller is removed/disposed
  106558. */
  106559. onDisposeObservable: Observable<{}>;
  106560. private _tmpMatrix;
  106561. private _tmpQuaternion;
  106562. private _tmpVector;
  106563. /**
  106564. * Creates the controller
  106565. * @see https://doc.babylonjs.com/how_to/webxr
  106566. * @param scene the scene which the controller should be associated to
  106567. * @param inputSource the underlying input source for the controller
  106568. * @param parentContainer parent that the controller meshes should be children of
  106569. */
  106570. constructor(scene: Scene,
  106571. /** The underlying input source for the controller */
  106572. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  106573. /**
  106574. * Updates the controller pose based on the given XRFrame
  106575. * @param xrFrame xr frame to update the pose with
  106576. * @param referenceSpace reference space to use
  106577. */
  106578. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  106579. /**
  106580. * Gets a world space ray coming from the controller
  106581. * @param result the resulting ray
  106582. */
  106583. getWorldPointerRayToRef(result: Ray): void;
  106584. /**
  106585. * Disposes of the object
  106586. */
  106587. dispose(): void;
  106588. }
  106589. }
  106590. declare module BABYLON {
  106591. /**
  106592. * XR input used to track XR inputs such as controllers/rays
  106593. */
  106594. export class WebXRInput implements IDisposable {
  106595. /**
  106596. * Base experience the input listens to
  106597. */
  106598. baseExperience: WebXRExperienceHelper;
  106599. /**
  106600. * XR controllers being tracked
  106601. */
  106602. controllers: Array<WebXRController>;
  106603. private _frameObserver;
  106604. private _stateObserver;
  106605. /**
  106606. * Event when a controller has been connected/added
  106607. */
  106608. onControllerAddedObservable: Observable<WebXRController>;
  106609. /**
  106610. * Event when a controller has been removed/disconnected
  106611. */
  106612. onControllerRemovedObservable: Observable<WebXRController>;
  106613. /**
  106614. * Initializes the WebXRInput
  106615. * @param baseExperience experience helper which the input should be created for
  106616. */
  106617. constructor(
  106618. /**
  106619. * Base experience the input listens to
  106620. */
  106621. baseExperience: WebXRExperienceHelper);
  106622. private _onInputSourcesChange;
  106623. private _addAndRemoveControllers;
  106624. /**
  106625. * Disposes of the object
  106626. */
  106627. dispose(): void;
  106628. }
  106629. }
  106630. declare module BABYLON {
  106631. /**
  106632. * Enables teleportation
  106633. */
  106634. export class WebXRControllerTeleportation {
  106635. private _teleportationFillColor;
  106636. private _teleportationBorderColor;
  106637. private _tmpRay;
  106638. private _tmpVector;
  106639. /**
  106640. * Creates a WebXRControllerTeleportation
  106641. * @param input input manager to add teleportation to
  106642. * @param floorMeshes floormeshes which can be teleported to
  106643. */
  106644. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106645. }
  106646. }
  106647. declare module BABYLON {
  106648. /**
  106649. * Handles pointer input automatically for the pointer of XR controllers
  106650. */
  106651. export class WebXRControllerPointerSelection {
  106652. private static _idCounter;
  106653. private _tmpRay;
  106654. /**
  106655. * Creates a WebXRControllerPointerSelection
  106656. * @param input input manager to setup pointer selection
  106657. */
  106658. constructor(input: WebXRInput);
  106659. private _convertNormalToDirectionOfRay;
  106660. private _updatePointerDistance;
  106661. }
  106662. }
  106663. declare module BABYLON {
  106664. /**
  106665. * Class used to represent data loading progression
  106666. */
  106667. export class SceneLoaderProgressEvent {
  106668. /** defines if data length to load can be evaluated */
  106669. readonly lengthComputable: boolean;
  106670. /** defines the loaded data length */
  106671. readonly loaded: number;
  106672. /** defines the data length to load */
  106673. readonly total: number;
  106674. /**
  106675. * Create a new progress event
  106676. * @param lengthComputable defines if data length to load can be evaluated
  106677. * @param loaded defines the loaded data length
  106678. * @param total defines the data length to load
  106679. */
  106680. constructor(
  106681. /** defines if data length to load can be evaluated */
  106682. lengthComputable: boolean,
  106683. /** defines the loaded data length */
  106684. loaded: number,
  106685. /** defines the data length to load */
  106686. total: number);
  106687. /**
  106688. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106689. * @param event defines the source event
  106690. * @returns a new SceneLoaderProgressEvent
  106691. */
  106692. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106693. }
  106694. /**
  106695. * Interface used by SceneLoader plugins to define supported file extensions
  106696. */
  106697. export interface ISceneLoaderPluginExtensions {
  106698. /**
  106699. * Defines the list of supported extensions
  106700. */
  106701. [extension: string]: {
  106702. isBinary: boolean;
  106703. };
  106704. }
  106705. /**
  106706. * Interface used by SceneLoader plugin factory
  106707. */
  106708. export interface ISceneLoaderPluginFactory {
  106709. /**
  106710. * Defines the name of the factory
  106711. */
  106712. name: string;
  106713. /**
  106714. * Function called to create a new plugin
  106715. * @return the new plugin
  106716. */
  106717. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106718. /**
  106719. * Boolean indicating if the plugin can direct load specific data
  106720. */
  106721. canDirectLoad?: (data: string) => boolean;
  106722. }
  106723. /**
  106724. * Interface used to define a SceneLoader plugin
  106725. */
  106726. export interface ISceneLoaderPlugin {
  106727. /**
  106728. * The friendly name of this plugin.
  106729. */
  106730. name: string;
  106731. /**
  106732. * The file extensions supported by this plugin.
  106733. */
  106734. extensions: string | ISceneLoaderPluginExtensions;
  106735. /**
  106736. * Import meshes into a scene.
  106737. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106738. * @param scene The scene to import into
  106739. * @param data The data to import
  106740. * @param rootUrl The root url for scene and resources
  106741. * @param meshes The meshes array to import into
  106742. * @param particleSystems The particle systems array to import into
  106743. * @param skeletons The skeletons array to import into
  106744. * @param onError The callback when import fails
  106745. * @returns True if successful or false otherwise
  106746. */
  106747. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106748. /**
  106749. * Load into a scene.
  106750. * @param scene The scene to load into
  106751. * @param data The data to import
  106752. * @param rootUrl The root url for scene and resources
  106753. * @param onError The callback when import fails
  106754. * @returns true if successful or false otherwise
  106755. */
  106756. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106757. /**
  106758. * The callback that returns true if the data can be directly loaded.
  106759. */
  106760. canDirectLoad?: (data: string) => boolean;
  106761. /**
  106762. * The callback that allows custom handling of the root url based on the response url.
  106763. */
  106764. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106765. /**
  106766. * Load into an asset container.
  106767. * @param scene The scene to load into
  106768. * @param data The data to import
  106769. * @param rootUrl The root url for scene and resources
  106770. * @param onError The callback when import fails
  106771. * @returns The loaded asset container
  106772. */
  106773. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106774. }
  106775. /**
  106776. * Interface used to define an async SceneLoader plugin
  106777. */
  106778. export interface ISceneLoaderPluginAsync {
  106779. /**
  106780. * The friendly name of this plugin.
  106781. */
  106782. name: string;
  106783. /**
  106784. * The file extensions supported by this plugin.
  106785. */
  106786. extensions: string | ISceneLoaderPluginExtensions;
  106787. /**
  106788. * Import meshes into a scene.
  106789. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106790. * @param scene The scene to import into
  106791. * @param data The data to import
  106792. * @param rootUrl The root url for scene and resources
  106793. * @param onProgress The callback when the load progresses
  106794. * @param fileName Defines the name of the file to load
  106795. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106796. */
  106797. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106798. meshes: AbstractMesh[];
  106799. particleSystems: IParticleSystem[];
  106800. skeletons: Skeleton[];
  106801. animationGroups: AnimationGroup[];
  106802. }>;
  106803. /**
  106804. * Load into a scene.
  106805. * @param scene The scene to load into
  106806. * @param data The data to import
  106807. * @param rootUrl The root url for scene and resources
  106808. * @param onProgress The callback when the load progresses
  106809. * @param fileName Defines the name of the file to load
  106810. * @returns Nothing
  106811. */
  106812. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106813. /**
  106814. * The callback that returns true if the data can be directly loaded.
  106815. */
  106816. canDirectLoad?: (data: string) => boolean;
  106817. /**
  106818. * The callback that allows custom handling of the root url based on the response url.
  106819. */
  106820. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106821. /**
  106822. * Load into an asset container.
  106823. * @param scene The scene to load into
  106824. * @param data The data to import
  106825. * @param rootUrl The root url for scene and resources
  106826. * @param onProgress The callback when the load progresses
  106827. * @param fileName Defines the name of the file to load
  106828. * @returns The loaded asset container
  106829. */
  106830. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106831. }
  106832. /**
  106833. * Class used to load scene from various file formats using registered plugins
  106834. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106835. */
  106836. export class SceneLoader {
  106837. /**
  106838. * No logging while loading
  106839. */
  106840. static readonly NO_LOGGING: number;
  106841. /**
  106842. * Minimal logging while loading
  106843. */
  106844. static readonly MINIMAL_LOGGING: number;
  106845. /**
  106846. * Summary logging while loading
  106847. */
  106848. static readonly SUMMARY_LOGGING: number;
  106849. /**
  106850. * Detailled logging while loading
  106851. */
  106852. static readonly DETAILED_LOGGING: number;
  106853. /**
  106854. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106855. */
  106856. static ForceFullSceneLoadingForIncremental: boolean;
  106857. /**
  106858. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106859. */
  106860. static ShowLoadingScreen: boolean;
  106861. /**
  106862. * Defines the current logging level (while loading the scene)
  106863. * @ignorenaming
  106864. */
  106865. static loggingLevel: number;
  106866. /**
  106867. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106868. */
  106869. static CleanBoneMatrixWeights: boolean;
  106870. /**
  106871. * Event raised when a plugin is used to load a scene
  106872. */
  106873. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106874. private static _registeredPlugins;
  106875. private static _getDefaultPlugin;
  106876. private static _getPluginForExtension;
  106877. private static _getPluginForDirectLoad;
  106878. private static _getPluginForFilename;
  106879. private static _getDirectLoad;
  106880. private static _loadData;
  106881. private static _getFileInfo;
  106882. /**
  106883. * Gets a plugin that can load the given extension
  106884. * @param extension defines the extension to load
  106885. * @returns a plugin or null if none works
  106886. */
  106887. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106888. /**
  106889. * Gets a boolean indicating that the given extension can be loaded
  106890. * @param extension defines the extension to load
  106891. * @returns true if the extension is supported
  106892. */
  106893. static IsPluginForExtensionAvailable(extension: string): boolean;
  106894. /**
  106895. * Adds a new plugin to the list of registered plugins
  106896. * @param plugin defines the plugin to add
  106897. */
  106898. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106899. /**
  106900. * Import meshes into a scene
  106901. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106902. * @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)
  106903. * @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)
  106904. * @param scene the instance of BABYLON.Scene to append to
  106905. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106906. * @param onProgress a callback with a progress event for each file being loaded
  106907. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106908. * @param pluginExtension the extension used to determine the plugin
  106909. * @returns The loaded plugin
  106910. */
  106911. 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>;
  106912. /**
  106913. * Import meshes into a scene
  106914. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106915. * @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)
  106916. * @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)
  106917. * @param scene the instance of BABYLON.Scene to append to
  106918. * @param onProgress a callback with a progress event for each file being loaded
  106919. * @param pluginExtension the extension used to determine the plugin
  106920. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106921. */
  106922. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106923. meshes: AbstractMesh[];
  106924. particleSystems: IParticleSystem[];
  106925. skeletons: Skeleton[];
  106926. animationGroups: AnimationGroup[];
  106927. }>;
  106928. /**
  106929. * Load a scene
  106930. * @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)
  106931. * @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)
  106932. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106933. * @param onSuccess a callback with the scene when import succeeds
  106934. * @param onProgress a callback with a progress event for each file being loaded
  106935. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106936. * @param pluginExtension the extension used to determine the plugin
  106937. * @returns The loaded plugin
  106938. */
  106939. 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>;
  106940. /**
  106941. * Load a scene
  106942. * @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)
  106943. * @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)
  106944. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106945. * @param onProgress a callback with a progress event for each file being loaded
  106946. * @param pluginExtension the extension used to determine the plugin
  106947. * @returns The loaded scene
  106948. */
  106949. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106950. /**
  106951. * Append a scene
  106952. * @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)
  106953. * @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)
  106954. * @param scene is the instance of BABYLON.Scene to append to
  106955. * @param onSuccess a callback with the scene when import succeeds
  106956. * @param onProgress a callback with a progress event for each file being loaded
  106957. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106958. * @param pluginExtension the extension used to determine the plugin
  106959. * @returns The loaded plugin
  106960. */
  106961. 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>;
  106962. /**
  106963. * Append a scene
  106964. * @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)
  106965. * @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)
  106966. * @param scene is the instance of BABYLON.Scene to append to
  106967. * @param onProgress a callback with a progress event for each file being loaded
  106968. * @param pluginExtension the extension used to determine the plugin
  106969. * @returns The given scene
  106970. */
  106971. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106972. /**
  106973. * Load a scene into an asset container
  106974. * @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)
  106975. * @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)
  106976. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106977. * @param onSuccess a callback with the scene when import succeeds
  106978. * @param onProgress a callback with a progress event for each file being loaded
  106979. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106980. * @param pluginExtension the extension used to determine the plugin
  106981. * @returns The loaded plugin
  106982. */
  106983. 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>;
  106984. /**
  106985. * Load a scene into an asset container
  106986. * @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)
  106987. * @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)
  106988. * @param scene is the instance of Scene to append to
  106989. * @param onProgress a callback with a progress event for each file being loaded
  106990. * @param pluginExtension the extension used to determine the plugin
  106991. * @returns The loaded asset container
  106992. */
  106993. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106994. }
  106995. }
  106996. declare module BABYLON {
  106997. /**
  106998. * Generic Controller
  106999. */
  107000. export class GenericController extends WebVRController {
  107001. /**
  107002. * Base Url for the controller model.
  107003. */
  107004. static readonly MODEL_BASE_URL: string;
  107005. /**
  107006. * File name for the controller model.
  107007. */
  107008. static readonly MODEL_FILENAME: string;
  107009. /**
  107010. * Creates a new GenericController from a gamepad
  107011. * @param vrGamepad the gamepad that the controller should be created from
  107012. */
  107013. constructor(vrGamepad: any);
  107014. /**
  107015. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107016. * @param scene scene in which to add meshes
  107017. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107018. */
  107019. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107020. /**
  107021. * Called once for each button that changed state since the last frame
  107022. * @param buttonIdx Which button index changed
  107023. * @param state New state of the button
  107024. * @param changes Which properties on the state changed since last frame
  107025. */
  107026. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107027. }
  107028. }
  107029. declare module BABYLON {
  107030. /**
  107031. * Defines the WindowsMotionController object that the state of the windows motion controller
  107032. */
  107033. export class WindowsMotionController extends WebVRController {
  107034. /**
  107035. * The base url used to load the left and right controller models
  107036. */
  107037. static MODEL_BASE_URL: string;
  107038. /**
  107039. * The name of the left controller model file
  107040. */
  107041. static MODEL_LEFT_FILENAME: string;
  107042. /**
  107043. * The name of the right controller model file
  107044. */
  107045. static MODEL_RIGHT_FILENAME: string;
  107046. /**
  107047. * The controller name prefix for this controller type
  107048. */
  107049. static readonly GAMEPAD_ID_PREFIX: string;
  107050. /**
  107051. * The controller id pattern for this controller type
  107052. */
  107053. private static readonly GAMEPAD_ID_PATTERN;
  107054. private _loadedMeshInfo;
  107055. private readonly _mapping;
  107056. /**
  107057. * Fired when the trackpad on this controller is clicked
  107058. */
  107059. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107060. /**
  107061. * Fired when the trackpad on this controller is modified
  107062. */
  107063. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107064. /**
  107065. * The current x and y values of this controller's trackpad
  107066. */
  107067. trackpad: StickValues;
  107068. /**
  107069. * Creates a new WindowsMotionController from a gamepad
  107070. * @param vrGamepad the gamepad that the controller should be created from
  107071. */
  107072. constructor(vrGamepad: any);
  107073. /**
  107074. * Fired when the trigger on this controller is modified
  107075. */
  107076. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107077. /**
  107078. * Fired when the menu button on this controller is modified
  107079. */
  107080. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107081. /**
  107082. * Fired when the grip button on this controller is modified
  107083. */
  107084. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107085. /**
  107086. * Fired when the thumbstick button on this controller is modified
  107087. */
  107088. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107089. /**
  107090. * Fired when the touchpad button on this controller is modified
  107091. */
  107092. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107093. /**
  107094. * Fired when the touchpad values on this controller are modified
  107095. */
  107096. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107097. private _updateTrackpad;
  107098. /**
  107099. * Called once per frame by the engine.
  107100. */
  107101. update(): void;
  107102. /**
  107103. * Called once for each button that changed state since the last frame
  107104. * @param buttonIdx Which button index changed
  107105. * @param state New state of the button
  107106. * @param changes Which properties on the state changed since last frame
  107107. */
  107108. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107109. /**
  107110. * Moves the buttons on the controller mesh based on their current state
  107111. * @param buttonName the name of the button to move
  107112. * @param buttonValue the value of the button which determines the buttons new position
  107113. */
  107114. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107115. /**
  107116. * Moves the axis on the controller mesh based on its current state
  107117. * @param axis the index of the axis
  107118. * @param axisValue the value of the axis which determines the meshes new position
  107119. * @hidden
  107120. */
  107121. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107122. /**
  107123. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107124. * @param scene scene in which to add meshes
  107125. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107126. */
  107127. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107128. /**
  107129. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107130. * can be transformed by button presses and axes values, based on this._mapping.
  107131. *
  107132. * @param scene scene in which the meshes exist
  107133. * @param meshes list of meshes that make up the controller model to process
  107134. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107135. */
  107136. private processModel;
  107137. private createMeshInfo;
  107138. /**
  107139. * Gets the ray of the controller in the direction the controller is pointing
  107140. * @param length the length the resulting ray should be
  107141. * @returns a ray in the direction the controller is pointing
  107142. */
  107143. getForwardRay(length?: number): Ray;
  107144. /**
  107145. * Disposes of the controller
  107146. */
  107147. dispose(): void;
  107148. }
  107149. }
  107150. declare module BABYLON {
  107151. /**
  107152. * Oculus Touch Controller
  107153. */
  107154. export class OculusTouchController extends WebVRController {
  107155. /**
  107156. * Base Url for the controller model.
  107157. */
  107158. static MODEL_BASE_URL: string;
  107159. /**
  107160. * File name for the left controller model.
  107161. */
  107162. static MODEL_LEFT_FILENAME: string;
  107163. /**
  107164. * File name for the right controller model.
  107165. */
  107166. static MODEL_RIGHT_FILENAME: string;
  107167. /**
  107168. * Base Url for the Quest controller model.
  107169. */
  107170. static QUEST_MODEL_BASE_URL: string;
  107171. /**
  107172. * @hidden
  107173. * If the controllers are running on a device that needs the updated Quest controller models
  107174. */
  107175. static _IsQuest: boolean;
  107176. /**
  107177. * Fired when the secondary trigger on this controller is modified
  107178. */
  107179. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107180. /**
  107181. * Fired when the thumb rest on this controller is modified
  107182. */
  107183. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107184. /**
  107185. * Creates a new OculusTouchController from a gamepad
  107186. * @param vrGamepad the gamepad that the controller should be created from
  107187. */
  107188. constructor(vrGamepad: any);
  107189. /**
  107190. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107191. * @param scene scene in which to add meshes
  107192. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107193. */
  107194. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107195. /**
  107196. * Fired when the A button on this controller is modified
  107197. */
  107198. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107199. /**
  107200. * Fired when the B button on this controller is modified
  107201. */
  107202. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107203. /**
  107204. * Fired when the X button on this controller is modified
  107205. */
  107206. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107207. /**
  107208. * Fired when the Y button on this controller is modified
  107209. */
  107210. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107211. /**
  107212. * Called once for each button that changed state since the last frame
  107213. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107214. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107215. * 2) secondary trigger (same)
  107216. * 3) A (right) X (left), touch, pressed = value
  107217. * 4) B / Y
  107218. * 5) thumb rest
  107219. * @param buttonIdx Which button index changed
  107220. * @param state New state of the button
  107221. * @param changes Which properties on the state changed since last frame
  107222. */
  107223. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107224. }
  107225. }
  107226. declare module BABYLON {
  107227. /**
  107228. * Vive Controller
  107229. */
  107230. export class ViveController extends WebVRController {
  107231. /**
  107232. * Base Url for the controller model.
  107233. */
  107234. static MODEL_BASE_URL: string;
  107235. /**
  107236. * File name for the controller model.
  107237. */
  107238. static MODEL_FILENAME: string;
  107239. /**
  107240. * Creates a new ViveController from a gamepad
  107241. * @param vrGamepad the gamepad that the controller should be created from
  107242. */
  107243. constructor(vrGamepad: any);
  107244. /**
  107245. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107246. * @param scene scene in which to add meshes
  107247. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107248. */
  107249. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107250. /**
  107251. * Fired when the left button on this controller is modified
  107252. */
  107253. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107254. /**
  107255. * Fired when the right button on this controller is modified
  107256. */
  107257. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107258. /**
  107259. * Fired when the menu button on this controller is modified
  107260. */
  107261. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107262. /**
  107263. * Called once for each button that changed state since the last frame
  107264. * Vive mapping:
  107265. * 0: touchpad
  107266. * 1: trigger
  107267. * 2: left AND right buttons
  107268. * 3: menu button
  107269. * @param buttonIdx Which button index changed
  107270. * @param state New state of the button
  107271. * @param changes Which properties on the state changed since last frame
  107272. */
  107273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107274. }
  107275. }
  107276. declare module BABYLON {
  107277. /**
  107278. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107279. */
  107280. export class WebXRControllerModelLoader {
  107281. /**
  107282. * Creates the WebXRControllerModelLoader
  107283. * @param input xr input that creates the controllers
  107284. */
  107285. constructor(input: WebXRInput);
  107286. }
  107287. }
  107288. declare module BABYLON {
  107289. /**
  107290. * Contains an array of blocks representing the octree
  107291. */
  107292. export interface IOctreeContainer<T> {
  107293. /**
  107294. * Blocks within the octree
  107295. */
  107296. blocks: Array<OctreeBlock<T>>;
  107297. }
  107298. /**
  107299. * Class used to store a cell in an octree
  107300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107301. */
  107302. export class OctreeBlock<T> {
  107303. /**
  107304. * Gets the content of the current block
  107305. */
  107306. entries: T[];
  107307. /**
  107308. * Gets the list of block children
  107309. */
  107310. blocks: Array<OctreeBlock<T>>;
  107311. private _depth;
  107312. private _maxDepth;
  107313. private _capacity;
  107314. private _minPoint;
  107315. private _maxPoint;
  107316. private _boundingVectors;
  107317. private _creationFunc;
  107318. /**
  107319. * Creates a new block
  107320. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107321. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107322. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107323. * @param depth defines the current depth of this block in the octree
  107324. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107325. * @param creationFunc defines a callback to call when an element is added to the block
  107326. */
  107327. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107328. /**
  107329. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107330. */
  107331. readonly capacity: number;
  107332. /**
  107333. * Gets the minimum vector (in world space) of the block's bounding box
  107334. */
  107335. readonly minPoint: Vector3;
  107336. /**
  107337. * Gets the maximum vector (in world space) of the block's bounding box
  107338. */
  107339. readonly maxPoint: Vector3;
  107340. /**
  107341. * Add a new element to this block
  107342. * @param entry defines the element to add
  107343. */
  107344. addEntry(entry: T): void;
  107345. /**
  107346. * Remove an element from this block
  107347. * @param entry defines the element to remove
  107348. */
  107349. removeEntry(entry: T): void;
  107350. /**
  107351. * Add an array of elements to this block
  107352. * @param entries defines the array of elements to add
  107353. */
  107354. addEntries(entries: T[]): void;
  107355. /**
  107356. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107357. * @param frustumPlanes defines the frustum planes to test
  107358. * @param selection defines the array to store current content if selection is positive
  107359. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107360. */
  107361. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107362. /**
  107363. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107364. * @param sphereCenter defines the bounding sphere center
  107365. * @param sphereRadius defines the bounding sphere radius
  107366. * @param selection defines the array to store current content if selection is positive
  107367. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107368. */
  107369. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107370. /**
  107371. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107372. * @param ray defines the ray to test with
  107373. * @param selection defines the array to store current content if selection is positive
  107374. */
  107375. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107376. /**
  107377. * Subdivide the content into child blocks (this block will then be empty)
  107378. */
  107379. createInnerBlocks(): void;
  107380. /**
  107381. * @hidden
  107382. */
  107383. 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;
  107384. }
  107385. }
  107386. declare module BABYLON {
  107387. /**
  107388. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107390. */
  107391. export class Octree<T> {
  107392. /** 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.) */
  107393. maxDepth: number;
  107394. /**
  107395. * Blocks within the octree containing objects
  107396. */
  107397. blocks: Array<OctreeBlock<T>>;
  107398. /**
  107399. * Content stored in the octree
  107400. */
  107401. dynamicContent: T[];
  107402. private _maxBlockCapacity;
  107403. private _selectionContent;
  107404. private _creationFunc;
  107405. /**
  107406. * Creates a octree
  107407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107408. * @param creationFunc function to be used to instatiate the octree
  107409. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107410. * @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.)
  107411. */
  107412. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107413. /** 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.) */
  107414. maxDepth?: number);
  107415. /**
  107416. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107417. * @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);
  107418. * @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);
  107419. * @param entries meshes to be added to the octree blocks
  107420. */
  107421. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107422. /**
  107423. * Adds a mesh to the octree
  107424. * @param entry Mesh to add to the octree
  107425. */
  107426. addMesh(entry: T): void;
  107427. /**
  107428. * Remove an element from the octree
  107429. * @param entry defines the element to remove
  107430. */
  107431. removeMesh(entry: T): void;
  107432. /**
  107433. * Selects an array of meshes within the frustum
  107434. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  107435. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  107436. * @returns array of meshes within the frustum
  107437. */
  107438. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  107439. /**
  107440. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  107441. * @param sphereCenter defines the bounding sphere center
  107442. * @param sphereRadius defines the bounding sphere radius
  107443. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107444. * @returns an array of objects that intersect the sphere
  107445. */
  107446. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  107447. /**
  107448. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107449. * @param ray defines the ray to test with
  107450. * @returns array of intersected objects
  107451. */
  107452. intersectsRay(ray: Ray): SmartArray<T>;
  107453. /**
  107454. * Adds a mesh into the octree block if it intersects the block
  107455. */
  107456. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107457. /**
  107458. * Adds a submesh into the octree block if it intersects the block
  107459. */
  107460. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107461. }
  107462. }
  107463. declare module BABYLON {
  107464. interface Scene {
  107465. /**
  107466. * @hidden
  107467. * Backing Filed
  107468. */
  107469. _selectionOctree: Octree<AbstractMesh>;
  107470. /**
  107471. * Gets the octree used to boost mesh selection (picking)
  107472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107473. */
  107474. selectionOctree: Octree<AbstractMesh>;
  107475. /**
  107476. * Creates or updates the octree used to boost selection (picking)
  107477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107478. * @param maxCapacity defines the maximum capacity per leaf
  107479. * @param maxDepth defines the maximum depth of the octree
  107480. * @returns an octree of AbstractMesh
  107481. */
  107482. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107483. }
  107484. interface AbstractMesh {
  107485. /**
  107486. * @hidden
  107487. * Backing Field
  107488. */
  107489. _submeshesOctree: Octree<SubMesh>;
  107490. /**
  107491. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107492. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107493. * @param maxCapacity defines the maximum size of each block (64 by default)
  107494. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107495. * @returns the new octree
  107496. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107498. */
  107499. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107500. }
  107501. /**
  107502. * Defines the octree scene component responsible to manage any octrees
  107503. * in a given scene.
  107504. */
  107505. export class OctreeSceneComponent {
  107506. /**
  107507. * The component name help to identify the component in the list of scene components.
  107508. */
  107509. readonly name: string;
  107510. /**
  107511. * The scene the component belongs to.
  107512. */
  107513. scene: Scene;
  107514. /**
  107515. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107516. */
  107517. readonly checksIsEnabled: boolean;
  107518. /**
  107519. * Creates a new instance of the component for the given scene
  107520. * @param scene Defines the scene to register the component in
  107521. */
  107522. constructor(scene: Scene);
  107523. /**
  107524. * Registers the component in a given scene
  107525. */
  107526. register(): void;
  107527. /**
  107528. * Return the list of active meshes
  107529. * @returns the list of active meshes
  107530. */
  107531. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107532. /**
  107533. * Return the list of active sub meshes
  107534. * @param mesh The mesh to get the candidates sub meshes from
  107535. * @returns the list of active sub meshes
  107536. */
  107537. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107538. private _tempRay;
  107539. /**
  107540. * Return the list of sub meshes intersecting with a given local ray
  107541. * @param mesh defines the mesh to find the submesh for
  107542. * @param localRay defines the ray in local space
  107543. * @returns the list of intersecting sub meshes
  107544. */
  107545. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107546. /**
  107547. * Return the list of sub meshes colliding with a collider
  107548. * @param mesh defines the mesh to find the submesh for
  107549. * @param collider defines the collider to evaluate the collision against
  107550. * @returns the list of colliding sub meshes
  107551. */
  107552. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107553. /**
  107554. * Rebuilds the elements related to this component in case of
  107555. * context lost for instance.
  107556. */
  107557. rebuild(): void;
  107558. /**
  107559. * Disposes the component and the associated ressources.
  107560. */
  107561. dispose(): void;
  107562. }
  107563. }
  107564. declare module BABYLON {
  107565. /**
  107566. * Renders a layer on top of an existing scene
  107567. */
  107568. export class UtilityLayerRenderer implements IDisposable {
  107569. /** the original scene that will be rendered on top of */
  107570. originalScene: Scene;
  107571. private _pointerCaptures;
  107572. private _lastPointerEvents;
  107573. private static _DefaultUtilityLayer;
  107574. private static _DefaultKeepDepthUtilityLayer;
  107575. private _sharedGizmoLight;
  107576. private _renderCamera;
  107577. /**
  107578. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  107579. * @returns the camera that is used when rendering the utility layer
  107580. */
  107581. getRenderCamera(): Nullable<Camera>;
  107582. /**
  107583. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  107584. * @param cam the camera that should be used when rendering the utility layer
  107585. */
  107586. setRenderCamera(cam: Nullable<Camera>): void;
  107587. /**
  107588. * @hidden
  107589. * Light which used by gizmos to get light shading
  107590. */
  107591. _getSharedGizmoLight(): HemisphericLight;
  107592. /**
  107593. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  107594. */
  107595. pickUtilitySceneFirst: boolean;
  107596. /**
  107597. * 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)
  107598. */
  107599. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  107600. /**
  107601. * 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)
  107602. */
  107603. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  107604. /**
  107605. * The scene that is rendered on top of the original scene
  107606. */
  107607. utilityLayerScene: Scene;
  107608. /**
  107609. * If the utility layer should automatically be rendered on top of existing scene
  107610. */
  107611. shouldRender: boolean;
  107612. /**
  107613. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  107614. */
  107615. onlyCheckPointerDownEvents: boolean;
  107616. /**
  107617. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107618. */
  107619. processAllEvents: boolean;
  107620. /**
  107621. * Observable raised when the pointer move from the utility layer scene to the main scene
  107622. */
  107623. onPointerOutObservable: Observable<number>;
  107624. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107625. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107626. private _afterRenderObserver;
  107627. private _sceneDisposeObserver;
  107628. private _originalPointerObserver;
  107629. /**
  107630. * Instantiates a UtilityLayerRenderer
  107631. * @param originalScene the original scene that will be rendered on top of
  107632. * @param handleEvents boolean indicating if the utility layer should handle events
  107633. */
  107634. constructor(
  107635. /** the original scene that will be rendered on top of */
  107636. originalScene: Scene, handleEvents?: boolean);
  107637. private _notifyObservers;
  107638. /**
  107639. * Renders the utility layers scene on top of the original scene
  107640. */
  107641. render(): void;
  107642. /**
  107643. * Disposes of the renderer
  107644. */
  107645. dispose(): void;
  107646. private _updateCamera;
  107647. }
  107648. }
  107649. declare module BABYLON {
  107650. /**
  107651. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107652. */
  107653. export class Gizmo implements IDisposable {
  107654. /** The utility layer the gizmo will be added to */
  107655. gizmoLayer: UtilityLayerRenderer;
  107656. /**
  107657. * The root mesh of the gizmo
  107658. */
  107659. _rootMesh: Mesh;
  107660. private _attachedMesh;
  107661. /**
  107662. * Ratio for the scale of the gizmo (Default: 1)
  107663. */
  107664. scaleRatio: number;
  107665. /**
  107666. * If a custom mesh has been set (Default: false)
  107667. */
  107668. protected _customMeshSet: boolean;
  107669. /**
  107670. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107671. * * When set, interactions will be enabled
  107672. */
  107673. attachedMesh: Nullable<AbstractMesh>;
  107674. /**
  107675. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107676. * @param mesh The mesh to replace the default mesh of the gizmo
  107677. */
  107678. setCustomMesh(mesh: Mesh): void;
  107679. /**
  107680. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107681. */
  107682. updateGizmoRotationToMatchAttachedMesh: boolean;
  107683. /**
  107684. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107685. */
  107686. updateGizmoPositionToMatchAttachedMesh: boolean;
  107687. /**
  107688. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107689. */
  107690. updateScale: boolean;
  107691. protected _interactionsEnabled: boolean;
  107692. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107693. private _beforeRenderObserver;
  107694. private _tempVector;
  107695. /**
  107696. * Creates a gizmo
  107697. * @param gizmoLayer The utility layer the gizmo will be added to
  107698. */
  107699. constructor(
  107700. /** The utility layer the gizmo will be added to */
  107701. gizmoLayer?: UtilityLayerRenderer);
  107702. /**
  107703. * Updates the gizmo to match the attached mesh's position/rotation
  107704. */
  107705. protected _update(): void;
  107706. /**
  107707. * Disposes of the gizmo
  107708. */
  107709. dispose(): void;
  107710. }
  107711. }
  107712. declare module BABYLON {
  107713. /**
  107714. * Single plane drag gizmo
  107715. */
  107716. export class PlaneDragGizmo extends Gizmo {
  107717. /**
  107718. * Drag behavior responsible for the gizmos dragging interactions
  107719. */
  107720. dragBehavior: PointerDragBehavior;
  107721. private _pointerObserver;
  107722. /**
  107723. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107724. */
  107725. snapDistance: number;
  107726. /**
  107727. * Event that fires each time the gizmo snaps to a new location.
  107728. * * snapDistance is the the change in distance
  107729. */
  107730. onSnapObservable: Observable<{
  107731. snapDistance: number;
  107732. }>;
  107733. private _plane;
  107734. private _coloredMaterial;
  107735. private _hoverMaterial;
  107736. private _isEnabled;
  107737. private _parent;
  107738. /** @hidden */
  107739. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107740. /** @hidden */
  107741. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107742. /**
  107743. * Creates a PlaneDragGizmo
  107744. * @param gizmoLayer The utility layer the gizmo will be added to
  107745. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107746. * @param color The color of the gizmo
  107747. */
  107748. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107750. /**
  107751. * If the gizmo is enabled
  107752. */
  107753. isEnabled: boolean;
  107754. /**
  107755. * Disposes of the gizmo
  107756. */
  107757. dispose(): void;
  107758. }
  107759. }
  107760. declare module BABYLON {
  107761. /**
  107762. * Gizmo that enables dragging a mesh along 3 axis
  107763. */
  107764. export class PositionGizmo extends Gizmo {
  107765. /**
  107766. * Internal gizmo used for interactions on the x axis
  107767. */
  107768. xGizmo: AxisDragGizmo;
  107769. /**
  107770. * Internal gizmo used for interactions on the y axis
  107771. */
  107772. yGizmo: AxisDragGizmo;
  107773. /**
  107774. * Internal gizmo used for interactions on the z axis
  107775. */
  107776. zGizmo: AxisDragGizmo;
  107777. /**
  107778. * Internal gizmo used for interactions on the yz plane
  107779. */
  107780. xPlaneGizmo: PlaneDragGizmo;
  107781. /**
  107782. * Internal gizmo used for interactions on the xz plane
  107783. */
  107784. yPlaneGizmo: PlaneDragGizmo;
  107785. /**
  107786. * Internal gizmo used for interactions on the xy plane
  107787. */
  107788. zPlaneGizmo: PlaneDragGizmo;
  107789. /**
  107790. * private variables
  107791. */
  107792. private _meshAttached;
  107793. private _updateGizmoRotationToMatchAttachedMesh;
  107794. private _snapDistance;
  107795. private _scaleRatio;
  107796. /** Fires an event when any of it's sub gizmos are dragged */
  107797. onDragStartObservable: Observable<unknown>;
  107798. /** Fires an event when any of it's sub gizmos are released from dragging */
  107799. onDragEndObservable: Observable<unknown>;
  107800. /**
  107801. * If set to true, planar drag is enabled
  107802. */
  107803. private _planarGizmoEnabled;
  107804. attachedMesh: Nullable<AbstractMesh>;
  107805. /**
  107806. * Creates a PositionGizmo
  107807. * @param gizmoLayer The utility layer the gizmo will be added to
  107808. */
  107809. constructor(gizmoLayer?: UtilityLayerRenderer);
  107810. /**
  107811. * If the planar drag gizmo is enabled
  107812. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107813. */
  107814. planarGizmoEnabled: boolean;
  107815. updateGizmoRotationToMatchAttachedMesh: boolean;
  107816. /**
  107817. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107818. */
  107819. snapDistance: number;
  107820. /**
  107821. * Ratio for the scale of the gizmo (Default: 1)
  107822. */
  107823. scaleRatio: number;
  107824. /**
  107825. * Disposes of the gizmo
  107826. */
  107827. dispose(): void;
  107828. /**
  107829. * CustomMeshes are not supported by this gizmo
  107830. * @param mesh The mesh to replace the default mesh of the gizmo
  107831. */
  107832. setCustomMesh(mesh: Mesh): void;
  107833. }
  107834. }
  107835. declare module BABYLON {
  107836. /**
  107837. * Single axis drag gizmo
  107838. */
  107839. export class AxisDragGizmo extends Gizmo {
  107840. /**
  107841. * Drag behavior responsible for the gizmos dragging interactions
  107842. */
  107843. dragBehavior: PointerDragBehavior;
  107844. private _pointerObserver;
  107845. /**
  107846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107847. */
  107848. snapDistance: number;
  107849. /**
  107850. * Event that fires each time the gizmo snaps to a new location.
  107851. * * snapDistance is the the change in distance
  107852. */
  107853. onSnapObservable: Observable<{
  107854. snapDistance: number;
  107855. }>;
  107856. private _isEnabled;
  107857. private _parent;
  107858. private _arrow;
  107859. private _coloredMaterial;
  107860. private _hoverMaterial;
  107861. /** @hidden */
  107862. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107863. /** @hidden */
  107864. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107865. /**
  107866. * Creates an AxisDragGizmo
  107867. * @param gizmoLayer The utility layer the gizmo will be added to
  107868. * @param dragAxis The axis which the gizmo will be able to drag on
  107869. * @param color The color of the gizmo
  107870. */
  107871. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107872. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107873. /**
  107874. * If the gizmo is enabled
  107875. */
  107876. isEnabled: boolean;
  107877. /**
  107878. * Disposes of the gizmo
  107879. */
  107880. dispose(): void;
  107881. }
  107882. }
  107883. declare module BABYLON.Debug {
  107884. /**
  107885. * The Axes viewer will show 3 axes in a specific point in space
  107886. */
  107887. export class AxesViewer {
  107888. private _xAxis;
  107889. private _yAxis;
  107890. private _zAxis;
  107891. private _scaleLinesFactor;
  107892. private _instanced;
  107893. /**
  107894. * Gets the hosting scene
  107895. */
  107896. scene: Scene;
  107897. /**
  107898. * Gets or sets a number used to scale line length
  107899. */
  107900. scaleLines: number;
  107901. /** Gets the node hierarchy used to render x-axis */
  107902. readonly xAxis: TransformNode;
  107903. /** Gets the node hierarchy used to render y-axis */
  107904. readonly yAxis: TransformNode;
  107905. /** Gets the node hierarchy used to render z-axis */
  107906. readonly zAxis: TransformNode;
  107907. /**
  107908. * Creates a new AxesViewer
  107909. * @param scene defines the hosting scene
  107910. * @param scaleLines defines a number used to scale line length (1 by default)
  107911. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107912. * @param xAxis defines the node hierarchy used to render the x-axis
  107913. * @param yAxis defines the node hierarchy used to render the y-axis
  107914. * @param zAxis defines the node hierarchy used to render the z-axis
  107915. */
  107916. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107917. /**
  107918. * Force the viewer to update
  107919. * @param position defines the position of the viewer
  107920. * @param xaxis defines the x axis of the viewer
  107921. * @param yaxis defines the y axis of the viewer
  107922. * @param zaxis defines the z axis of the viewer
  107923. */
  107924. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107925. /**
  107926. * Creates an instance of this axes viewer.
  107927. * @returns a new axes viewer with instanced meshes
  107928. */
  107929. createInstance(): AxesViewer;
  107930. /** Releases resources */
  107931. dispose(): void;
  107932. private static _SetRenderingGroupId;
  107933. }
  107934. }
  107935. declare module BABYLON.Debug {
  107936. /**
  107937. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107938. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107939. */
  107940. export class BoneAxesViewer extends AxesViewer {
  107941. /**
  107942. * Gets or sets the target mesh where to display the axes viewer
  107943. */
  107944. mesh: Nullable<Mesh>;
  107945. /**
  107946. * Gets or sets the target bone where to display the axes viewer
  107947. */
  107948. bone: Nullable<Bone>;
  107949. /** Gets current position */
  107950. pos: Vector3;
  107951. /** Gets direction of X axis */
  107952. xaxis: Vector3;
  107953. /** Gets direction of Y axis */
  107954. yaxis: Vector3;
  107955. /** Gets direction of Z axis */
  107956. zaxis: Vector3;
  107957. /**
  107958. * Creates a new BoneAxesViewer
  107959. * @param scene defines the hosting scene
  107960. * @param bone defines the target bone
  107961. * @param mesh defines the target mesh
  107962. * @param scaleLines defines a scaling factor for line length (1 by default)
  107963. */
  107964. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107965. /**
  107966. * Force the viewer to update
  107967. */
  107968. update(): void;
  107969. /** Releases resources */
  107970. dispose(): void;
  107971. }
  107972. }
  107973. declare module BABYLON {
  107974. /**
  107975. * Interface used to define scene explorer extensibility option
  107976. */
  107977. export interface IExplorerExtensibilityOption {
  107978. /**
  107979. * Define the option label
  107980. */
  107981. label: string;
  107982. /**
  107983. * Defines the action to execute on click
  107984. */
  107985. action: (entity: any) => void;
  107986. }
  107987. /**
  107988. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107989. */
  107990. export interface IExplorerExtensibilityGroup {
  107991. /**
  107992. * Defines a predicate to test if a given type mut be extended
  107993. */
  107994. predicate: (entity: any) => boolean;
  107995. /**
  107996. * Gets the list of options added to a type
  107997. */
  107998. entries: IExplorerExtensibilityOption[];
  107999. }
  108000. /**
  108001. * Interface used to define the options to use to create the Inspector
  108002. */
  108003. export interface IInspectorOptions {
  108004. /**
  108005. * Display in overlay mode (default: false)
  108006. */
  108007. overlay?: boolean;
  108008. /**
  108009. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108010. */
  108011. globalRoot?: HTMLElement;
  108012. /**
  108013. * Display the Scene explorer
  108014. */
  108015. showExplorer?: boolean;
  108016. /**
  108017. * Display the property inspector
  108018. */
  108019. showInspector?: boolean;
  108020. /**
  108021. * Display in embed mode (both panes on the right)
  108022. */
  108023. embedMode?: boolean;
  108024. /**
  108025. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108026. */
  108027. handleResize?: boolean;
  108028. /**
  108029. * Allow the panes to popup (default: true)
  108030. */
  108031. enablePopup?: boolean;
  108032. /**
  108033. * Allow the panes to be closed by users (default: true)
  108034. */
  108035. enableClose?: boolean;
  108036. /**
  108037. * Optional list of extensibility entries
  108038. */
  108039. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108040. /**
  108041. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108042. */
  108043. inspectorURL?: string;
  108044. }
  108045. interface Scene {
  108046. /**
  108047. * @hidden
  108048. * Backing field
  108049. */
  108050. _debugLayer: DebugLayer;
  108051. /**
  108052. * Gets the debug layer (aka Inspector) associated with the scene
  108053. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108054. */
  108055. debugLayer: DebugLayer;
  108056. }
  108057. /**
  108058. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108059. * what is happening in your scene
  108060. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108061. */
  108062. export class DebugLayer {
  108063. /**
  108064. * Define the url to get the inspector script from.
  108065. * By default it uses the babylonjs CDN.
  108066. * @ignoreNaming
  108067. */
  108068. static InspectorURL: string;
  108069. private _scene;
  108070. private BJSINSPECTOR;
  108071. private _onPropertyChangedObservable?;
  108072. /**
  108073. * Observable triggered when a property is changed through the inspector.
  108074. */
  108075. readonly onPropertyChangedObservable: any;
  108076. /**
  108077. * Instantiates a new debug layer.
  108078. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108079. * what is happening in your scene
  108080. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108081. * @param scene Defines the scene to inspect
  108082. */
  108083. constructor(scene: Scene);
  108084. /** Creates the inspector window. */
  108085. private _createInspector;
  108086. /**
  108087. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108088. * @param entity defines the entity to select
  108089. * @param lineContainerTitle defines the specific block to highlight
  108090. */
  108091. select(entity: any, lineContainerTitle?: string): void;
  108092. /** Get the inspector from bundle or global */
  108093. private _getGlobalInspector;
  108094. /**
  108095. * Get if the inspector is visible or not.
  108096. * @returns true if visible otherwise, false
  108097. */
  108098. isVisible(): boolean;
  108099. /**
  108100. * Hide the inspector and close its window.
  108101. */
  108102. hide(): void;
  108103. /**
  108104. * Launch the debugLayer.
  108105. * @param config Define the configuration of the inspector
  108106. * @return a promise fulfilled when the debug layer is visible
  108107. */
  108108. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108109. }
  108110. }
  108111. declare module BABYLON {
  108112. /**
  108113. * Class containing static functions to help procedurally build meshes
  108114. */
  108115. export class BoxBuilder {
  108116. /**
  108117. * Creates a box mesh
  108118. * * The parameter `size` sets the size (float) of each box side (default 1)
  108119. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108120. * * 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)
  108121. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108125. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108126. * @param name defines the name of the mesh
  108127. * @param options defines the options used to create the mesh
  108128. * @param scene defines the hosting scene
  108129. * @returns the box mesh
  108130. */
  108131. static CreateBox(name: string, options: {
  108132. size?: number;
  108133. width?: number;
  108134. height?: number;
  108135. depth?: number;
  108136. faceUV?: Vector4[];
  108137. faceColors?: Color4[];
  108138. sideOrientation?: number;
  108139. frontUVs?: Vector4;
  108140. backUVs?: Vector4;
  108141. wrap?: boolean;
  108142. topBaseAt?: number;
  108143. bottomBaseAt?: number;
  108144. updatable?: boolean;
  108145. }, scene?: Nullable<Scene>): Mesh;
  108146. }
  108147. }
  108148. declare module BABYLON {
  108149. /**
  108150. * Class containing static functions to help procedurally build meshes
  108151. */
  108152. export class SphereBuilder {
  108153. /**
  108154. * Creates a sphere mesh
  108155. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108156. * * 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`)
  108157. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108158. * * 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
  108159. * * 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)
  108160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108163. * @param name defines the name of the mesh
  108164. * @param options defines the options used to create the mesh
  108165. * @param scene defines the hosting scene
  108166. * @returns the sphere mesh
  108167. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108168. */
  108169. static CreateSphere(name: string, options: {
  108170. segments?: number;
  108171. diameter?: number;
  108172. diameterX?: number;
  108173. diameterY?: number;
  108174. diameterZ?: number;
  108175. arc?: number;
  108176. slice?: number;
  108177. sideOrientation?: number;
  108178. frontUVs?: Vector4;
  108179. backUVs?: Vector4;
  108180. updatable?: boolean;
  108181. }, scene?: Nullable<Scene>): Mesh;
  108182. }
  108183. }
  108184. declare module BABYLON.Debug {
  108185. /**
  108186. * Used to show the physics impostor around the specific mesh
  108187. */
  108188. export class PhysicsViewer {
  108189. /** @hidden */
  108190. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108191. /** @hidden */
  108192. protected _meshes: Array<Nullable<AbstractMesh>>;
  108193. /** @hidden */
  108194. protected _scene: Nullable<Scene>;
  108195. /** @hidden */
  108196. protected _numMeshes: number;
  108197. /** @hidden */
  108198. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108199. private _renderFunction;
  108200. private _utilityLayer;
  108201. private _debugBoxMesh;
  108202. private _debugSphereMesh;
  108203. private _debugCylinderMesh;
  108204. private _debugMaterial;
  108205. private _debugMeshMeshes;
  108206. /**
  108207. * Creates a new PhysicsViewer
  108208. * @param scene defines the hosting scene
  108209. */
  108210. constructor(scene: Scene);
  108211. /** @hidden */
  108212. protected _updateDebugMeshes(): void;
  108213. /**
  108214. * Renders a specified physic impostor
  108215. * @param impostor defines the impostor to render
  108216. * @param targetMesh defines the mesh represented by the impostor
  108217. * @returns the new debug mesh used to render the impostor
  108218. */
  108219. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108220. /**
  108221. * Hides a specified physic impostor
  108222. * @param impostor defines the impostor to hide
  108223. */
  108224. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108225. private _getDebugMaterial;
  108226. private _getDebugBoxMesh;
  108227. private _getDebugSphereMesh;
  108228. private _getDebugCylinderMesh;
  108229. private _getDebugMeshMesh;
  108230. private _getDebugMesh;
  108231. /** Releases all resources */
  108232. dispose(): void;
  108233. }
  108234. }
  108235. declare module BABYLON {
  108236. /**
  108237. * Class containing static functions to help procedurally build meshes
  108238. */
  108239. export class LinesBuilder {
  108240. /**
  108241. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108242. * * 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
  108243. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108244. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108245. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108246. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108247. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108248. * * 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
  108249. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108252. * @param name defines the name of the new line system
  108253. * @param options defines the options used to create the line system
  108254. * @param scene defines the hosting scene
  108255. * @returns a new line system mesh
  108256. */
  108257. static CreateLineSystem(name: string, options: {
  108258. lines: Vector3[][];
  108259. updatable?: boolean;
  108260. instance?: Nullable<LinesMesh>;
  108261. colors?: Nullable<Color4[][]>;
  108262. useVertexAlpha?: boolean;
  108263. }, scene: Nullable<Scene>): LinesMesh;
  108264. /**
  108265. * Creates a line mesh
  108266. * 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
  108267. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108268. * * The parameter `points` is an array successive Vector3
  108269. * * 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
  108270. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108271. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108272. * * When updating an instance, remember that only point positions can change, not the number of points
  108273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108275. * @param name defines the name of the new line system
  108276. * @param options defines the options used to create the line system
  108277. * @param scene defines the hosting scene
  108278. * @returns a new line mesh
  108279. */
  108280. static CreateLines(name: string, options: {
  108281. points: Vector3[];
  108282. updatable?: boolean;
  108283. instance?: Nullable<LinesMesh>;
  108284. colors?: Color4[];
  108285. useVertexAlpha?: boolean;
  108286. }, scene?: Nullable<Scene>): LinesMesh;
  108287. /**
  108288. * Creates a dashed line mesh
  108289. * * 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
  108290. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108291. * * The parameter `points` is an array successive Vector3
  108292. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108293. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108294. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108295. * * 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
  108296. * * When updating an instance, remember that only point positions can change, not the number of points
  108297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108298. * @param name defines the name of the mesh
  108299. * @param options defines the options used to create the mesh
  108300. * @param scene defines the hosting scene
  108301. * @returns the dashed line mesh
  108302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108303. */
  108304. static CreateDashedLines(name: string, options: {
  108305. points: Vector3[];
  108306. dashSize?: number;
  108307. gapSize?: number;
  108308. dashNb?: number;
  108309. updatable?: boolean;
  108310. instance?: LinesMesh;
  108311. }, scene?: Nullable<Scene>): LinesMesh;
  108312. }
  108313. }
  108314. declare module BABYLON {
  108315. /**
  108316. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108317. * in order to better appreciate the issue one might have.
  108318. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108319. */
  108320. export class RayHelper {
  108321. /**
  108322. * Defines the ray we are currently tryin to visualize.
  108323. */
  108324. ray: Nullable<Ray>;
  108325. private _renderPoints;
  108326. private _renderLine;
  108327. private _renderFunction;
  108328. private _scene;
  108329. private _updateToMeshFunction;
  108330. private _attachedToMesh;
  108331. private _meshSpaceDirection;
  108332. private _meshSpaceOrigin;
  108333. /**
  108334. * Helper function to create a colored helper in a scene in one line.
  108335. * @param ray Defines the ray we are currently tryin to visualize
  108336. * @param scene Defines the scene the ray is used in
  108337. * @param color Defines the color we want to see the ray in
  108338. * @returns The newly created ray helper.
  108339. */
  108340. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108341. /**
  108342. * Instantiate a new ray helper.
  108343. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108344. * in order to better appreciate the issue one might have.
  108345. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108346. * @param ray Defines the ray we are currently tryin to visualize
  108347. */
  108348. constructor(ray: Ray);
  108349. /**
  108350. * Shows the ray we are willing to debug.
  108351. * @param scene Defines the scene the ray needs to be rendered in
  108352. * @param color Defines the color the ray needs to be rendered in
  108353. */
  108354. show(scene: Scene, color?: Color3): void;
  108355. /**
  108356. * Hides the ray we are debugging.
  108357. */
  108358. hide(): void;
  108359. private _render;
  108360. /**
  108361. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108362. * @param mesh Defines the mesh we want the helper attached to
  108363. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108364. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108365. * @param length Defines the length of the ray
  108366. */
  108367. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108368. /**
  108369. * Detach the ray helper from the mesh it has previously been attached to.
  108370. */
  108371. detachFromMesh(): void;
  108372. private _updateToMesh;
  108373. /**
  108374. * Dispose the helper and release its associated resources.
  108375. */
  108376. dispose(): void;
  108377. }
  108378. }
  108379. declare module BABYLON.Debug {
  108380. /**
  108381. * Class used to render a debug view of a given skeleton
  108382. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108383. */
  108384. export class SkeletonViewer {
  108385. /** defines the skeleton to render */
  108386. skeleton: Skeleton;
  108387. /** defines the mesh attached to the skeleton */
  108388. mesh: AbstractMesh;
  108389. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108390. autoUpdateBonesMatrices: boolean;
  108391. /** defines the rendering group id to use with the viewer */
  108392. renderingGroupId: number;
  108393. /** Gets or sets the color used to render the skeleton */
  108394. color: Color3;
  108395. private _scene;
  108396. private _debugLines;
  108397. private _debugMesh;
  108398. private _isEnabled;
  108399. private _renderFunction;
  108400. private _utilityLayer;
  108401. /**
  108402. * Returns the mesh used to render the bones
  108403. */
  108404. readonly debugMesh: Nullable<LinesMesh>;
  108405. /**
  108406. * Creates a new SkeletonViewer
  108407. * @param skeleton defines the skeleton to render
  108408. * @param mesh defines the mesh attached to the skeleton
  108409. * @param scene defines the hosting scene
  108410. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108411. * @param renderingGroupId defines the rendering group id to use with the viewer
  108412. */
  108413. constructor(
  108414. /** defines the skeleton to render */
  108415. skeleton: Skeleton,
  108416. /** defines the mesh attached to the skeleton */
  108417. mesh: AbstractMesh, scene: Scene,
  108418. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108419. autoUpdateBonesMatrices?: boolean,
  108420. /** defines the rendering group id to use with the viewer */
  108421. renderingGroupId?: number);
  108422. /** Gets or sets a boolean indicating if the viewer is enabled */
  108423. isEnabled: boolean;
  108424. private _getBonePosition;
  108425. private _getLinesForBonesWithLength;
  108426. private _getLinesForBonesNoLength;
  108427. /** Update the viewer to sync with current skeleton state */
  108428. update(): void;
  108429. /** Release associated resources */
  108430. dispose(): void;
  108431. }
  108432. }
  108433. declare module BABYLON {
  108434. /**
  108435. * Options to create the null engine
  108436. */
  108437. export class NullEngineOptions {
  108438. /**
  108439. * Render width (Default: 512)
  108440. */
  108441. renderWidth: number;
  108442. /**
  108443. * Render height (Default: 256)
  108444. */
  108445. renderHeight: number;
  108446. /**
  108447. * Texture size (Default: 512)
  108448. */
  108449. textureSize: number;
  108450. /**
  108451. * If delta time between frames should be constant
  108452. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108453. */
  108454. deterministicLockstep: boolean;
  108455. /**
  108456. * Maximum about of steps between frames (Default: 4)
  108457. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108458. */
  108459. lockstepMaxSteps: number;
  108460. }
  108461. /**
  108462. * The null engine class provides support for headless version of babylon.js.
  108463. * This can be used in server side scenario or for testing purposes
  108464. */
  108465. export class NullEngine extends Engine {
  108466. private _options;
  108467. /**
  108468. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108469. */
  108470. isDeterministicLockStep(): boolean;
  108471. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108472. getLockstepMaxSteps(): number;
  108473. /**
  108474. * Sets hardware scaling, used to save performance if needed
  108475. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108476. */
  108477. getHardwareScalingLevel(): number;
  108478. constructor(options?: NullEngineOptions);
  108479. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108480. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108481. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108482. getRenderWidth(useScreen?: boolean): number;
  108483. getRenderHeight(useScreen?: boolean): number;
  108484. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108485. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108486. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108487. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108488. bindSamplers(effect: Effect): void;
  108489. enableEffect(effect: Effect): void;
  108490. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108491. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108492. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108493. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108494. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108495. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108496. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108497. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108498. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108499. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108500. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108501. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108502. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108503. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108504. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108505. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108506. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108507. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108508. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108509. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108510. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108511. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108512. bindBuffers(vertexBuffers: {
  108513. [key: string]: VertexBuffer;
  108514. }, indexBuffer: DataBuffer, effect: Effect): void;
  108515. wipeCaches(bruteForce?: boolean): void;
  108516. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108517. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108518. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108519. /** @hidden */
  108520. _createTexture(): WebGLTexture;
  108521. /** @hidden */
  108522. _releaseTexture(texture: InternalTexture): void;
  108523. 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;
  108524. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108525. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108526. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108527. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108528. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108529. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108530. areAllEffectsReady(): boolean;
  108531. /**
  108532. * @hidden
  108533. * Get the current error code of the webGL context
  108534. * @returns the error code
  108535. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108536. */
  108537. getError(): number;
  108538. /** @hidden */
  108539. _getUnpackAlignement(): number;
  108540. /** @hidden */
  108541. _unpackFlipY(value: boolean): void;
  108542. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108543. /**
  108544. * Updates a dynamic vertex buffer.
  108545. * @param vertexBuffer the vertex buffer to update
  108546. * @param data the data used to update the vertex buffer
  108547. * @param byteOffset the byte offset of the data (optional)
  108548. * @param byteLength the byte length of the data (optional)
  108549. */
  108550. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108551. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108552. /** @hidden */
  108553. _bindTexture(channel: number, texture: InternalTexture): void;
  108554. /** @hidden */
  108555. _releaseBuffer(buffer: DataBuffer): boolean;
  108556. releaseEffects(): void;
  108557. displayLoadingUI(): void;
  108558. hideLoadingUI(): void;
  108559. /** @hidden */
  108560. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108561. /** @hidden */
  108562. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108563. /** @hidden */
  108564. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108565. /** @hidden */
  108566. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  108567. }
  108568. }
  108569. declare module BABYLON {
  108570. /** @hidden */
  108571. export class _OcclusionDataStorage {
  108572. /** @hidden */
  108573. occlusionInternalRetryCounter: number;
  108574. /** @hidden */
  108575. isOcclusionQueryInProgress: boolean;
  108576. /** @hidden */
  108577. isOccluded: boolean;
  108578. /** @hidden */
  108579. occlusionRetryCount: number;
  108580. /** @hidden */
  108581. occlusionType: number;
  108582. /** @hidden */
  108583. occlusionQueryAlgorithmType: number;
  108584. }
  108585. interface Engine {
  108586. /**
  108587. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  108588. * @return the new query
  108589. */
  108590. createQuery(): WebGLQuery;
  108591. /**
  108592. * Delete and release a webGL query
  108593. * @param query defines the query to delete
  108594. * @return the current engine
  108595. */
  108596. deleteQuery(query: WebGLQuery): Engine;
  108597. /**
  108598. * Check if a given query has resolved and got its value
  108599. * @param query defines the query to check
  108600. * @returns true if the query got its value
  108601. */
  108602. isQueryResultAvailable(query: WebGLQuery): boolean;
  108603. /**
  108604. * Gets the value of a given query
  108605. * @param query defines the query to check
  108606. * @returns the value of the query
  108607. */
  108608. getQueryResult(query: WebGLQuery): number;
  108609. /**
  108610. * Initiates an occlusion query
  108611. * @param algorithmType defines the algorithm to use
  108612. * @param query defines the query to use
  108613. * @returns the current engine
  108614. * @see http://doc.babylonjs.com/features/occlusionquery
  108615. */
  108616. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  108617. /**
  108618. * Ends an occlusion query
  108619. * @see http://doc.babylonjs.com/features/occlusionquery
  108620. * @param algorithmType defines the algorithm to use
  108621. * @returns the current engine
  108622. */
  108623. endOcclusionQuery(algorithmType: number): Engine;
  108624. /**
  108625. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108626. * Please note that only one query can be issued at a time
  108627. * @returns a time token used to track the time span
  108628. */
  108629. startTimeQuery(): Nullable<_TimeToken>;
  108630. /**
  108631. * Ends a time query
  108632. * @param token defines the token used to measure the time span
  108633. * @returns the time spent (in ns)
  108634. */
  108635. endTimeQuery(token: _TimeToken): int;
  108636. /** @hidden */
  108637. _currentNonTimestampToken: Nullable<_TimeToken>;
  108638. /** @hidden */
  108639. _createTimeQuery(): WebGLQuery;
  108640. /** @hidden */
  108641. _deleteTimeQuery(query: WebGLQuery): void;
  108642. /** @hidden */
  108643. _getGlAlgorithmType(algorithmType: number): number;
  108644. /** @hidden */
  108645. _getTimeQueryResult(query: WebGLQuery): any;
  108646. /** @hidden */
  108647. _getTimeQueryAvailability(query: WebGLQuery): any;
  108648. }
  108649. interface AbstractMesh {
  108650. /**
  108651. * Backing filed
  108652. * @hidden
  108653. */
  108654. __occlusionDataStorage: _OcclusionDataStorage;
  108655. /**
  108656. * Access property
  108657. * @hidden
  108658. */
  108659. _occlusionDataStorage: _OcclusionDataStorage;
  108660. /**
  108661. * 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.
  108662. * The default value is -1 which means don't break the query and wait till the result
  108663. * @see http://doc.babylonjs.com/features/occlusionquery
  108664. */
  108665. occlusionRetryCount: number;
  108666. /**
  108667. * 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:
  108668. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108669. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108670. * * 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.
  108671. * @see http://doc.babylonjs.com/features/occlusionquery
  108672. */
  108673. occlusionType: number;
  108674. /**
  108675. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108676. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108677. * * 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.
  108678. * @see http://doc.babylonjs.com/features/occlusionquery
  108679. */
  108680. occlusionQueryAlgorithmType: number;
  108681. /**
  108682. * 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
  108683. * @see http://doc.babylonjs.com/features/occlusionquery
  108684. */
  108685. isOccluded: boolean;
  108686. /**
  108687. * Flag to check the progress status of the query
  108688. * @see http://doc.babylonjs.com/features/occlusionquery
  108689. */
  108690. isOcclusionQueryInProgress: boolean;
  108691. }
  108692. }
  108693. declare module BABYLON {
  108694. /** @hidden */
  108695. export var _forceTransformFeedbackToBundle: boolean;
  108696. interface Engine {
  108697. /**
  108698. * Creates a webGL transform feedback object
  108699. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108700. * @returns the webGL transform feedback object
  108701. */
  108702. createTransformFeedback(): WebGLTransformFeedback;
  108703. /**
  108704. * Delete a webGL transform feedback object
  108705. * @param value defines the webGL transform feedback object to delete
  108706. */
  108707. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108708. /**
  108709. * Bind a webGL transform feedback object to the webgl context
  108710. * @param value defines the webGL transform feedback object to bind
  108711. */
  108712. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108713. /**
  108714. * Begins a transform feedback operation
  108715. * @param usePoints defines if points or triangles must be used
  108716. */
  108717. beginTransformFeedback(usePoints: boolean): void;
  108718. /**
  108719. * Ends a transform feedback operation
  108720. */
  108721. endTransformFeedback(): void;
  108722. /**
  108723. * Specify the varyings to use with transform feedback
  108724. * @param program defines the associated webGL program
  108725. * @param value defines the list of strings representing the varying names
  108726. */
  108727. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108728. /**
  108729. * Bind a webGL buffer for a transform feedback operation
  108730. * @param value defines the webGL buffer to bind
  108731. */
  108732. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108733. }
  108734. }
  108735. declare module BABYLON {
  108736. /**
  108737. * Creation options of the multi render target texture.
  108738. */
  108739. export interface IMultiRenderTargetOptions {
  108740. /**
  108741. * Define if the texture needs to create mip maps after render.
  108742. */
  108743. generateMipMaps?: boolean;
  108744. /**
  108745. * Define the types of all the draw buffers we want to create
  108746. */
  108747. types?: number[];
  108748. /**
  108749. * Define the sampling modes of all the draw buffers we want to create
  108750. */
  108751. samplingModes?: number[];
  108752. /**
  108753. * Define if a depth buffer is required
  108754. */
  108755. generateDepthBuffer?: boolean;
  108756. /**
  108757. * Define if a stencil buffer is required
  108758. */
  108759. generateStencilBuffer?: boolean;
  108760. /**
  108761. * Define if a depth texture is required instead of a depth buffer
  108762. */
  108763. generateDepthTexture?: boolean;
  108764. /**
  108765. * Define the number of desired draw buffers
  108766. */
  108767. textureCount?: number;
  108768. /**
  108769. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108770. */
  108771. doNotChangeAspectRatio?: boolean;
  108772. /**
  108773. * Define the default type of the buffers we are creating
  108774. */
  108775. defaultType?: number;
  108776. }
  108777. /**
  108778. * A multi render target, like a render target provides the ability to render to a texture.
  108779. * Unlike the render target, it can render to several draw buffers in one draw.
  108780. * This is specially interesting in deferred rendering or for any effects requiring more than
  108781. * just one color from a single pass.
  108782. */
  108783. export class MultiRenderTarget extends RenderTargetTexture {
  108784. private _internalTextures;
  108785. private _textures;
  108786. private _multiRenderTargetOptions;
  108787. /**
  108788. * Get if draw buffers are currently supported by the used hardware and browser.
  108789. */
  108790. readonly isSupported: boolean;
  108791. /**
  108792. * Get the list of textures generated by the multi render target.
  108793. */
  108794. readonly textures: Texture[];
  108795. /**
  108796. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108797. */
  108798. readonly depthTexture: Texture;
  108799. /**
  108800. * Set the wrapping mode on U of all the textures we are rendering to.
  108801. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108802. */
  108803. wrapU: number;
  108804. /**
  108805. * Set the wrapping mode on V of all the textures we are rendering to.
  108806. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108807. */
  108808. wrapV: number;
  108809. /**
  108810. * Instantiate a new multi render target texture.
  108811. * A multi render target, like a render target provides the ability to render to a texture.
  108812. * Unlike the render target, it can render to several draw buffers in one draw.
  108813. * This is specially interesting in deferred rendering or for any effects requiring more than
  108814. * just one color from a single pass.
  108815. * @param name Define the name of the texture
  108816. * @param size Define the size of the buffers to render to
  108817. * @param count Define the number of target we are rendering into
  108818. * @param scene Define the scene the texture belongs to
  108819. * @param options Define the options used to create the multi render target
  108820. */
  108821. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108822. /** @hidden */
  108823. _rebuild(): void;
  108824. private _createInternalTextures;
  108825. private _createTextures;
  108826. /**
  108827. * Define the number of samples used if MSAA is enabled.
  108828. */
  108829. samples: number;
  108830. /**
  108831. * Resize all the textures in the multi render target.
  108832. * Be carrefull as it will recreate all the data in the new texture.
  108833. * @param size Define the new size
  108834. */
  108835. resize(size: any): void;
  108836. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108837. /**
  108838. * Dispose the render targets and their associated resources
  108839. */
  108840. dispose(): void;
  108841. /**
  108842. * Release all the underlying texture used as draw buffers.
  108843. */
  108844. releaseInternalTextures(): void;
  108845. }
  108846. }
  108847. declare module BABYLON {
  108848. interface Engine {
  108849. /**
  108850. * Unbind a list of render target textures from the webGL context
  108851. * This is used only when drawBuffer extension or webGL2 are active
  108852. * @param textures defines the render target textures to unbind
  108853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108855. */
  108856. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108857. /**
  108858. * Create a multi render target texture
  108859. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108860. * @param size defines the size of the texture
  108861. * @param options defines the creation options
  108862. * @returns the cube texture as an InternalTexture
  108863. */
  108864. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108865. /**
  108866. * Update the sample count for a given multiple render target texture
  108867. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108868. * @param textures defines the textures to update
  108869. * @param samples defines the sample count to set
  108870. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108871. */
  108872. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108873. }
  108874. }
  108875. declare module BABYLON {
  108876. /**
  108877. * Gather the list of clipboard event types as constants.
  108878. */
  108879. export class ClipboardEventTypes {
  108880. /**
  108881. * The clipboard event is fired when a copy command is active (pressed).
  108882. */
  108883. static readonly COPY: number;
  108884. /**
  108885. * The clipboard event is fired when a cut command is active (pressed).
  108886. */
  108887. static readonly CUT: number;
  108888. /**
  108889. * The clipboard event is fired when a paste command is active (pressed).
  108890. */
  108891. static readonly PASTE: number;
  108892. }
  108893. /**
  108894. * This class is used to store clipboard related info for the onClipboardObservable event.
  108895. */
  108896. export class ClipboardInfo {
  108897. /**
  108898. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108899. */
  108900. type: number;
  108901. /**
  108902. * Defines the related dom event
  108903. */
  108904. event: ClipboardEvent;
  108905. /**
  108906. *Creates an instance of ClipboardInfo.
  108907. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108908. * @param event Defines the related dom event
  108909. */
  108910. constructor(
  108911. /**
  108912. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108913. */
  108914. type: number,
  108915. /**
  108916. * Defines the related dom event
  108917. */
  108918. event: ClipboardEvent);
  108919. /**
  108920. * Get the clipboard event's type from the keycode.
  108921. * @param keyCode Defines the keyCode for the current keyboard event.
  108922. * @return {number}
  108923. */
  108924. static GetTypeFromCharacter(keyCode: number): number;
  108925. }
  108926. }
  108927. declare module BABYLON {
  108928. /**
  108929. * Google Daydream controller
  108930. */
  108931. export class DaydreamController extends WebVRController {
  108932. /**
  108933. * Base Url for the controller model.
  108934. */
  108935. static MODEL_BASE_URL: string;
  108936. /**
  108937. * File name for the controller model.
  108938. */
  108939. static MODEL_FILENAME: string;
  108940. /**
  108941. * Gamepad Id prefix used to identify Daydream Controller.
  108942. */
  108943. static readonly GAMEPAD_ID_PREFIX: string;
  108944. /**
  108945. * Creates a new DaydreamController from a gamepad
  108946. * @param vrGamepad the gamepad that the controller should be created from
  108947. */
  108948. constructor(vrGamepad: any);
  108949. /**
  108950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108951. * @param scene scene in which to add meshes
  108952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108953. */
  108954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108955. /**
  108956. * Called once for each button that changed state since the last frame
  108957. * @param buttonIdx Which button index changed
  108958. * @param state New state of the button
  108959. * @param changes Which properties on the state changed since last frame
  108960. */
  108961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108962. }
  108963. }
  108964. declare module BABYLON {
  108965. /**
  108966. * Gear VR Controller
  108967. */
  108968. export class GearVRController extends WebVRController {
  108969. /**
  108970. * Base Url for the controller model.
  108971. */
  108972. static MODEL_BASE_URL: string;
  108973. /**
  108974. * File name for the controller model.
  108975. */
  108976. static MODEL_FILENAME: string;
  108977. /**
  108978. * Gamepad Id prefix used to identify this controller.
  108979. */
  108980. static readonly GAMEPAD_ID_PREFIX: string;
  108981. private readonly _buttonIndexToObservableNameMap;
  108982. /**
  108983. * Creates a new GearVRController from a gamepad
  108984. * @param vrGamepad the gamepad that the controller should be created from
  108985. */
  108986. constructor(vrGamepad: any);
  108987. /**
  108988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108989. * @param scene scene in which to add meshes
  108990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108991. */
  108992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108993. /**
  108994. * Called once for each button that changed state since the last frame
  108995. * @param buttonIdx Which button index changed
  108996. * @param state New state of the button
  108997. * @param changes Which properties on the state changed since last frame
  108998. */
  108999. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109000. }
  109001. }
  109002. declare module BABYLON {
  109003. /**
  109004. * Class containing static functions to help procedurally build meshes
  109005. */
  109006. export class PolyhedronBuilder {
  109007. /**
  109008. * Creates a polyhedron mesh
  109009. * * 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
  109010. * * The parameter `size` (positive float, default 1) sets the polygon size
  109011. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109012. * * 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`
  109013. * * 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
  109014. * * 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)`)
  109015. * * 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
  109016. * * 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
  109017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109020. * @param name defines the name of the mesh
  109021. * @param options defines the options used to create the mesh
  109022. * @param scene defines the hosting scene
  109023. * @returns the polyhedron mesh
  109024. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109025. */
  109026. static CreatePolyhedron(name: string, options: {
  109027. type?: number;
  109028. size?: number;
  109029. sizeX?: number;
  109030. sizeY?: number;
  109031. sizeZ?: number;
  109032. custom?: any;
  109033. faceUV?: Vector4[];
  109034. faceColors?: Color4[];
  109035. flat?: boolean;
  109036. updatable?: boolean;
  109037. sideOrientation?: number;
  109038. frontUVs?: Vector4;
  109039. backUVs?: Vector4;
  109040. }, scene?: Nullable<Scene>): Mesh;
  109041. }
  109042. }
  109043. declare module BABYLON {
  109044. /**
  109045. * Gizmo that enables scaling a mesh along 3 axis
  109046. */
  109047. export class ScaleGizmo extends Gizmo {
  109048. /**
  109049. * Internal gizmo used for interactions on the x axis
  109050. */
  109051. xGizmo: AxisScaleGizmo;
  109052. /**
  109053. * Internal gizmo used for interactions on the y axis
  109054. */
  109055. yGizmo: AxisScaleGizmo;
  109056. /**
  109057. * Internal gizmo used for interactions on the z axis
  109058. */
  109059. zGizmo: AxisScaleGizmo;
  109060. /**
  109061. * Internal gizmo used to scale all axis equally
  109062. */
  109063. uniformScaleGizmo: AxisScaleGizmo;
  109064. private _meshAttached;
  109065. private _updateGizmoRotationToMatchAttachedMesh;
  109066. private _snapDistance;
  109067. private _scaleRatio;
  109068. private _uniformScalingMesh;
  109069. private _octahedron;
  109070. /** Fires an event when any of it's sub gizmos are dragged */
  109071. onDragStartObservable: Observable<unknown>;
  109072. /** Fires an event when any of it's sub gizmos are released from dragging */
  109073. onDragEndObservable: Observable<unknown>;
  109074. attachedMesh: Nullable<AbstractMesh>;
  109075. /**
  109076. * Creates a ScaleGizmo
  109077. * @param gizmoLayer The utility layer the gizmo will be added to
  109078. */
  109079. constructor(gizmoLayer?: UtilityLayerRenderer);
  109080. updateGizmoRotationToMatchAttachedMesh: boolean;
  109081. /**
  109082. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109083. */
  109084. snapDistance: number;
  109085. /**
  109086. * Ratio for the scale of the gizmo (Default: 1)
  109087. */
  109088. scaleRatio: number;
  109089. /**
  109090. * Disposes of the gizmo
  109091. */
  109092. dispose(): void;
  109093. }
  109094. }
  109095. declare module BABYLON {
  109096. /**
  109097. * Single axis scale gizmo
  109098. */
  109099. export class AxisScaleGizmo extends Gizmo {
  109100. /**
  109101. * Drag behavior responsible for the gizmos dragging interactions
  109102. */
  109103. dragBehavior: PointerDragBehavior;
  109104. private _pointerObserver;
  109105. /**
  109106. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109107. */
  109108. snapDistance: number;
  109109. /**
  109110. * Event that fires each time the gizmo snaps to a new location.
  109111. * * snapDistance is the the change in distance
  109112. */
  109113. onSnapObservable: Observable<{
  109114. snapDistance: number;
  109115. }>;
  109116. /**
  109117. * If the scaling operation should be done on all axis (default: false)
  109118. */
  109119. uniformScaling: boolean;
  109120. private _isEnabled;
  109121. private _parent;
  109122. private _arrow;
  109123. private _coloredMaterial;
  109124. private _hoverMaterial;
  109125. /**
  109126. * Creates an AxisScaleGizmo
  109127. * @param gizmoLayer The utility layer the gizmo will be added to
  109128. * @param dragAxis The axis which the gizmo will be able to scale on
  109129. * @param color The color of the gizmo
  109130. */
  109131. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  109132. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109133. /**
  109134. * If the gizmo is enabled
  109135. */
  109136. isEnabled: boolean;
  109137. /**
  109138. * Disposes of the gizmo
  109139. */
  109140. dispose(): void;
  109141. /**
  109142. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109143. * @param mesh The mesh to replace the default mesh of the gizmo
  109144. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  109145. */
  109146. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  109147. }
  109148. }
  109149. declare module BABYLON {
  109150. /**
  109151. * Bounding box gizmo
  109152. */
  109153. export class BoundingBoxGizmo extends Gizmo {
  109154. private _lineBoundingBox;
  109155. private _rotateSpheresParent;
  109156. private _scaleBoxesParent;
  109157. private _boundingDimensions;
  109158. private _renderObserver;
  109159. private _pointerObserver;
  109160. private _scaleDragSpeed;
  109161. private _tmpQuaternion;
  109162. private _tmpVector;
  109163. private _tmpRotationMatrix;
  109164. /**
  109165. * 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)
  109166. */
  109167. ignoreChildren: boolean;
  109168. /**
  109169. * 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)
  109170. */
  109171. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  109172. /**
  109173. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  109174. */
  109175. rotationSphereSize: number;
  109176. /**
  109177. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  109178. */
  109179. scaleBoxSize: number;
  109180. /**
  109181. * 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)
  109182. */
  109183. fixedDragMeshScreenSize: boolean;
  109184. /**
  109185. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  109186. */
  109187. fixedDragMeshScreenSizeDistanceFactor: number;
  109188. /**
  109189. * Fired when a rotation sphere or scale box is dragged
  109190. */
  109191. onDragStartObservable: Observable<{}>;
  109192. /**
  109193. * Fired when a scale box is dragged
  109194. */
  109195. onScaleBoxDragObservable: Observable<{}>;
  109196. /**
  109197. * Fired when a scale box drag is ended
  109198. */
  109199. onScaleBoxDragEndObservable: Observable<{}>;
  109200. /**
  109201. * Fired when a rotation sphere is dragged
  109202. */
  109203. onRotationSphereDragObservable: Observable<{}>;
  109204. /**
  109205. * Fired when a rotation sphere drag is ended
  109206. */
  109207. onRotationSphereDragEndObservable: Observable<{}>;
  109208. /**
  109209. * 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)
  109210. */
  109211. scalePivot: Nullable<Vector3>;
  109212. /**
  109213. * Mesh used as a pivot to rotate the attached mesh
  109214. */
  109215. private _anchorMesh;
  109216. private _existingMeshScale;
  109217. private _dragMesh;
  109218. private pointerDragBehavior;
  109219. private coloredMaterial;
  109220. private hoverColoredMaterial;
  109221. /**
  109222. * Sets the color of the bounding box gizmo
  109223. * @param color the color to set
  109224. */
  109225. setColor(color: Color3): void;
  109226. /**
  109227. * Creates an BoundingBoxGizmo
  109228. * @param gizmoLayer The utility layer the gizmo will be added to
  109229. * @param color The color of the gizmo
  109230. */
  109231. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  109232. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109233. private _selectNode;
  109234. /**
  109235. * Updates the bounding box information for the Gizmo
  109236. */
  109237. updateBoundingBox(): void;
  109238. private _updateRotationSpheres;
  109239. private _updateScaleBoxes;
  109240. /**
  109241. * Enables rotation on the specified axis and disables rotation on the others
  109242. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  109243. */
  109244. setEnabledRotationAxis(axis: string): void;
  109245. /**
  109246. * Enables/disables scaling
  109247. * @param enable if scaling should be enabled
  109248. */
  109249. setEnabledScaling(enable: boolean): void;
  109250. private _updateDummy;
  109251. /**
  109252. * Enables a pointer drag behavior on the bounding box of the gizmo
  109253. */
  109254. enableDragBehavior(): void;
  109255. /**
  109256. * Disposes of the gizmo
  109257. */
  109258. dispose(): void;
  109259. /**
  109260. * 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)
  109261. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  109262. * @returns the bounding box mesh with the passed in mesh as a child
  109263. */
  109264. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  109265. /**
  109266. * CustomMeshes are not supported by this gizmo
  109267. * @param mesh The mesh to replace the default mesh of the gizmo
  109268. */
  109269. setCustomMesh(mesh: Mesh): void;
  109270. }
  109271. }
  109272. declare module BABYLON {
  109273. /**
  109274. * Single plane rotation gizmo
  109275. */
  109276. export class PlaneRotationGizmo extends Gizmo {
  109277. /**
  109278. * Drag behavior responsible for the gizmos dragging interactions
  109279. */
  109280. dragBehavior: PointerDragBehavior;
  109281. private _pointerObserver;
  109282. /**
  109283. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  109284. */
  109285. snapDistance: number;
  109286. /**
  109287. * Event that fires each time the gizmo snaps to a new location.
  109288. * * snapDistance is the the change in distance
  109289. */
  109290. onSnapObservable: Observable<{
  109291. snapDistance: number;
  109292. }>;
  109293. private _isEnabled;
  109294. private _parent;
  109295. /**
  109296. * Creates a PlaneRotationGizmo
  109297. * @param gizmoLayer The utility layer the gizmo will be added to
  109298. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  109299. * @param color The color of the gizmo
  109300. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109301. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109302. */
  109303. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  109304. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109305. /**
  109306. * If the gizmo is enabled
  109307. */
  109308. isEnabled: boolean;
  109309. /**
  109310. * Disposes of the gizmo
  109311. */
  109312. dispose(): void;
  109313. }
  109314. }
  109315. declare module BABYLON {
  109316. /**
  109317. * Gizmo that enables rotating a mesh along 3 axis
  109318. */
  109319. export class RotationGizmo extends Gizmo {
  109320. /**
  109321. * Internal gizmo used for interactions on the x axis
  109322. */
  109323. xGizmo: PlaneRotationGizmo;
  109324. /**
  109325. * Internal gizmo used for interactions on the y axis
  109326. */
  109327. yGizmo: PlaneRotationGizmo;
  109328. /**
  109329. * Internal gizmo used for interactions on the z axis
  109330. */
  109331. zGizmo: PlaneRotationGizmo;
  109332. /** Fires an event when any of it's sub gizmos are dragged */
  109333. onDragStartObservable: Observable<unknown>;
  109334. /** Fires an event when any of it's sub gizmos are released from dragging */
  109335. onDragEndObservable: Observable<unknown>;
  109336. private _meshAttached;
  109337. attachedMesh: Nullable<AbstractMesh>;
  109338. /**
  109339. * Creates a RotationGizmo
  109340. * @param gizmoLayer The utility layer the gizmo will be added to
  109341. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109342. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109343. */
  109344. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  109345. updateGizmoRotationToMatchAttachedMesh: boolean;
  109346. /**
  109347. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109348. */
  109349. snapDistance: number;
  109350. /**
  109351. * Ratio for the scale of the gizmo (Default: 1)
  109352. */
  109353. scaleRatio: number;
  109354. /**
  109355. * Disposes of the gizmo
  109356. */
  109357. dispose(): void;
  109358. /**
  109359. * CustomMeshes are not supported by this gizmo
  109360. * @param mesh The mesh to replace the default mesh of the gizmo
  109361. */
  109362. setCustomMesh(mesh: Mesh): void;
  109363. }
  109364. }
  109365. declare module BABYLON {
  109366. /**
  109367. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  109368. */
  109369. export class GizmoManager implements IDisposable {
  109370. private scene;
  109371. /**
  109372. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  109373. */
  109374. gizmos: {
  109375. positionGizmo: Nullable<PositionGizmo>;
  109376. rotationGizmo: Nullable<RotationGizmo>;
  109377. scaleGizmo: Nullable<ScaleGizmo>;
  109378. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  109379. };
  109380. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  109381. clearGizmoOnEmptyPointerEvent: boolean;
  109382. /** Fires an event when the manager is attached to a mesh */
  109383. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  109384. private _gizmosEnabled;
  109385. private _pointerObserver;
  109386. private _attachedMesh;
  109387. private _boundingBoxColor;
  109388. private _defaultUtilityLayer;
  109389. private _defaultKeepDepthUtilityLayer;
  109390. /**
  109391. * When bounding box gizmo is enabled, this can be used to track drag/end events
  109392. */
  109393. boundingBoxDragBehavior: SixDofDragBehavior;
  109394. /**
  109395. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  109396. */
  109397. attachableMeshes: Nullable<Array<AbstractMesh>>;
  109398. /**
  109399. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  109400. */
  109401. usePointerToAttachGizmos: boolean;
  109402. /**
  109403. * Utility layer that the bounding box gizmo belongs to
  109404. */
  109405. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  109406. /**
  109407. * Utility layer that all gizmos besides bounding box belong to
  109408. */
  109409. readonly utilityLayer: UtilityLayerRenderer;
  109410. /**
  109411. * Instatiates a gizmo manager
  109412. * @param scene the scene to overlay the gizmos on top of
  109413. */
  109414. constructor(scene: Scene);
  109415. /**
  109416. * Attaches a set of gizmos to the specified mesh
  109417. * @param mesh The mesh the gizmo's should be attached to
  109418. */
  109419. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  109420. /**
  109421. * If the position gizmo is enabled
  109422. */
  109423. positionGizmoEnabled: boolean;
  109424. /**
  109425. * If the rotation gizmo is enabled
  109426. */
  109427. rotationGizmoEnabled: boolean;
  109428. /**
  109429. * If the scale gizmo is enabled
  109430. */
  109431. scaleGizmoEnabled: boolean;
  109432. /**
  109433. * If the boundingBox gizmo is enabled
  109434. */
  109435. boundingBoxGizmoEnabled: boolean;
  109436. /**
  109437. * Disposes of the gizmo manager
  109438. */
  109439. dispose(): void;
  109440. }
  109441. }
  109442. declare module BABYLON {
  109443. /**
  109444. * A directional light is defined by a direction (what a surprise!).
  109445. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  109446. * 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.
  109447. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109448. */
  109449. export class DirectionalLight extends ShadowLight {
  109450. private _shadowFrustumSize;
  109451. /**
  109452. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  109453. */
  109454. /**
  109455. * Specifies a fix frustum size for the shadow generation.
  109456. */
  109457. shadowFrustumSize: number;
  109458. private _shadowOrthoScale;
  109459. /**
  109460. * Gets the shadow projection scale against the optimal computed one.
  109461. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109462. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109463. */
  109464. /**
  109465. * Sets the shadow projection scale against the optimal computed one.
  109466. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109467. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109468. */
  109469. shadowOrthoScale: number;
  109470. /**
  109471. * Automatically compute the projection matrix to best fit (including all the casters)
  109472. * on each frame.
  109473. */
  109474. autoUpdateExtends: boolean;
  109475. private _orthoLeft;
  109476. private _orthoRight;
  109477. private _orthoTop;
  109478. private _orthoBottom;
  109479. /**
  109480. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  109481. * The directional light is emitted from everywhere in the given direction.
  109482. * It can cast shadows.
  109483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109484. * @param name The friendly name of the light
  109485. * @param direction The direction of the light
  109486. * @param scene The scene the light belongs to
  109487. */
  109488. constructor(name: string, direction: Vector3, scene: Scene);
  109489. /**
  109490. * Returns the string "DirectionalLight".
  109491. * @return The class name
  109492. */
  109493. getClassName(): string;
  109494. /**
  109495. * Returns the integer 1.
  109496. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109497. */
  109498. getTypeID(): number;
  109499. /**
  109500. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  109501. * Returns the DirectionalLight Shadow projection matrix.
  109502. */
  109503. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109504. /**
  109505. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  109506. * Returns the DirectionalLight Shadow projection matrix.
  109507. */
  109508. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  109509. /**
  109510. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  109511. * Returns the DirectionalLight Shadow projection matrix.
  109512. */
  109513. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109514. protected _buildUniformLayout(): void;
  109515. /**
  109516. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  109517. * @param effect The effect to update
  109518. * @param lightIndex The index of the light in the effect to update
  109519. * @returns The directional light
  109520. */
  109521. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  109522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  109523. /**
  109524. * Gets the minZ used for shadow according to both the scene and the light.
  109525. *
  109526. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109527. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109528. * @param activeCamera The camera we are returning the min for
  109529. * @returns the depth min z
  109530. */
  109531. getDepthMinZ(activeCamera: Camera): number;
  109532. /**
  109533. * Gets the maxZ used for shadow according to both the scene and the light.
  109534. *
  109535. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109536. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109537. * @param activeCamera The camera we are returning the max for
  109538. * @returns the depth max z
  109539. */
  109540. getDepthMaxZ(activeCamera: Camera): number;
  109541. /**
  109542. * Prepares the list of defines specific to the light type.
  109543. * @param defines the list of defines
  109544. * @param lightIndex defines the index of the light for the effect
  109545. */
  109546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109547. }
  109548. }
  109549. declare module BABYLON {
  109550. /**
  109551. * Class containing static functions to help procedurally build meshes
  109552. */
  109553. export class HemisphereBuilder {
  109554. /**
  109555. * Creates a hemisphere mesh
  109556. * @param name defines the name of the mesh
  109557. * @param options defines the options used to create the mesh
  109558. * @param scene defines the hosting scene
  109559. * @returns the hemisphere mesh
  109560. */
  109561. static CreateHemisphere(name: string, options: {
  109562. segments?: number;
  109563. diameter?: number;
  109564. sideOrientation?: number;
  109565. }, scene: any): Mesh;
  109566. }
  109567. }
  109568. declare module BABYLON {
  109569. /**
  109570. * A spot light is defined by a position, a direction, an angle, and an exponent.
  109571. * These values define a cone of light starting from the position, emitting toward the direction.
  109572. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  109573. * and the exponent defines the speed of the decay of the light with distance (reach).
  109574. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109575. */
  109576. export class SpotLight extends ShadowLight {
  109577. private _angle;
  109578. private _innerAngle;
  109579. private _cosHalfAngle;
  109580. private _lightAngleScale;
  109581. private _lightAngleOffset;
  109582. /**
  109583. * Gets the cone angle of the spot light in Radians.
  109584. */
  109585. /**
  109586. * Sets the cone angle of the spot light in Radians.
  109587. */
  109588. angle: number;
  109589. /**
  109590. * Only used in gltf falloff mode, this defines the angle where
  109591. * the directional falloff will start before cutting at angle which could be seen
  109592. * as outer angle.
  109593. */
  109594. /**
  109595. * Only used in gltf falloff mode, this defines the angle where
  109596. * the directional falloff will start before cutting at angle which could be seen
  109597. * as outer angle.
  109598. */
  109599. innerAngle: number;
  109600. private _shadowAngleScale;
  109601. /**
  109602. * Allows scaling the angle of the light for shadow generation only.
  109603. */
  109604. /**
  109605. * Allows scaling the angle of the light for shadow generation only.
  109606. */
  109607. shadowAngleScale: number;
  109608. /**
  109609. * The light decay speed with the distance from the emission spot.
  109610. */
  109611. exponent: number;
  109612. private _projectionTextureMatrix;
  109613. /**
  109614. * Allows reading the projecton texture
  109615. */
  109616. readonly projectionTextureMatrix: Matrix;
  109617. protected _projectionTextureLightNear: number;
  109618. /**
  109619. * Gets the near clip of the Spotlight for texture projection.
  109620. */
  109621. /**
  109622. * Sets the near clip of the Spotlight for texture projection.
  109623. */
  109624. projectionTextureLightNear: number;
  109625. protected _projectionTextureLightFar: number;
  109626. /**
  109627. * Gets the far clip of the Spotlight for texture projection.
  109628. */
  109629. /**
  109630. * Sets the far clip of the Spotlight for texture projection.
  109631. */
  109632. projectionTextureLightFar: number;
  109633. protected _projectionTextureUpDirection: Vector3;
  109634. /**
  109635. * Gets the Up vector of the Spotlight for texture projection.
  109636. */
  109637. /**
  109638. * Sets the Up vector of the Spotlight for texture projection.
  109639. */
  109640. projectionTextureUpDirection: Vector3;
  109641. private _projectionTexture;
  109642. /**
  109643. * Gets the projection texture of the light.
  109644. */
  109645. /**
  109646. * Sets the projection texture of the light.
  109647. */
  109648. projectionTexture: Nullable<BaseTexture>;
  109649. private _projectionTextureViewLightDirty;
  109650. private _projectionTextureProjectionLightDirty;
  109651. private _projectionTextureDirty;
  109652. private _projectionTextureViewTargetVector;
  109653. private _projectionTextureViewLightMatrix;
  109654. private _projectionTextureProjectionLightMatrix;
  109655. private _projectionTextureScalingMatrix;
  109656. /**
  109657. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109658. * It can cast shadows.
  109659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109660. * @param name The light friendly name
  109661. * @param position The position of the spot light in the scene
  109662. * @param direction The direction of the light in the scene
  109663. * @param angle The cone angle of the light in Radians
  109664. * @param exponent The light decay speed with the distance from the emission spot
  109665. * @param scene The scene the lights belongs to
  109666. */
  109667. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109668. /**
  109669. * Returns the string "SpotLight".
  109670. * @returns the class name
  109671. */
  109672. getClassName(): string;
  109673. /**
  109674. * Returns the integer 2.
  109675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109676. */
  109677. getTypeID(): number;
  109678. /**
  109679. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109680. */
  109681. protected _setDirection(value: Vector3): void;
  109682. /**
  109683. * Overrides the position setter to recompute the projection texture view light Matrix.
  109684. */
  109685. protected _setPosition(value: Vector3): void;
  109686. /**
  109687. * 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.
  109688. * Returns the SpotLight.
  109689. */
  109690. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109691. protected _computeProjectionTextureViewLightMatrix(): void;
  109692. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109693. /**
  109694. * Main function for light texture projection matrix computing.
  109695. */
  109696. protected _computeProjectionTextureMatrix(): void;
  109697. protected _buildUniformLayout(): void;
  109698. private _computeAngleValues;
  109699. /**
  109700. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109701. * @param effect The effect to update
  109702. * @param lightIndex The index of the light in the effect to update
  109703. * @returns The spot light
  109704. */
  109705. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109706. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  109707. /**
  109708. * Disposes the light and the associated resources.
  109709. */
  109710. dispose(): void;
  109711. /**
  109712. * Prepares the list of defines specific to the light type.
  109713. * @param defines the list of defines
  109714. * @param lightIndex defines the index of the light for the effect
  109715. */
  109716. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109717. }
  109718. }
  109719. declare module BABYLON {
  109720. /**
  109721. * Gizmo that enables viewing a light
  109722. */
  109723. export class LightGizmo extends Gizmo {
  109724. private _lightMesh;
  109725. private _material;
  109726. private cachedPosition;
  109727. private cachedForward;
  109728. /**
  109729. * Creates a LightGizmo
  109730. * @param gizmoLayer The utility layer the gizmo will be added to
  109731. */
  109732. constructor(gizmoLayer?: UtilityLayerRenderer);
  109733. private _light;
  109734. /**
  109735. * The light that the gizmo is attached to
  109736. */
  109737. light: Nullable<Light>;
  109738. /**
  109739. * Gets the material used to render the light gizmo
  109740. */
  109741. readonly material: StandardMaterial;
  109742. /**
  109743. * @hidden
  109744. * Updates the gizmo to match the attached mesh's position/rotation
  109745. */
  109746. protected _update(): void;
  109747. private static _Scale;
  109748. /**
  109749. * Creates the lines for a light mesh
  109750. */
  109751. private static _createLightLines;
  109752. /**
  109753. * Disposes of the light gizmo
  109754. */
  109755. dispose(): void;
  109756. private static _CreateHemisphericLightMesh;
  109757. private static _CreatePointLightMesh;
  109758. private static _CreateSpotLightMesh;
  109759. private static _CreateDirectionalLightMesh;
  109760. }
  109761. }
  109762. declare module BABYLON {
  109763. /** @hidden */
  109764. export var backgroundFragmentDeclaration: {
  109765. name: string;
  109766. shader: string;
  109767. };
  109768. }
  109769. declare module BABYLON {
  109770. /** @hidden */
  109771. export var backgroundUboDeclaration: {
  109772. name: string;
  109773. shader: string;
  109774. };
  109775. }
  109776. declare module BABYLON {
  109777. /** @hidden */
  109778. export var backgroundPixelShader: {
  109779. name: string;
  109780. shader: string;
  109781. };
  109782. }
  109783. declare module BABYLON {
  109784. /** @hidden */
  109785. export var backgroundVertexDeclaration: {
  109786. name: string;
  109787. shader: string;
  109788. };
  109789. }
  109790. declare module BABYLON {
  109791. /** @hidden */
  109792. export var backgroundVertexShader: {
  109793. name: string;
  109794. shader: string;
  109795. };
  109796. }
  109797. declare module BABYLON {
  109798. /**
  109799. * Background material used to create an efficient environement around your scene.
  109800. */
  109801. export class BackgroundMaterial extends PushMaterial {
  109802. /**
  109803. * Standard reflectance value at parallel view angle.
  109804. */
  109805. static StandardReflectance0: number;
  109806. /**
  109807. * Standard reflectance value at grazing angle.
  109808. */
  109809. static StandardReflectance90: number;
  109810. protected _primaryColor: Color3;
  109811. /**
  109812. * Key light Color (multiply against the environement texture)
  109813. */
  109814. primaryColor: Color3;
  109815. protected __perceptualColor: Nullable<Color3>;
  109816. /**
  109817. * Experimental Internal Use Only.
  109818. *
  109819. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109820. * This acts as a helper to set the primary color to a more "human friendly" value.
  109821. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109822. * output color as close as possible from the chosen value.
  109823. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109824. * part of lighting setup.)
  109825. */
  109826. _perceptualColor: Nullable<Color3>;
  109827. protected _primaryColorShadowLevel: float;
  109828. /**
  109829. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109830. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109831. */
  109832. primaryColorShadowLevel: float;
  109833. protected _primaryColorHighlightLevel: float;
  109834. /**
  109835. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109836. * The primary color is used at the level chosen to define what the white area would look.
  109837. */
  109838. primaryColorHighlightLevel: float;
  109839. protected _reflectionTexture: Nullable<BaseTexture>;
  109840. /**
  109841. * Reflection Texture used in the material.
  109842. * Should be author in a specific way for the best result (refer to the documentation).
  109843. */
  109844. reflectionTexture: Nullable<BaseTexture>;
  109845. protected _reflectionBlur: float;
  109846. /**
  109847. * Reflection Texture level of blur.
  109848. *
  109849. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109850. * texture twice.
  109851. */
  109852. reflectionBlur: float;
  109853. protected _diffuseTexture: Nullable<BaseTexture>;
  109854. /**
  109855. * Diffuse Texture used in the material.
  109856. * Should be author in a specific way for the best result (refer to the documentation).
  109857. */
  109858. diffuseTexture: Nullable<BaseTexture>;
  109859. protected _shadowLights: Nullable<IShadowLight[]>;
  109860. /**
  109861. * Specify the list of lights casting shadow on the material.
  109862. * All scene shadow lights will be included if null.
  109863. */
  109864. shadowLights: Nullable<IShadowLight[]>;
  109865. protected _shadowLevel: float;
  109866. /**
  109867. * Helps adjusting the shadow to a softer level if required.
  109868. * 0 means black shadows and 1 means no shadows.
  109869. */
  109870. shadowLevel: float;
  109871. protected _sceneCenter: Vector3;
  109872. /**
  109873. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109874. * It is usually zero but might be interesting to modify according to your setup.
  109875. */
  109876. sceneCenter: Vector3;
  109877. protected _opacityFresnel: boolean;
  109878. /**
  109879. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109880. * This helps ensuring a nice transition when the camera goes under the ground.
  109881. */
  109882. opacityFresnel: boolean;
  109883. protected _reflectionFresnel: boolean;
  109884. /**
  109885. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109886. * This helps adding a mirror texture on the ground.
  109887. */
  109888. reflectionFresnel: boolean;
  109889. protected _reflectionFalloffDistance: number;
  109890. /**
  109891. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109892. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109893. */
  109894. reflectionFalloffDistance: number;
  109895. protected _reflectionAmount: number;
  109896. /**
  109897. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109898. */
  109899. reflectionAmount: number;
  109900. protected _reflectionReflectance0: number;
  109901. /**
  109902. * This specifies the weight of the reflection at grazing angle.
  109903. */
  109904. reflectionReflectance0: number;
  109905. protected _reflectionReflectance90: number;
  109906. /**
  109907. * This specifies the weight of the reflection at a perpendicular point of view.
  109908. */
  109909. reflectionReflectance90: number;
  109910. /**
  109911. * Sets the reflection reflectance fresnel values according to the default standard
  109912. * empirically know to work well :-)
  109913. */
  109914. reflectionStandardFresnelWeight: number;
  109915. protected _useRGBColor: boolean;
  109916. /**
  109917. * Helps to directly use the maps channels instead of their level.
  109918. */
  109919. useRGBColor: boolean;
  109920. protected _enableNoise: boolean;
  109921. /**
  109922. * This helps reducing the banding effect that could occur on the background.
  109923. */
  109924. enableNoise: boolean;
  109925. /**
  109926. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109927. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109928. * Recommended to be keep at 1.0 except for special cases.
  109929. */
  109930. fovMultiplier: number;
  109931. private _fovMultiplier;
  109932. /**
  109933. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109934. */
  109935. useEquirectangularFOV: boolean;
  109936. private _maxSimultaneousLights;
  109937. /**
  109938. * Number of Simultaneous lights allowed on the material.
  109939. */
  109940. maxSimultaneousLights: int;
  109941. /**
  109942. * Default configuration related to image processing available in the Background Material.
  109943. */
  109944. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109945. /**
  109946. * Keep track of the image processing observer to allow dispose and replace.
  109947. */
  109948. private _imageProcessingObserver;
  109949. /**
  109950. * Attaches a new image processing configuration to the PBR Material.
  109951. * @param configuration (if null the scene configuration will be use)
  109952. */
  109953. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109954. /**
  109955. * Gets the image processing configuration used either in this material.
  109956. */
  109957. /**
  109958. * Sets the Default image processing configuration used either in the this material.
  109959. *
  109960. * If sets to null, the scene one is in use.
  109961. */
  109962. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109963. /**
  109964. * Gets wether the color curves effect is enabled.
  109965. */
  109966. /**
  109967. * Sets wether the color curves effect is enabled.
  109968. */
  109969. cameraColorCurvesEnabled: boolean;
  109970. /**
  109971. * Gets wether the color grading effect is enabled.
  109972. */
  109973. /**
  109974. * Gets wether the color grading effect is enabled.
  109975. */
  109976. cameraColorGradingEnabled: boolean;
  109977. /**
  109978. * Gets wether tonemapping is enabled or not.
  109979. */
  109980. /**
  109981. * Sets wether tonemapping is enabled or not
  109982. */
  109983. cameraToneMappingEnabled: boolean;
  109984. /**
  109985. * The camera exposure used on this material.
  109986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109987. * This corresponds to a photographic exposure.
  109988. */
  109989. /**
  109990. * The camera exposure used on this material.
  109991. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109992. * This corresponds to a photographic exposure.
  109993. */
  109994. cameraExposure: float;
  109995. /**
  109996. * Gets The camera contrast used on this material.
  109997. */
  109998. /**
  109999. * Sets The camera contrast used on this material.
  110000. */
  110001. cameraContrast: float;
  110002. /**
  110003. * Gets the Color Grading 2D Lookup Texture.
  110004. */
  110005. /**
  110006. * Sets the Color Grading 2D Lookup Texture.
  110007. */
  110008. cameraColorGradingTexture: Nullable<BaseTexture>;
  110009. /**
  110010. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110011. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110012. * 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;
  110013. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110014. */
  110015. /**
  110016. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110017. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110018. * 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;
  110019. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110020. */
  110021. cameraColorCurves: Nullable<ColorCurves>;
  110022. /**
  110023. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  110024. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  110025. */
  110026. switchToBGR: boolean;
  110027. private _renderTargets;
  110028. private _reflectionControls;
  110029. private _white;
  110030. private _primaryShadowColor;
  110031. private _primaryHighlightColor;
  110032. /**
  110033. * Instantiates a Background Material in the given scene
  110034. * @param name The friendly name of the material
  110035. * @param scene The scene to add the material to
  110036. */
  110037. constructor(name: string, scene: Scene);
  110038. /**
  110039. * Gets a boolean indicating that current material needs to register RTT
  110040. */
  110041. readonly hasRenderTargetTextures: boolean;
  110042. /**
  110043. * The entire material has been created in order to prevent overdraw.
  110044. * @returns false
  110045. */
  110046. needAlphaTesting(): boolean;
  110047. /**
  110048. * The entire material has been created in order to prevent overdraw.
  110049. * @returns true if blending is enable
  110050. */
  110051. needAlphaBlending(): boolean;
  110052. /**
  110053. * Checks wether the material is ready to be rendered for a given mesh.
  110054. * @param mesh The mesh to render
  110055. * @param subMesh The submesh to check against
  110056. * @param useInstances Specify wether or not the material is used with instances
  110057. * @returns true if all the dependencies are ready (Textures, Effects...)
  110058. */
  110059. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110060. /**
  110061. * Compute the primary color according to the chosen perceptual color.
  110062. */
  110063. private _computePrimaryColorFromPerceptualColor;
  110064. /**
  110065. * Compute the highlights and shadow colors according to their chosen levels.
  110066. */
  110067. private _computePrimaryColors;
  110068. /**
  110069. * Build the uniform buffer used in the material.
  110070. */
  110071. buildUniformLayout(): void;
  110072. /**
  110073. * Unbind the material.
  110074. */
  110075. unbind(): void;
  110076. /**
  110077. * Bind only the world matrix to the material.
  110078. * @param world The world matrix to bind.
  110079. */
  110080. bindOnlyWorldMatrix(world: Matrix): void;
  110081. /**
  110082. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  110083. * @param world The world matrix to bind.
  110084. * @param subMesh The submesh to bind for.
  110085. */
  110086. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110087. /**
  110088. * Checks to see if a texture is used in the material.
  110089. * @param texture - Base texture to use.
  110090. * @returns - Boolean specifying if a texture is used in the material.
  110091. */
  110092. hasTexture(texture: BaseTexture): boolean;
  110093. /**
  110094. * Dispose the material.
  110095. * @param forceDisposeEffect Force disposal of the associated effect.
  110096. * @param forceDisposeTextures Force disposal of the associated textures.
  110097. */
  110098. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110099. /**
  110100. * Clones the material.
  110101. * @param name The cloned name.
  110102. * @returns The cloned material.
  110103. */
  110104. clone(name: string): BackgroundMaterial;
  110105. /**
  110106. * Serializes the current material to its JSON representation.
  110107. * @returns The JSON representation.
  110108. */
  110109. serialize(): any;
  110110. /**
  110111. * Gets the class name of the material
  110112. * @returns "BackgroundMaterial"
  110113. */
  110114. getClassName(): string;
  110115. /**
  110116. * Parse a JSON input to create back a background material.
  110117. * @param source The JSON data to parse
  110118. * @param scene The scene to create the parsed material in
  110119. * @param rootUrl The root url of the assets the material depends upon
  110120. * @returns the instantiated BackgroundMaterial.
  110121. */
  110122. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  110123. }
  110124. }
  110125. declare module BABYLON {
  110126. /**
  110127. * Represents the different options available during the creation of
  110128. * a Environment helper.
  110129. *
  110130. * This can control the default ground, skybox and image processing setup of your scene.
  110131. */
  110132. export interface IEnvironmentHelperOptions {
  110133. /**
  110134. * Specifies wether or not to create a ground.
  110135. * True by default.
  110136. */
  110137. createGround: boolean;
  110138. /**
  110139. * Specifies the ground size.
  110140. * 15 by default.
  110141. */
  110142. groundSize: number;
  110143. /**
  110144. * The texture used on the ground for the main color.
  110145. * Comes from the BabylonJS CDN by default.
  110146. *
  110147. * Remarks: Can be either a texture or a url.
  110148. */
  110149. groundTexture: string | BaseTexture;
  110150. /**
  110151. * The color mixed in the ground texture by default.
  110152. * BabylonJS clearColor by default.
  110153. */
  110154. groundColor: Color3;
  110155. /**
  110156. * Specifies the ground opacity.
  110157. * 1 by default.
  110158. */
  110159. groundOpacity: number;
  110160. /**
  110161. * Enables the ground to receive shadows.
  110162. * True by default.
  110163. */
  110164. enableGroundShadow: boolean;
  110165. /**
  110166. * Helps preventing the shadow to be fully black on the ground.
  110167. * 0.5 by default.
  110168. */
  110169. groundShadowLevel: number;
  110170. /**
  110171. * Creates a mirror texture attach to the ground.
  110172. * false by default.
  110173. */
  110174. enableGroundMirror: boolean;
  110175. /**
  110176. * Specifies the ground mirror size ratio.
  110177. * 0.3 by default as the default kernel is 64.
  110178. */
  110179. groundMirrorSizeRatio: number;
  110180. /**
  110181. * Specifies the ground mirror blur kernel size.
  110182. * 64 by default.
  110183. */
  110184. groundMirrorBlurKernel: number;
  110185. /**
  110186. * Specifies the ground mirror visibility amount.
  110187. * 1 by default
  110188. */
  110189. groundMirrorAmount: number;
  110190. /**
  110191. * Specifies the ground mirror reflectance weight.
  110192. * This uses the standard weight of the background material to setup the fresnel effect
  110193. * of the mirror.
  110194. * 1 by default.
  110195. */
  110196. groundMirrorFresnelWeight: number;
  110197. /**
  110198. * Specifies the ground mirror Falloff distance.
  110199. * This can helps reducing the size of the reflection.
  110200. * 0 by Default.
  110201. */
  110202. groundMirrorFallOffDistance: number;
  110203. /**
  110204. * Specifies the ground mirror texture type.
  110205. * Unsigned Int by Default.
  110206. */
  110207. groundMirrorTextureType: number;
  110208. /**
  110209. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  110210. * the shown objects.
  110211. */
  110212. groundYBias: number;
  110213. /**
  110214. * Specifies wether or not to create a skybox.
  110215. * True by default.
  110216. */
  110217. createSkybox: boolean;
  110218. /**
  110219. * Specifies the skybox size.
  110220. * 20 by default.
  110221. */
  110222. skyboxSize: number;
  110223. /**
  110224. * The texture used on the skybox for the main color.
  110225. * Comes from the BabylonJS CDN by default.
  110226. *
  110227. * Remarks: Can be either a texture or a url.
  110228. */
  110229. skyboxTexture: string | BaseTexture;
  110230. /**
  110231. * The color mixed in the skybox texture by default.
  110232. * BabylonJS clearColor by default.
  110233. */
  110234. skyboxColor: Color3;
  110235. /**
  110236. * The background rotation around the Y axis of the scene.
  110237. * This helps aligning the key lights of your scene with the background.
  110238. * 0 by default.
  110239. */
  110240. backgroundYRotation: number;
  110241. /**
  110242. * Compute automatically the size of the elements to best fit with the scene.
  110243. */
  110244. sizeAuto: boolean;
  110245. /**
  110246. * Default position of the rootMesh if autoSize is not true.
  110247. */
  110248. rootPosition: Vector3;
  110249. /**
  110250. * Sets up the image processing in the scene.
  110251. * true by default.
  110252. */
  110253. setupImageProcessing: boolean;
  110254. /**
  110255. * The texture used as your environment texture in the scene.
  110256. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  110257. *
  110258. * Remarks: Can be either a texture or a url.
  110259. */
  110260. environmentTexture: string | BaseTexture;
  110261. /**
  110262. * The value of the exposure to apply to the scene.
  110263. * 0.6 by default if setupImageProcessing is true.
  110264. */
  110265. cameraExposure: number;
  110266. /**
  110267. * The value of the contrast to apply to the scene.
  110268. * 1.6 by default if setupImageProcessing is true.
  110269. */
  110270. cameraContrast: number;
  110271. /**
  110272. * Specifies wether or not tonemapping should be enabled in the scene.
  110273. * true by default if setupImageProcessing is true.
  110274. */
  110275. toneMappingEnabled: boolean;
  110276. }
  110277. /**
  110278. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  110279. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  110280. * It also helps with the default setup of your imageProcessing configuration.
  110281. */
  110282. export class EnvironmentHelper {
  110283. /**
  110284. * Default ground texture URL.
  110285. */
  110286. private static _groundTextureCDNUrl;
  110287. /**
  110288. * Default skybox texture URL.
  110289. */
  110290. private static _skyboxTextureCDNUrl;
  110291. /**
  110292. * Default environment texture URL.
  110293. */
  110294. private static _environmentTextureCDNUrl;
  110295. /**
  110296. * Creates the default options for the helper.
  110297. */
  110298. private static _getDefaultOptions;
  110299. private _rootMesh;
  110300. /**
  110301. * Gets the root mesh created by the helper.
  110302. */
  110303. readonly rootMesh: Mesh;
  110304. private _skybox;
  110305. /**
  110306. * Gets the skybox created by the helper.
  110307. */
  110308. readonly skybox: Nullable<Mesh>;
  110309. private _skyboxTexture;
  110310. /**
  110311. * Gets the skybox texture created by the helper.
  110312. */
  110313. readonly skyboxTexture: Nullable<BaseTexture>;
  110314. private _skyboxMaterial;
  110315. /**
  110316. * Gets the skybox material created by the helper.
  110317. */
  110318. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  110319. private _ground;
  110320. /**
  110321. * Gets the ground mesh created by the helper.
  110322. */
  110323. readonly ground: Nullable<Mesh>;
  110324. private _groundTexture;
  110325. /**
  110326. * Gets the ground texture created by the helper.
  110327. */
  110328. readonly groundTexture: Nullable<BaseTexture>;
  110329. private _groundMirror;
  110330. /**
  110331. * Gets the ground mirror created by the helper.
  110332. */
  110333. readonly groundMirror: Nullable<MirrorTexture>;
  110334. /**
  110335. * Gets the ground mirror render list to helps pushing the meshes
  110336. * you wish in the ground reflection.
  110337. */
  110338. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  110339. private _groundMaterial;
  110340. /**
  110341. * Gets the ground material created by the helper.
  110342. */
  110343. readonly groundMaterial: Nullable<BackgroundMaterial>;
  110344. /**
  110345. * Stores the creation options.
  110346. */
  110347. private readonly _scene;
  110348. private _options;
  110349. /**
  110350. * This observable will be notified with any error during the creation of the environment,
  110351. * mainly texture creation errors.
  110352. */
  110353. onErrorObservable: Observable<{
  110354. message?: string;
  110355. exception?: any;
  110356. }>;
  110357. /**
  110358. * constructor
  110359. * @param options Defines the options we want to customize the helper
  110360. * @param scene The scene to add the material to
  110361. */
  110362. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  110363. /**
  110364. * Updates the background according to the new options
  110365. * @param options
  110366. */
  110367. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  110368. /**
  110369. * Sets the primary color of all the available elements.
  110370. * @param color the main color to affect to the ground and the background
  110371. */
  110372. setMainColor(color: Color3): void;
  110373. /**
  110374. * Setup the image processing according to the specified options.
  110375. */
  110376. private _setupImageProcessing;
  110377. /**
  110378. * Setup the environment texture according to the specified options.
  110379. */
  110380. private _setupEnvironmentTexture;
  110381. /**
  110382. * Setup the background according to the specified options.
  110383. */
  110384. private _setupBackground;
  110385. /**
  110386. * Get the scene sizes according to the setup.
  110387. */
  110388. private _getSceneSize;
  110389. /**
  110390. * Setup the ground according to the specified options.
  110391. */
  110392. private _setupGround;
  110393. /**
  110394. * Setup the ground material according to the specified options.
  110395. */
  110396. private _setupGroundMaterial;
  110397. /**
  110398. * Setup the ground diffuse texture according to the specified options.
  110399. */
  110400. private _setupGroundDiffuseTexture;
  110401. /**
  110402. * Setup the ground mirror texture according to the specified options.
  110403. */
  110404. private _setupGroundMirrorTexture;
  110405. /**
  110406. * Setup the ground to receive the mirror texture.
  110407. */
  110408. private _setupMirrorInGroundMaterial;
  110409. /**
  110410. * Setup the skybox according to the specified options.
  110411. */
  110412. private _setupSkybox;
  110413. /**
  110414. * Setup the skybox material according to the specified options.
  110415. */
  110416. private _setupSkyboxMaterial;
  110417. /**
  110418. * Setup the skybox reflection texture according to the specified options.
  110419. */
  110420. private _setupSkyboxReflectionTexture;
  110421. private _errorHandler;
  110422. /**
  110423. * Dispose all the elements created by the Helper.
  110424. */
  110425. dispose(): void;
  110426. }
  110427. }
  110428. declare module BABYLON {
  110429. /**
  110430. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  110431. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  110432. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  110433. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110434. */
  110435. export class PhotoDome extends TransformNode {
  110436. /**
  110437. * Define the image as a Monoscopic panoramic 360 image.
  110438. */
  110439. static readonly MODE_MONOSCOPIC: number;
  110440. /**
  110441. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110442. */
  110443. static readonly MODE_TOPBOTTOM: number;
  110444. /**
  110445. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110446. */
  110447. static readonly MODE_SIDEBYSIDE: number;
  110448. private _useDirectMapping;
  110449. /**
  110450. * The texture being displayed on the sphere
  110451. */
  110452. protected _photoTexture: Texture;
  110453. /**
  110454. * Gets or sets the texture being displayed on the sphere
  110455. */
  110456. photoTexture: Texture;
  110457. /**
  110458. * Observable raised when an error occured while loading the 360 image
  110459. */
  110460. onLoadErrorObservable: Observable<string>;
  110461. /**
  110462. * The skybox material
  110463. */
  110464. protected _material: BackgroundMaterial;
  110465. /**
  110466. * The surface used for the skybox
  110467. */
  110468. protected _mesh: Mesh;
  110469. /**
  110470. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110471. * Also see the options.resolution property.
  110472. */
  110473. fovMultiplier: number;
  110474. private _imageMode;
  110475. /**
  110476. * Gets or set the current video mode for the video. It can be:
  110477. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  110478. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110479. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110480. */
  110481. imageMode: number;
  110482. /**
  110483. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  110484. * @param name Element's name, child elements will append suffixes for their own names.
  110485. * @param urlsOfPhoto defines the url of the photo to display
  110486. * @param options defines an object containing optional or exposed sub element properties
  110487. * @param onError defines a callback called when an error occured while loading the texture
  110488. */
  110489. constructor(name: string, urlOfPhoto: string, options: {
  110490. resolution?: number;
  110491. size?: number;
  110492. useDirectMapping?: boolean;
  110493. faceForward?: boolean;
  110494. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  110495. private _onBeforeCameraRenderObserver;
  110496. private _changeImageMode;
  110497. /**
  110498. * Releases resources associated with this node.
  110499. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110500. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110501. */
  110502. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110503. }
  110504. }
  110505. declare module BABYLON {
  110506. /** @hidden */
  110507. export var rgbdDecodePixelShader: {
  110508. name: string;
  110509. shader: string;
  110510. };
  110511. }
  110512. declare module BABYLON {
  110513. /**
  110514. * Class used to host texture specific utilities
  110515. */
  110516. export class BRDFTextureTools {
  110517. /**
  110518. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  110519. * @param texture the texture to expand.
  110520. */
  110521. private static _ExpandDefaultBRDFTexture;
  110522. /**
  110523. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  110524. * @param scene defines the hosting scene
  110525. * @returns the environment BRDF texture
  110526. */
  110527. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  110528. private static _environmentBRDFBase64Texture;
  110529. }
  110530. }
  110531. declare module BABYLON {
  110532. /**
  110533. * @hidden
  110534. */
  110535. export interface IMaterialClearCoatDefines {
  110536. CLEARCOAT: boolean;
  110537. CLEARCOAT_DEFAULTIOR: boolean;
  110538. CLEARCOAT_TEXTURE: boolean;
  110539. CLEARCOAT_TEXTUREDIRECTUV: number;
  110540. CLEARCOAT_BUMP: boolean;
  110541. CLEARCOAT_BUMPDIRECTUV: number;
  110542. CLEARCOAT_TINT: boolean;
  110543. CLEARCOAT_TINT_TEXTURE: boolean;
  110544. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110545. /** @hidden */
  110546. _areTexturesDirty: boolean;
  110547. }
  110548. /**
  110549. * Define the code related to the clear coat parameters of the pbr material.
  110550. */
  110551. export class PBRClearCoatConfiguration {
  110552. /**
  110553. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110554. * The default fits with a polyurethane material.
  110555. */
  110556. private static readonly _DefaultIndexOfRefraction;
  110557. private _isEnabled;
  110558. /**
  110559. * Defines if the clear coat is enabled in the material.
  110560. */
  110561. isEnabled: boolean;
  110562. /**
  110563. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  110564. */
  110565. intensity: number;
  110566. /**
  110567. * Defines the clear coat layer roughness.
  110568. */
  110569. roughness: number;
  110570. private _indexOfRefraction;
  110571. /**
  110572. * Defines the index of refraction of the clear coat.
  110573. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110574. * The default fits with a polyurethane material.
  110575. * Changing the default value is more performance intensive.
  110576. */
  110577. indexOfRefraction: number;
  110578. private _texture;
  110579. /**
  110580. * Stores the clear coat values in a texture.
  110581. */
  110582. texture: Nullable<BaseTexture>;
  110583. private _bumpTexture;
  110584. /**
  110585. * Define the clear coat specific bump texture.
  110586. */
  110587. bumpTexture: Nullable<BaseTexture>;
  110588. private _isTintEnabled;
  110589. /**
  110590. * Defines if the clear coat tint is enabled in the material.
  110591. */
  110592. isTintEnabled: boolean;
  110593. /**
  110594. * Defines the clear coat tint of the material.
  110595. * This is only use if tint is enabled
  110596. */
  110597. tintColor: Color3;
  110598. /**
  110599. * Defines the distance at which the tint color should be found in the
  110600. * clear coat media.
  110601. * This is only use if tint is enabled
  110602. */
  110603. tintColorAtDistance: number;
  110604. /**
  110605. * Defines the clear coat layer thickness.
  110606. * This is only use if tint is enabled
  110607. */
  110608. tintThickness: number;
  110609. private _tintTexture;
  110610. /**
  110611. * Stores the clear tint values in a texture.
  110612. * rgb is tint
  110613. * a is a thickness factor
  110614. */
  110615. tintTexture: Nullable<BaseTexture>;
  110616. /** @hidden */
  110617. private _internalMarkAllSubMeshesAsTexturesDirty;
  110618. /** @hidden */
  110619. _markAllSubMeshesAsTexturesDirty(): void;
  110620. /**
  110621. * Instantiate a new istance of clear coat configuration.
  110622. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110623. */
  110624. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110625. /**
  110626. * Gets wehter the submesh is ready to be used or not.
  110627. * @param defines the list of "defines" to update.
  110628. * @param scene defines the scene the material belongs to.
  110629. * @param engine defines the engine the material belongs to.
  110630. * @param disableBumpMap defines wether the material disables bump or not.
  110631. * @returns - boolean indicating that the submesh is ready or not.
  110632. */
  110633. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110634. /**
  110635. * Checks to see if a texture is used in the material.
  110636. * @param defines the list of "defines" to update.
  110637. * @param scene defines the scene to the material belongs to.
  110638. */
  110639. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110640. /**
  110641. * Binds the material data.
  110642. * @param uniformBuffer defines the Uniform buffer to fill in.
  110643. * @param scene defines the scene the material belongs to.
  110644. * @param engine defines the engine the material belongs to.
  110645. * @param disableBumpMap defines wether the material disables bump or not.
  110646. * @param isFrozen defines wether the material is frozen or not.
  110647. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110648. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110649. */
  110650. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110651. /**
  110652. * Checks to see if a texture is used in the material.
  110653. * @param texture - Base texture to use.
  110654. * @returns - Boolean specifying if a texture is used in the material.
  110655. */
  110656. hasTexture(texture: BaseTexture): boolean;
  110657. /**
  110658. * Returns an array of the actively used textures.
  110659. * @param activeTextures Array of BaseTextures
  110660. */
  110661. getActiveTextures(activeTextures: BaseTexture[]): void;
  110662. /**
  110663. * Returns the animatable textures.
  110664. * @param animatables Array of animatable textures.
  110665. */
  110666. getAnimatables(animatables: IAnimatable[]): void;
  110667. /**
  110668. * Disposes the resources of the material.
  110669. * @param forceDisposeTextures - Forces the disposal of all textures.
  110670. */
  110671. dispose(forceDisposeTextures?: boolean): void;
  110672. /**
  110673. * Get the current class name of the texture useful for serialization or dynamic coding.
  110674. * @returns "PBRClearCoatConfiguration"
  110675. */
  110676. getClassName(): string;
  110677. /**
  110678. * Add fallbacks to the effect fallbacks list.
  110679. * @param defines defines the Base texture to use.
  110680. * @param fallbacks defines the current fallback list.
  110681. * @param currentRank defines the current fallback rank.
  110682. * @returns the new fallback rank.
  110683. */
  110684. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110685. /**
  110686. * Add the required uniforms to the current list.
  110687. * @param uniforms defines the current uniform list.
  110688. */
  110689. static AddUniforms(uniforms: string[]): void;
  110690. /**
  110691. * Add the required samplers to the current list.
  110692. * @param samplers defines the current sampler list.
  110693. */
  110694. static AddSamplers(samplers: string[]): void;
  110695. /**
  110696. * Add the required uniforms to the current buffer.
  110697. * @param uniformBuffer defines the current uniform buffer.
  110698. */
  110699. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110700. /**
  110701. * Makes a duplicate of the current configuration into another one.
  110702. * @param clearCoatConfiguration define the config where to copy the info
  110703. */
  110704. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110705. /**
  110706. * Serializes this clear coat configuration.
  110707. * @returns - An object with the serialized config.
  110708. */
  110709. serialize(): any;
  110710. /**
  110711. * Parses a anisotropy Configuration from a serialized object.
  110712. * @param source - Serialized object.
  110713. * @param scene Defines the scene we are parsing for
  110714. * @param rootUrl Defines the rootUrl to load from
  110715. */
  110716. parse(source: any, scene: Scene, rootUrl: string): void;
  110717. }
  110718. }
  110719. declare module BABYLON {
  110720. /**
  110721. * @hidden
  110722. */
  110723. export interface IMaterialAnisotropicDefines {
  110724. ANISOTROPIC: boolean;
  110725. ANISOTROPIC_TEXTURE: boolean;
  110726. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110727. MAINUV1: boolean;
  110728. _areTexturesDirty: boolean;
  110729. _needUVs: boolean;
  110730. }
  110731. /**
  110732. * Define the code related to the anisotropic parameters of the pbr material.
  110733. */
  110734. export class PBRAnisotropicConfiguration {
  110735. private _isEnabled;
  110736. /**
  110737. * Defines if the anisotropy is enabled in the material.
  110738. */
  110739. isEnabled: boolean;
  110740. /**
  110741. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110742. */
  110743. intensity: number;
  110744. /**
  110745. * Defines if the effect is along the tangents, bitangents or in between.
  110746. * By default, the effect is "strectching" the highlights along the tangents.
  110747. */
  110748. direction: Vector2;
  110749. private _texture;
  110750. /**
  110751. * Stores the anisotropy values in a texture.
  110752. * rg is direction (like normal from -1 to 1)
  110753. * b is a intensity
  110754. */
  110755. texture: Nullable<BaseTexture>;
  110756. /** @hidden */
  110757. private _internalMarkAllSubMeshesAsTexturesDirty;
  110758. /** @hidden */
  110759. _markAllSubMeshesAsTexturesDirty(): void;
  110760. /**
  110761. * Instantiate a new istance of anisotropy configuration.
  110762. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110763. */
  110764. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110765. /**
  110766. * Specifies that the submesh is ready to be used.
  110767. * @param defines the list of "defines" to update.
  110768. * @param scene defines the scene the material belongs to.
  110769. * @returns - boolean indicating that the submesh is ready or not.
  110770. */
  110771. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110772. /**
  110773. * Checks to see if a texture is used in the material.
  110774. * @param defines the list of "defines" to update.
  110775. * @param mesh the mesh we are preparing the defines for.
  110776. * @param scene defines the scene the material belongs to.
  110777. */
  110778. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110779. /**
  110780. * Binds the material data.
  110781. * @param uniformBuffer defines the Uniform buffer to fill in.
  110782. * @param scene defines the scene the material belongs to.
  110783. * @param isFrozen defines wether the material is frozen or not.
  110784. */
  110785. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110786. /**
  110787. * Checks to see if a texture is used in the material.
  110788. * @param texture - Base texture to use.
  110789. * @returns - Boolean specifying if a texture is used in the material.
  110790. */
  110791. hasTexture(texture: BaseTexture): boolean;
  110792. /**
  110793. * Returns an array of the actively used textures.
  110794. * @param activeTextures Array of BaseTextures
  110795. */
  110796. getActiveTextures(activeTextures: BaseTexture[]): void;
  110797. /**
  110798. * Returns the animatable textures.
  110799. * @param animatables Array of animatable textures.
  110800. */
  110801. getAnimatables(animatables: IAnimatable[]): void;
  110802. /**
  110803. * Disposes the resources of the material.
  110804. * @param forceDisposeTextures - Forces the disposal of all textures.
  110805. */
  110806. dispose(forceDisposeTextures?: boolean): void;
  110807. /**
  110808. * Get the current class name of the texture useful for serialization or dynamic coding.
  110809. * @returns "PBRAnisotropicConfiguration"
  110810. */
  110811. getClassName(): string;
  110812. /**
  110813. * Add fallbacks to the effect fallbacks list.
  110814. * @param defines defines the Base texture to use.
  110815. * @param fallbacks defines the current fallback list.
  110816. * @param currentRank defines the current fallback rank.
  110817. * @returns the new fallback rank.
  110818. */
  110819. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110820. /**
  110821. * Add the required uniforms to the current list.
  110822. * @param uniforms defines the current uniform list.
  110823. */
  110824. static AddUniforms(uniforms: string[]): void;
  110825. /**
  110826. * Add the required uniforms to the current buffer.
  110827. * @param uniformBuffer defines the current uniform buffer.
  110828. */
  110829. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110830. /**
  110831. * Add the required samplers to the current list.
  110832. * @param samplers defines the current sampler list.
  110833. */
  110834. static AddSamplers(samplers: string[]): void;
  110835. /**
  110836. * Makes a duplicate of the current configuration into another one.
  110837. * @param anisotropicConfiguration define the config where to copy the info
  110838. */
  110839. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110840. /**
  110841. * Serializes this anisotropy configuration.
  110842. * @returns - An object with the serialized config.
  110843. */
  110844. serialize(): any;
  110845. /**
  110846. * Parses a anisotropy Configuration from a serialized object.
  110847. * @param source - Serialized object.
  110848. * @param scene Defines the scene we are parsing for
  110849. * @param rootUrl Defines the rootUrl to load from
  110850. */
  110851. parse(source: any, scene: Scene, rootUrl: string): void;
  110852. }
  110853. }
  110854. declare module BABYLON {
  110855. /**
  110856. * @hidden
  110857. */
  110858. export interface IMaterialBRDFDefines {
  110859. BRDF_V_HEIGHT_CORRELATED: boolean;
  110860. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110861. SPHERICAL_HARMONICS: boolean;
  110862. /** @hidden */
  110863. _areMiscDirty: boolean;
  110864. }
  110865. /**
  110866. * Define the code related to the BRDF parameters of the pbr material.
  110867. */
  110868. export class PBRBRDFConfiguration {
  110869. /**
  110870. * Default value used for the energy conservation.
  110871. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110872. */
  110873. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110874. /**
  110875. * Default value used for the Smith Visibility Height Correlated mode.
  110876. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110877. */
  110878. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110879. /**
  110880. * Default value used for the IBL diffuse part.
  110881. * This can help switching back to the polynomials mode globally which is a tiny bit
  110882. * less GPU intensive at the drawback of a lower quality.
  110883. */
  110884. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110885. private _useEnergyConservation;
  110886. /**
  110887. * Defines if the material uses energy conservation.
  110888. */
  110889. useEnergyConservation: boolean;
  110890. private _useSmithVisibilityHeightCorrelated;
  110891. /**
  110892. * LEGACY Mode set to false
  110893. * Defines if the material uses height smith correlated visibility term.
  110894. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110895. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110896. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110897. * Not relying on height correlated will also disable energy conservation.
  110898. */
  110899. useSmithVisibilityHeightCorrelated: boolean;
  110900. private _useSphericalHarmonics;
  110901. /**
  110902. * LEGACY Mode set to false
  110903. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110904. * diffuse part of the IBL.
  110905. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110906. * to the ground truth.
  110907. */
  110908. useSphericalHarmonics: boolean;
  110909. /** @hidden */
  110910. private _internalMarkAllSubMeshesAsMiscDirty;
  110911. /** @hidden */
  110912. _markAllSubMeshesAsMiscDirty(): void;
  110913. /**
  110914. * Instantiate a new istance of clear coat configuration.
  110915. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110916. */
  110917. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110918. /**
  110919. * Checks to see if a texture is used in the material.
  110920. * @param defines the list of "defines" to update.
  110921. */
  110922. prepareDefines(defines: IMaterialBRDFDefines): void;
  110923. /**
  110924. * Get the current class name of the texture useful for serialization or dynamic coding.
  110925. * @returns "PBRClearCoatConfiguration"
  110926. */
  110927. getClassName(): string;
  110928. /**
  110929. * Makes a duplicate of the current configuration into another one.
  110930. * @param brdfConfiguration define the config where to copy the info
  110931. */
  110932. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110933. /**
  110934. * Serializes this BRDF configuration.
  110935. * @returns - An object with the serialized config.
  110936. */
  110937. serialize(): any;
  110938. /**
  110939. * Parses a anisotropy Configuration from a serialized object.
  110940. * @param source - Serialized object.
  110941. * @param scene Defines the scene we are parsing for
  110942. * @param rootUrl Defines the rootUrl to load from
  110943. */
  110944. parse(source: any, scene: Scene, rootUrl: string): void;
  110945. }
  110946. }
  110947. declare module BABYLON {
  110948. /**
  110949. * @hidden
  110950. */
  110951. export interface IMaterialSheenDefines {
  110952. SHEEN: boolean;
  110953. SHEEN_TEXTURE: boolean;
  110954. SHEEN_TEXTUREDIRECTUV: number;
  110955. SHEEN_LINKWITHALBEDO: boolean;
  110956. /** @hidden */
  110957. _areTexturesDirty: boolean;
  110958. }
  110959. /**
  110960. * Define the code related to the Sheen parameters of the pbr material.
  110961. */
  110962. export class PBRSheenConfiguration {
  110963. private _isEnabled;
  110964. /**
  110965. * Defines if the material uses sheen.
  110966. */
  110967. isEnabled: boolean;
  110968. private _linkSheenWithAlbedo;
  110969. /**
  110970. * Defines if the sheen is linked to the sheen color.
  110971. */
  110972. linkSheenWithAlbedo: boolean;
  110973. /**
  110974. * Defines the sheen intensity.
  110975. */
  110976. intensity: number;
  110977. /**
  110978. * Defines the sheen color.
  110979. */
  110980. color: Color3;
  110981. private _texture;
  110982. /**
  110983. * Stores the sheen tint values in a texture.
  110984. * rgb is tint
  110985. * a is a intensity
  110986. */
  110987. texture: Nullable<BaseTexture>;
  110988. /** @hidden */
  110989. private _internalMarkAllSubMeshesAsTexturesDirty;
  110990. /** @hidden */
  110991. _markAllSubMeshesAsTexturesDirty(): void;
  110992. /**
  110993. * Instantiate a new istance of clear coat configuration.
  110994. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110995. */
  110996. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110997. /**
  110998. * Specifies that the submesh is ready to be used.
  110999. * @param defines the list of "defines" to update.
  111000. * @param scene defines the scene the material belongs to.
  111001. * @returns - boolean indicating that the submesh is ready or not.
  111002. */
  111003. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  111004. /**
  111005. * Checks to see if a texture is used in the material.
  111006. * @param defines the list of "defines" to update.
  111007. * @param scene defines the scene the material belongs to.
  111008. */
  111009. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  111010. /**
  111011. * Binds the material data.
  111012. * @param uniformBuffer defines the Uniform buffer to fill in.
  111013. * @param scene defines the scene the material belongs to.
  111014. * @param isFrozen defines wether the material is frozen or not.
  111015. */
  111016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111017. /**
  111018. * Checks to see if a texture is used in the material.
  111019. * @param texture - Base texture to use.
  111020. * @returns - Boolean specifying if a texture is used in the material.
  111021. */
  111022. hasTexture(texture: BaseTexture): boolean;
  111023. /**
  111024. * Returns an array of the actively used textures.
  111025. * @param activeTextures Array of BaseTextures
  111026. */
  111027. getActiveTextures(activeTextures: BaseTexture[]): void;
  111028. /**
  111029. * Returns the animatable textures.
  111030. * @param animatables Array of animatable textures.
  111031. */
  111032. getAnimatables(animatables: IAnimatable[]): void;
  111033. /**
  111034. * Disposes the resources of the material.
  111035. * @param forceDisposeTextures - Forces the disposal of all textures.
  111036. */
  111037. dispose(forceDisposeTextures?: boolean): void;
  111038. /**
  111039. * Get the current class name of the texture useful for serialization or dynamic coding.
  111040. * @returns "PBRSheenConfiguration"
  111041. */
  111042. getClassName(): string;
  111043. /**
  111044. * Add fallbacks to the effect fallbacks list.
  111045. * @param defines defines the Base texture to use.
  111046. * @param fallbacks defines the current fallback list.
  111047. * @param currentRank defines the current fallback rank.
  111048. * @returns the new fallback rank.
  111049. */
  111050. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111051. /**
  111052. * Add the required uniforms to the current list.
  111053. * @param uniforms defines the current uniform list.
  111054. */
  111055. static AddUniforms(uniforms: string[]): void;
  111056. /**
  111057. * Add the required uniforms to the current buffer.
  111058. * @param uniformBuffer defines the current uniform buffer.
  111059. */
  111060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111061. /**
  111062. * Add the required samplers to the current list.
  111063. * @param samplers defines the current sampler list.
  111064. */
  111065. static AddSamplers(samplers: string[]): void;
  111066. /**
  111067. * Makes a duplicate of the current configuration into another one.
  111068. * @param sheenConfiguration define the config where to copy the info
  111069. */
  111070. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  111071. /**
  111072. * Serializes this BRDF configuration.
  111073. * @returns - An object with the serialized config.
  111074. */
  111075. serialize(): any;
  111076. /**
  111077. * Parses a anisotropy Configuration from a serialized object.
  111078. * @param source - Serialized object.
  111079. * @param scene Defines the scene we are parsing for
  111080. * @param rootUrl Defines the rootUrl to load from
  111081. */
  111082. parse(source: any, scene: Scene, rootUrl: string): void;
  111083. }
  111084. }
  111085. declare module BABYLON {
  111086. /**
  111087. * @hidden
  111088. */
  111089. export interface IMaterialSubSurfaceDefines {
  111090. SUBSURFACE: boolean;
  111091. SS_REFRACTION: boolean;
  111092. SS_TRANSLUCENCY: boolean;
  111093. SS_SCATERRING: boolean;
  111094. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111095. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111096. SS_REFRACTIONMAP_3D: boolean;
  111097. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111098. SS_LODINREFRACTIONALPHA: boolean;
  111099. SS_GAMMAREFRACTION: boolean;
  111100. SS_RGBDREFRACTION: boolean;
  111101. SS_LINEARSPECULARREFRACTION: boolean;
  111102. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111103. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111104. /** @hidden */
  111105. _areTexturesDirty: boolean;
  111106. }
  111107. /**
  111108. * Define the code related to the sub surface parameters of the pbr material.
  111109. */
  111110. export class PBRSubSurfaceConfiguration {
  111111. private _isRefractionEnabled;
  111112. /**
  111113. * Defines if the refraction is enabled in the material.
  111114. */
  111115. isRefractionEnabled: boolean;
  111116. private _isTranslucencyEnabled;
  111117. /**
  111118. * Defines if the translucency is enabled in the material.
  111119. */
  111120. isTranslucencyEnabled: boolean;
  111121. private _isScatteringEnabled;
  111122. /**
  111123. * Defines the refraction intensity of the material.
  111124. * The refraction when enabled replaces the Diffuse part of the material.
  111125. * The intensity helps transitionning between diffuse and refraction.
  111126. */
  111127. refractionIntensity: number;
  111128. /**
  111129. * Defines the translucency intensity of the material.
  111130. * When translucency has been enabled, this defines how much of the "translucency"
  111131. * is addded to the diffuse part of the material.
  111132. */
  111133. translucencyIntensity: number;
  111134. /**
  111135. * Defines the scattering intensity of the material.
  111136. * When scattering has been enabled, this defines how much of the "scattered light"
  111137. * is addded to the diffuse part of the material.
  111138. */
  111139. scatteringIntensity: number;
  111140. private _thicknessTexture;
  111141. /**
  111142. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  111143. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  111144. * 0 would mean minimumThickness
  111145. * 1 would mean maximumThickness
  111146. * The other channels might be use as a mask to vary the different effects intensity.
  111147. */
  111148. thicknessTexture: Nullable<BaseTexture>;
  111149. private _refractionTexture;
  111150. /**
  111151. * Defines the texture to use for refraction.
  111152. */
  111153. refractionTexture: Nullable<BaseTexture>;
  111154. private _indexOfRefraction;
  111155. /**
  111156. * Defines the index of refraction used in the material.
  111157. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  111158. */
  111159. indexOfRefraction: number;
  111160. private _invertRefractionY;
  111161. /**
  111162. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111163. */
  111164. invertRefractionY: boolean;
  111165. private _linkRefractionWithTransparency;
  111166. /**
  111167. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111168. * Materials half opaque for instance using refraction could benefit from this control.
  111169. */
  111170. linkRefractionWithTransparency: boolean;
  111171. /**
  111172. * Defines the minimum thickness stored in the thickness map.
  111173. * If no thickness map is defined, this value will be used to simulate thickness.
  111174. */
  111175. minimumThickness: number;
  111176. /**
  111177. * Defines the maximum thickness stored in the thickness map.
  111178. */
  111179. maximumThickness: number;
  111180. /**
  111181. * Defines the volume tint of the material.
  111182. * This is used for both translucency and scattering.
  111183. */
  111184. tintColor: Color3;
  111185. /**
  111186. * Defines the distance at which the tint color should be found in the media.
  111187. * This is used for refraction only.
  111188. */
  111189. tintColorAtDistance: number;
  111190. /**
  111191. * Defines how far each channel transmit through the media.
  111192. * It is defined as a color to simplify it selection.
  111193. */
  111194. diffusionDistance: Color3;
  111195. private _useMaskFromThicknessTexture;
  111196. /**
  111197. * Stores the intensity of the different subsurface effects in the thickness texture.
  111198. * * the green channel is the translucency intensity.
  111199. * * the blue channel is the scattering intensity.
  111200. * * the alpha channel is the refraction intensity.
  111201. */
  111202. useMaskFromThicknessTexture: boolean;
  111203. /** @hidden */
  111204. private _internalMarkAllSubMeshesAsTexturesDirty;
  111205. /** @hidden */
  111206. _markAllSubMeshesAsTexturesDirty(): void;
  111207. /**
  111208. * Instantiate a new istance of sub surface configuration.
  111209. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111210. */
  111211. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111212. /**
  111213. * Gets wehter the submesh is ready to be used or not.
  111214. * @param defines the list of "defines" to update.
  111215. * @param scene defines the scene the material belongs to.
  111216. * @returns - boolean indicating that the submesh is ready or not.
  111217. */
  111218. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  111219. /**
  111220. * Checks to see if a texture is used in the material.
  111221. * @param defines the list of "defines" to update.
  111222. * @param scene defines the scene to the material belongs to.
  111223. */
  111224. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  111225. /**
  111226. * Binds the material data.
  111227. * @param uniformBuffer defines the Uniform buffer to fill in.
  111228. * @param scene defines the scene the material belongs to.
  111229. * @param engine defines the engine the material belongs to.
  111230. * @param isFrozen defines wether the material is frozen or not.
  111231. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  111232. */
  111233. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  111234. /**
  111235. * Unbinds the material from the mesh.
  111236. * @param activeEffect defines the effect that should be unbound from.
  111237. * @returns true if unbound, otherwise false
  111238. */
  111239. unbind(activeEffect: Effect): boolean;
  111240. /**
  111241. * Returns the texture used for refraction or null if none is used.
  111242. * @param scene defines the scene the material belongs to.
  111243. * @returns - Refraction texture if present. If no refraction texture and refraction
  111244. * is linked with transparency, returns environment texture. Otherwise, returns null.
  111245. */
  111246. private _getRefractionTexture;
  111247. /**
  111248. * Returns true if alpha blending should be disabled.
  111249. */
  111250. readonly disableAlphaBlending: boolean;
  111251. /**
  111252. * Fills the list of render target textures.
  111253. * @param renderTargets the list of render targets to update
  111254. */
  111255. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  111256. /**
  111257. * Checks to see if a texture is used in the material.
  111258. * @param texture - Base texture to use.
  111259. * @returns - Boolean specifying if a texture is used in the material.
  111260. */
  111261. hasTexture(texture: BaseTexture): boolean;
  111262. /**
  111263. * Gets a boolean indicating that current material needs to register RTT
  111264. * @returns true if this uses a render target otherwise false.
  111265. */
  111266. hasRenderTargetTextures(): boolean;
  111267. /**
  111268. * Returns an array of the actively used textures.
  111269. * @param activeTextures Array of BaseTextures
  111270. */
  111271. getActiveTextures(activeTextures: BaseTexture[]): void;
  111272. /**
  111273. * Returns the animatable textures.
  111274. * @param animatables Array of animatable textures.
  111275. */
  111276. getAnimatables(animatables: IAnimatable[]): void;
  111277. /**
  111278. * Disposes the resources of the material.
  111279. * @param forceDisposeTextures - Forces the disposal of all textures.
  111280. */
  111281. dispose(forceDisposeTextures?: boolean): void;
  111282. /**
  111283. * Get the current class name of the texture useful for serialization or dynamic coding.
  111284. * @returns "PBRSubSurfaceConfiguration"
  111285. */
  111286. getClassName(): string;
  111287. /**
  111288. * Add fallbacks to the effect fallbacks list.
  111289. * @param defines defines the Base texture to use.
  111290. * @param fallbacks defines the current fallback list.
  111291. * @param currentRank defines the current fallback rank.
  111292. * @returns the new fallback rank.
  111293. */
  111294. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111295. /**
  111296. * Add the required uniforms to the current list.
  111297. * @param uniforms defines the current uniform list.
  111298. */
  111299. static AddUniforms(uniforms: string[]): void;
  111300. /**
  111301. * Add the required samplers to the current list.
  111302. * @param samplers defines the current sampler list.
  111303. */
  111304. static AddSamplers(samplers: string[]): void;
  111305. /**
  111306. * Add the required uniforms to the current buffer.
  111307. * @param uniformBuffer defines the current uniform buffer.
  111308. */
  111309. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111310. /**
  111311. * Makes a duplicate of the current configuration into another one.
  111312. * @param configuration define the config where to copy the info
  111313. */
  111314. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  111315. /**
  111316. * Serializes this Sub Surface configuration.
  111317. * @returns - An object with the serialized config.
  111318. */
  111319. serialize(): any;
  111320. /**
  111321. * Parses a anisotropy Configuration from a serialized object.
  111322. * @param source - Serialized object.
  111323. * @param scene Defines the scene we are parsing for
  111324. * @param rootUrl Defines the rootUrl to load from
  111325. */
  111326. parse(source: any, scene: Scene, rootUrl: string): void;
  111327. }
  111328. }
  111329. declare module BABYLON {
  111330. /** @hidden */
  111331. export var pbrFragmentDeclaration: {
  111332. name: string;
  111333. shader: string;
  111334. };
  111335. }
  111336. declare module BABYLON {
  111337. /** @hidden */
  111338. export var pbrUboDeclaration: {
  111339. name: string;
  111340. shader: string;
  111341. };
  111342. }
  111343. declare module BABYLON {
  111344. /** @hidden */
  111345. export var pbrFragmentExtraDeclaration: {
  111346. name: string;
  111347. shader: string;
  111348. };
  111349. }
  111350. declare module BABYLON {
  111351. /** @hidden */
  111352. export var pbrFragmentSamplersDeclaration: {
  111353. name: string;
  111354. shader: string;
  111355. };
  111356. }
  111357. declare module BABYLON {
  111358. /** @hidden */
  111359. export var pbrHelperFunctions: {
  111360. name: string;
  111361. shader: string;
  111362. };
  111363. }
  111364. declare module BABYLON {
  111365. /** @hidden */
  111366. export var harmonicsFunctions: {
  111367. name: string;
  111368. shader: string;
  111369. };
  111370. }
  111371. declare module BABYLON {
  111372. /** @hidden */
  111373. export var pbrDirectLightingSetupFunctions: {
  111374. name: string;
  111375. shader: string;
  111376. };
  111377. }
  111378. declare module BABYLON {
  111379. /** @hidden */
  111380. export var pbrDirectLightingFalloffFunctions: {
  111381. name: string;
  111382. shader: string;
  111383. };
  111384. }
  111385. declare module BABYLON {
  111386. /** @hidden */
  111387. export var pbrBRDFFunctions: {
  111388. name: string;
  111389. shader: string;
  111390. };
  111391. }
  111392. declare module BABYLON {
  111393. /** @hidden */
  111394. export var pbrDirectLightingFunctions: {
  111395. name: string;
  111396. shader: string;
  111397. };
  111398. }
  111399. declare module BABYLON {
  111400. /** @hidden */
  111401. export var pbrIBLFunctions: {
  111402. name: string;
  111403. shader: string;
  111404. };
  111405. }
  111406. declare module BABYLON {
  111407. /** @hidden */
  111408. export var pbrDebug: {
  111409. name: string;
  111410. shader: string;
  111411. };
  111412. }
  111413. declare module BABYLON {
  111414. /** @hidden */
  111415. export var pbrPixelShader: {
  111416. name: string;
  111417. shader: string;
  111418. };
  111419. }
  111420. declare module BABYLON {
  111421. /** @hidden */
  111422. export var pbrVertexDeclaration: {
  111423. name: string;
  111424. shader: string;
  111425. };
  111426. }
  111427. declare module BABYLON {
  111428. /** @hidden */
  111429. export var pbrVertexShader: {
  111430. name: string;
  111431. shader: string;
  111432. };
  111433. }
  111434. declare module BABYLON {
  111435. /**
  111436. * Manages the defines for the PBR Material.
  111437. * @hidden
  111438. */
  111439. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  111440. PBR: boolean;
  111441. MAINUV1: boolean;
  111442. MAINUV2: boolean;
  111443. UV1: boolean;
  111444. UV2: boolean;
  111445. ALBEDO: boolean;
  111446. ALBEDODIRECTUV: number;
  111447. VERTEXCOLOR: boolean;
  111448. AMBIENT: boolean;
  111449. AMBIENTDIRECTUV: number;
  111450. AMBIENTINGRAYSCALE: boolean;
  111451. OPACITY: boolean;
  111452. VERTEXALPHA: boolean;
  111453. OPACITYDIRECTUV: number;
  111454. OPACITYRGB: boolean;
  111455. ALPHATEST: boolean;
  111456. DEPTHPREPASS: boolean;
  111457. ALPHABLEND: boolean;
  111458. ALPHAFROMALBEDO: boolean;
  111459. ALPHATESTVALUE: string;
  111460. SPECULAROVERALPHA: boolean;
  111461. RADIANCEOVERALPHA: boolean;
  111462. ALPHAFRESNEL: boolean;
  111463. LINEARALPHAFRESNEL: boolean;
  111464. PREMULTIPLYALPHA: boolean;
  111465. EMISSIVE: boolean;
  111466. EMISSIVEDIRECTUV: number;
  111467. REFLECTIVITY: boolean;
  111468. REFLECTIVITYDIRECTUV: number;
  111469. SPECULARTERM: boolean;
  111470. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  111471. MICROSURFACEAUTOMATIC: boolean;
  111472. LODBASEDMICROSFURACE: boolean;
  111473. MICROSURFACEMAP: boolean;
  111474. MICROSURFACEMAPDIRECTUV: number;
  111475. METALLICWORKFLOW: boolean;
  111476. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  111477. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  111478. METALLNESSSTOREINMETALMAPBLUE: boolean;
  111479. AOSTOREINMETALMAPRED: boolean;
  111480. ENVIRONMENTBRDF: boolean;
  111481. ENVIRONMENTBRDF_RGBD: boolean;
  111482. NORMAL: boolean;
  111483. TANGENT: boolean;
  111484. BUMP: boolean;
  111485. BUMPDIRECTUV: number;
  111486. OBJECTSPACE_NORMALMAP: boolean;
  111487. PARALLAX: boolean;
  111488. PARALLAXOCCLUSION: boolean;
  111489. NORMALXYSCALE: boolean;
  111490. LIGHTMAP: boolean;
  111491. LIGHTMAPDIRECTUV: number;
  111492. USELIGHTMAPASSHADOWMAP: boolean;
  111493. GAMMALIGHTMAP: boolean;
  111494. REFLECTION: boolean;
  111495. REFLECTIONMAP_3D: boolean;
  111496. REFLECTIONMAP_SPHERICAL: boolean;
  111497. REFLECTIONMAP_PLANAR: boolean;
  111498. REFLECTIONMAP_CUBIC: boolean;
  111499. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111500. REFLECTIONMAP_PROJECTION: boolean;
  111501. REFLECTIONMAP_SKYBOX: boolean;
  111502. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  111503. REFLECTIONMAP_EXPLICIT: boolean;
  111504. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111505. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111506. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111507. INVERTCUBICMAP: boolean;
  111508. USESPHERICALFROMREFLECTIONMAP: boolean;
  111509. USEIRRADIANCEMAP: boolean;
  111510. SPHERICAL_HARMONICS: boolean;
  111511. USESPHERICALINVERTEX: boolean;
  111512. REFLECTIONMAP_OPPOSITEZ: boolean;
  111513. LODINREFLECTIONALPHA: boolean;
  111514. GAMMAREFLECTION: boolean;
  111515. RGBDREFLECTION: boolean;
  111516. LINEARSPECULARREFLECTION: boolean;
  111517. RADIANCEOCCLUSION: boolean;
  111518. HORIZONOCCLUSION: boolean;
  111519. INSTANCES: boolean;
  111520. NUM_BONE_INFLUENCERS: number;
  111521. BonesPerMesh: number;
  111522. BONETEXTURE: boolean;
  111523. NONUNIFORMSCALING: boolean;
  111524. MORPHTARGETS: boolean;
  111525. MORPHTARGETS_NORMAL: boolean;
  111526. MORPHTARGETS_TANGENT: boolean;
  111527. MORPHTARGETS_UV: boolean;
  111528. NUM_MORPH_INFLUENCERS: number;
  111529. IMAGEPROCESSING: boolean;
  111530. VIGNETTE: boolean;
  111531. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111532. VIGNETTEBLENDMODEOPAQUE: boolean;
  111533. TONEMAPPING: boolean;
  111534. TONEMAPPING_ACES: boolean;
  111535. CONTRAST: boolean;
  111536. COLORCURVES: boolean;
  111537. COLORGRADING: boolean;
  111538. COLORGRADING3D: boolean;
  111539. SAMPLER3DGREENDEPTH: boolean;
  111540. SAMPLER3DBGRMAP: boolean;
  111541. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111542. EXPOSURE: boolean;
  111543. MULTIVIEW: boolean;
  111544. USEPHYSICALLIGHTFALLOFF: boolean;
  111545. USEGLTFLIGHTFALLOFF: boolean;
  111546. TWOSIDEDLIGHTING: boolean;
  111547. SHADOWFLOAT: boolean;
  111548. CLIPPLANE: boolean;
  111549. CLIPPLANE2: boolean;
  111550. CLIPPLANE3: boolean;
  111551. CLIPPLANE4: boolean;
  111552. POINTSIZE: boolean;
  111553. FOG: boolean;
  111554. LOGARITHMICDEPTH: boolean;
  111555. FORCENORMALFORWARD: boolean;
  111556. SPECULARAA: boolean;
  111557. CLEARCOAT: boolean;
  111558. CLEARCOAT_DEFAULTIOR: boolean;
  111559. CLEARCOAT_TEXTURE: boolean;
  111560. CLEARCOAT_TEXTUREDIRECTUV: number;
  111561. CLEARCOAT_BUMP: boolean;
  111562. CLEARCOAT_BUMPDIRECTUV: number;
  111563. CLEARCOAT_TINT: boolean;
  111564. CLEARCOAT_TINT_TEXTURE: boolean;
  111565. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111566. ANISOTROPIC: boolean;
  111567. ANISOTROPIC_TEXTURE: boolean;
  111568. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111569. BRDF_V_HEIGHT_CORRELATED: boolean;
  111570. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111571. SHEEN: boolean;
  111572. SHEEN_TEXTURE: boolean;
  111573. SHEEN_TEXTUREDIRECTUV: number;
  111574. SHEEN_LINKWITHALBEDO: boolean;
  111575. SUBSURFACE: boolean;
  111576. SS_REFRACTION: boolean;
  111577. SS_TRANSLUCENCY: boolean;
  111578. SS_SCATERRING: boolean;
  111579. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111580. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111581. SS_REFRACTIONMAP_3D: boolean;
  111582. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111583. SS_LODINREFRACTIONALPHA: boolean;
  111584. SS_GAMMAREFRACTION: boolean;
  111585. SS_RGBDREFRACTION: boolean;
  111586. SS_LINEARSPECULARREFRACTION: boolean;
  111587. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111588. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111589. UNLIT: boolean;
  111590. DEBUGMODE: number;
  111591. /**
  111592. * Initializes the PBR Material defines.
  111593. */
  111594. constructor();
  111595. /**
  111596. * Resets the PBR Material defines.
  111597. */
  111598. reset(): void;
  111599. }
  111600. /**
  111601. * The Physically based material base class of BJS.
  111602. *
  111603. * This offers the main features of a standard PBR material.
  111604. * For more information, please refer to the documentation :
  111605. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111606. */
  111607. export abstract class PBRBaseMaterial extends PushMaterial {
  111608. /**
  111609. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111610. */
  111611. static readonly PBRMATERIAL_OPAQUE: number;
  111612. /**
  111613. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111614. */
  111615. static readonly PBRMATERIAL_ALPHATEST: number;
  111616. /**
  111617. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111618. */
  111619. static readonly PBRMATERIAL_ALPHABLEND: number;
  111620. /**
  111621. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111622. * They are also discarded below the alpha cutoff threshold to improve performances.
  111623. */
  111624. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111625. /**
  111626. * Defines the default value of how much AO map is occluding the analytical lights
  111627. * (point spot...).
  111628. */
  111629. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111630. /**
  111631. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111632. */
  111633. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111634. /**
  111635. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111636. * to enhance interoperability with other engines.
  111637. */
  111638. static readonly LIGHTFALLOFF_GLTF: number;
  111639. /**
  111640. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111641. * to enhance interoperability with other materials.
  111642. */
  111643. static readonly LIGHTFALLOFF_STANDARD: number;
  111644. /**
  111645. * Intensity of the direct lights e.g. the four lights available in your scene.
  111646. * This impacts both the direct diffuse and specular highlights.
  111647. */
  111648. protected _directIntensity: number;
  111649. /**
  111650. * Intensity of the emissive part of the material.
  111651. * This helps controlling the emissive effect without modifying the emissive color.
  111652. */
  111653. protected _emissiveIntensity: number;
  111654. /**
  111655. * Intensity of the environment e.g. how much the environment will light the object
  111656. * either through harmonics for rough material or through the refelction for shiny ones.
  111657. */
  111658. protected _environmentIntensity: number;
  111659. /**
  111660. * This is a special control allowing the reduction of the specular highlights coming from the
  111661. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111662. */
  111663. protected _specularIntensity: number;
  111664. /**
  111665. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111666. */
  111667. private _lightingInfos;
  111668. /**
  111669. * Debug Control allowing disabling the bump map on this material.
  111670. */
  111671. protected _disableBumpMap: boolean;
  111672. /**
  111673. * AKA Diffuse Texture in standard nomenclature.
  111674. */
  111675. protected _albedoTexture: Nullable<BaseTexture>;
  111676. /**
  111677. * AKA Occlusion Texture in other nomenclature.
  111678. */
  111679. protected _ambientTexture: Nullable<BaseTexture>;
  111680. /**
  111681. * AKA Occlusion Texture Intensity in other nomenclature.
  111682. */
  111683. protected _ambientTextureStrength: number;
  111684. /**
  111685. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111686. * 1 means it completely occludes it
  111687. * 0 mean it has no impact
  111688. */
  111689. protected _ambientTextureImpactOnAnalyticalLights: number;
  111690. /**
  111691. * Stores the alpha values in a texture.
  111692. */
  111693. protected _opacityTexture: Nullable<BaseTexture>;
  111694. /**
  111695. * Stores the reflection values in a texture.
  111696. */
  111697. protected _reflectionTexture: Nullable<BaseTexture>;
  111698. /**
  111699. * Stores the emissive values in a texture.
  111700. */
  111701. protected _emissiveTexture: Nullable<BaseTexture>;
  111702. /**
  111703. * AKA Specular texture in other nomenclature.
  111704. */
  111705. protected _reflectivityTexture: Nullable<BaseTexture>;
  111706. /**
  111707. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111708. */
  111709. protected _metallicTexture: Nullable<BaseTexture>;
  111710. /**
  111711. * Specifies the metallic scalar of the metallic/roughness workflow.
  111712. * Can also be used to scale the metalness values of the metallic texture.
  111713. */
  111714. protected _metallic: Nullable<number>;
  111715. /**
  111716. * Specifies the roughness scalar of the metallic/roughness workflow.
  111717. * Can also be used to scale the roughness values of the metallic texture.
  111718. */
  111719. protected _roughness: Nullable<number>;
  111720. /**
  111721. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111722. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111723. */
  111724. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111725. /**
  111726. * Stores surface normal data used to displace a mesh in a texture.
  111727. */
  111728. protected _bumpTexture: Nullable<BaseTexture>;
  111729. /**
  111730. * Stores the pre-calculated light information of a mesh in a texture.
  111731. */
  111732. protected _lightmapTexture: Nullable<BaseTexture>;
  111733. /**
  111734. * The color of a material in ambient lighting.
  111735. */
  111736. protected _ambientColor: Color3;
  111737. /**
  111738. * AKA Diffuse Color in other nomenclature.
  111739. */
  111740. protected _albedoColor: Color3;
  111741. /**
  111742. * AKA Specular Color in other nomenclature.
  111743. */
  111744. protected _reflectivityColor: Color3;
  111745. /**
  111746. * The color applied when light is reflected from a material.
  111747. */
  111748. protected _reflectionColor: Color3;
  111749. /**
  111750. * The color applied when light is emitted from a material.
  111751. */
  111752. protected _emissiveColor: Color3;
  111753. /**
  111754. * AKA Glossiness in other nomenclature.
  111755. */
  111756. protected _microSurface: number;
  111757. /**
  111758. * Specifies that the material will use the light map as a show map.
  111759. */
  111760. protected _useLightmapAsShadowmap: boolean;
  111761. /**
  111762. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111763. * makes the reflect vector face the model (under horizon).
  111764. */
  111765. protected _useHorizonOcclusion: boolean;
  111766. /**
  111767. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111768. * too much the area relying on ambient texture to define their ambient occlusion.
  111769. */
  111770. protected _useRadianceOcclusion: boolean;
  111771. /**
  111772. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111773. */
  111774. protected _useAlphaFromAlbedoTexture: boolean;
  111775. /**
  111776. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111777. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111778. */
  111779. protected _useSpecularOverAlpha: boolean;
  111780. /**
  111781. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111782. */
  111783. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111784. /**
  111785. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111786. */
  111787. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111788. /**
  111789. * Specifies if the metallic texture contains the roughness information in its green channel.
  111790. */
  111791. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111792. /**
  111793. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111794. */
  111795. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111796. /**
  111797. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111798. */
  111799. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111800. /**
  111801. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111802. */
  111803. protected _useAmbientInGrayScale: boolean;
  111804. /**
  111805. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111806. * The material will try to infer what glossiness each pixel should be.
  111807. */
  111808. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111809. /**
  111810. * Defines the falloff type used in this material.
  111811. * It by default is Physical.
  111812. */
  111813. protected _lightFalloff: number;
  111814. /**
  111815. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111816. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111817. */
  111818. protected _useRadianceOverAlpha: boolean;
  111819. /**
  111820. * Allows using an object space normal map (instead of tangent space).
  111821. */
  111822. protected _useObjectSpaceNormalMap: boolean;
  111823. /**
  111824. * Allows using the bump map in parallax mode.
  111825. */
  111826. protected _useParallax: boolean;
  111827. /**
  111828. * Allows using the bump map in parallax occlusion mode.
  111829. */
  111830. protected _useParallaxOcclusion: boolean;
  111831. /**
  111832. * Controls the scale bias of the parallax mode.
  111833. */
  111834. protected _parallaxScaleBias: number;
  111835. /**
  111836. * If sets to true, disables all the lights affecting the material.
  111837. */
  111838. protected _disableLighting: boolean;
  111839. /**
  111840. * Number of Simultaneous lights allowed on the material.
  111841. */
  111842. protected _maxSimultaneousLights: number;
  111843. /**
  111844. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111845. */
  111846. protected _invertNormalMapX: boolean;
  111847. /**
  111848. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111849. */
  111850. protected _invertNormalMapY: boolean;
  111851. /**
  111852. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111853. */
  111854. protected _twoSidedLighting: boolean;
  111855. /**
  111856. * Defines the alpha limits in alpha test mode.
  111857. */
  111858. protected _alphaCutOff: number;
  111859. /**
  111860. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111861. */
  111862. protected _forceAlphaTest: boolean;
  111863. /**
  111864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111865. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111866. */
  111867. protected _useAlphaFresnel: boolean;
  111868. /**
  111869. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111870. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111871. */
  111872. protected _useLinearAlphaFresnel: boolean;
  111873. /**
  111874. * The transparency mode of the material.
  111875. */
  111876. protected _transparencyMode: Nullable<number>;
  111877. /**
  111878. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111879. * from cos thetav and roughness:
  111880. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111881. */
  111882. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111883. /**
  111884. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111885. */
  111886. protected _forceIrradianceInFragment: boolean;
  111887. /**
  111888. * Force normal to face away from face.
  111889. */
  111890. protected _forceNormalForward: boolean;
  111891. /**
  111892. * Enables specular anti aliasing in the PBR shader.
  111893. * It will both interacts on the Geometry for analytical and IBL lighting.
  111894. * It also prefilter the roughness map based on the bump values.
  111895. */
  111896. protected _enableSpecularAntiAliasing: boolean;
  111897. /**
  111898. * Default configuration related to image processing available in the PBR Material.
  111899. */
  111900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111901. /**
  111902. * Keep track of the image processing observer to allow dispose and replace.
  111903. */
  111904. private _imageProcessingObserver;
  111905. /**
  111906. * Attaches a new image processing configuration to the PBR Material.
  111907. * @param configuration
  111908. */
  111909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111910. /**
  111911. * Stores the available render targets.
  111912. */
  111913. private _renderTargets;
  111914. /**
  111915. * Sets the global ambient color for the material used in lighting calculations.
  111916. */
  111917. private _globalAmbientColor;
  111918. /**
  111919. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111920. */
  111921. private _useLogarithmicDepth;
  111922. /**
  111923. * If set to true, no lighting calculations will be applied.
  111924. */
  111925. private _unlit;
  111926. private _debugMode;
  111927. /**
  111928. * @hidden
  111929. * This is reserved for the inspector.
  111930. * Defines the material debug mode.
  111931. * It helps seeing only some components of the material while troubleshooting.
  111932. */
  111933. debugMode: number;
  111934. /**
  111935. * @hidden
  111936. * This is reserved for the inspector.
  111937. * Specify from where on screen the debug mode should start.
  111938. * The value goes from -1 (full screen) to 1 (not visible)
  111939. * It helps with side by side comparison against the final render
  111940. * This defaults to -1
  111941. */
  111942. private debugLimit;
  111943. /**
  111944. * @hidden
  111945. * This is reserved for the inspector.
  111946. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111947. * You can use the factor to better multiply the final value.
  111948. */
  111949. private debugFactor;
  111950. /**
  111951. * Defines the clear coat layer parameters for the material.
  111952. */
  111953. readonly clearCoat: PBRClearCoatConfiguration;
  111954. /**
  111955. * Defines the anisotropic parameters for the material.
  111956. */
  111957. readonly anisotropy: PBRAnisotropicConfiguration;
  111958. /**
  111959. * Defines the BRDF parameters for the material.
  111960. */
  111961. readonly brdf: PBRBRDFConfiguration;
  111962. /**
  111963. * Defines the Sheen parameters for the material.
  111964. */
  111965. readonly sheen: PBRSheenConfiguration;
  111966. /**
  111967. * Defines the SubSurface parameters for the material.
  111968. */
  111969. readonly subSurface: PBRSubSurfaceConfiguration;
  111970. /**
  111971. * Custom callback helping to override the default shader used in the material.
  111972. */
  111973. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111974. protected _rebuildInParallel: boolean;
  111975. /**
  111976. * Instantiates a new PBRMaterial instance.
  111977. *
  111978. * @param name The material name
  111979. * @param scene The scene the material will be use in.
  111980. */
  111981. constructor(name: string, scene: Scene);
  111982. /**
  111983. * Gets a boolean indicating that current material needs to register RTT
  111984. */
  111985. readonly hasRenderTargetTextures: boolean;
  111986. /**
  111987. * Gets the name of the material class.
  111988. */
  111989. getClassName(): string;
  111990. /**
  111991. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111992. */
  111993. /**
  111994. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111995. */
  111996. useLogarithmicDepth: boolean;
  111997. /**
  111998. * Gets the current transparency mode.
  111999. */
  112000. /**
  112001. * Sets the transparency mode of the material.
  112002. *
  112003. * | Value | Type | Description |
  112004. * | ----- | ----------------------------------- | ----------- |
  112005. * | 0 | OPAQUE | |
  112006. * | 1 | ALPHATEST | |
  112007. * | 2 | ALPHABLEND | |
  112008. * | 3 | ALPHATESTANDBLEND | |
  112009. *
  112010. */
  112011. transparencyMode: Nullable<number>;
  112012. /**
  112013. * Returns true if alpha blending should be disabled.
  112014. */
  112015. private readonly _disableAlphaBlending;
  112016. /**
  112017. * Specifies whether or not this material should be rendered in alpha blend mode.
  112018. */
  112019. needAlphaBlending(): boolean;
  112020. /**
  112021. * Specifies if the mesh will require alpha blending.
  112022. * @param mesh - BJS mesh.
  112023. */
  112024. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  112025. /**
  112026. * Specifies whether or not this material should be rendered in alpha test mode.
  112027. */
  112028. needAlphaTesting(): boolean;
  112029. /**
  112030. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  112031. */
  112032. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  112033. /**
  112034. * Gets the texture used for the alpha test.
  112035. */
  112036. getAlphaTestTexture(): Nullable<BaseTexture>;
  112037. /**
  112038. * Specifies that the submesh is ready to be used.
  112039. * @param mesh - BJS mesh.
  112040. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  112041. * @param useInstances - Specifies that instances should be used.
  112042. * @returns - boolean indicating that the submesh is ready or not.
  112043. */
  112044. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112045. /**
  112046. * Specifies if the material uses metallic roughness workflow.
  112047. * @returns boolean specifiying if the material uses metallic roughness workflow.
  112048. */
  112049. isMetallicWorkflow(): boolean;
  112050. private _prepareEffect;
  112051. private _prepareDefines;
  112052. /**
  112053. * Force shader compilation
  112054. */
  112055. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  112056. clipPlane: boolean;
  112057. }>): void;
  112058. /**
  112059. * Initializes the uniform buffer layout for the shader.
  112060. */
  112061. buildUniformLayout(): void;
  112062. /**
  112063. * Unbinds the material from the mesh
  112064. */
  112065. unbind(): void;
  112066. /**
  112067. * Binds the submesh data.
  112068. * @param world - The world matrix.
  112069. * @param mesh - The BJS mesh.
  112070. * @param subMesh - A submesh of the BJS mesh.
  112071. */
  112072. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112073. /**
  112074. * Returns the animatable textures.
  112075. * @returns - Array of animatable textures.
  112076. */
  112077. getAnimatables(): IAnimatable[];
  112078. /**
  112079. * Returns the texture used for reflections.
  112080. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  112081. */
  112082. private _getReflectionTexture;
  112083. /**
  112084. * Returns an array of the actively used textures.
  112085. * @returns - Array of BaseTextures
  112086. */
  112087. getActiveTextures(): BaseTexture[];
  112088. /**
  112089. * Checks to see if a texture is used in the material.
  112090. * @param texture - Base texture to use.
  112091. * @returns - Boolean specifying if a texture is used in the material.
  112092. */
  112093. hasTexture(texture: BaseTexture): boolean;
  112094. /**
  112095. * Disposes the resources of the material.
  112096. * @param forceDisposeEffect - Forces the disposal of effects.
  112097. * @param forceDisposeTextures - Forces the disposal of all textures.
  112098. */
  112099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112100. }
  112101. }
  112102. declare module BABYLON {
  112103. /**
  112104. * The Physically based material of BJS.
  112105. *
  112106. * This offers the main features of a standard PBR material.
  112107. * For more information, please refer to the documentation :
  112108. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112109. */
  112110. export class PBRMaterial extends PBRBaseMaterial {
  112111. /**
  112112. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112113. */
  112114. static readonly PBRMATERIAL_OPAQUE: number;
  112115. /**
  112116. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112117. */
  112118. static readonly PBRMATERIAL_ALPHATEST: number;
  112119. /**
  112120. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112121. */
  112122. static readonly PBRMATERIAL_ALPHABLEND: number;
  112123. /**
  112124. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112125. * They are also discarded below the alpha cutoff threshold to improve performances.
  112126. */
  112127. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112128. /**
  112129. * Defines the default value of how much AO map is occluding the analytical lights
  112130. * (point spot...).
  112131. */
  112132. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112133. /**
  112134. * Intensity of the direct lights e.g. the four lights available in your scene.
  112135. * This impacts both the direct diffuse and specular highlights.
  112136. */
  112137. directIntensity: number;
  112138. /**
  112139. * Intensity of the emissive part of the material.
  112140. * This helps controlling the emissive effect without modifying the emissive color.
  112141. */
  112142. emissiveIntensity: number;
  112143. /**
  112144. * Intensity of the environment e.g. how much the environment will light the object
  112145. * either through harmonics for rough material or through the refelction for shiny ones.
  112146. */
  112147. environmentIntensity: number;
  112148. /**
  112149. * This is a special control allowing the reduction of the specular highlights coming from the
  112150. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112151. */
  112152. specularIntensity: number;
  112153. /**
  112154. * Debug Control allowing disabling the bump map on this material.
  112155. */
  112156. disableBumpMap: boolean;
  112157. /**
  112158. * AKA Diffuse Texture in standard nomenclature.
  112159. */
  112160. albedoTexture: BaseTexture;
  112161. /**
  112162. * AKA Occlusion Texture in other nomenclature.
  112163. */
  112164. ambientTexture: BaseTexture;
  112165. /**
  112166. * AKA Occlusion Texture Intensity in other nomenclature.
  112167. */
  112168. ambientTextureStrength: number;
  112169. /**
  112170. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112171. * 1 means it completely occludes it
  112172. * 0 mean it has no impact
  112173. */
  112174. ambientTextureImpactOnAnalyticalLights: number;
  112175. /**
  112176. * Stores the alpha values in a texture.
  112177. */
  112178. opacityTexture: BaseTexture;
  112179. /**
  112180. * Stores the reflection values in a texture.
  112181. */
  112182. reflectionTexture: Nullable<BaseTexture>;
  112183. /**
  112184. * Stores the emissive values in a texture.
  112185. */
  112186. emissiveTexture: BaseTexture;
  112187. /**
  112188. * AKA Specular texture in other nomenclature.
  112189. */
  112190. reflectivityTexture: BaseTexture;
  112191. /**
  112192. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112193. */
  112194. metallicTexture: BaseTexture;
  112195. /**
  112196. * Specifies the metallic scalar of the metallic/roughness workflow.
  112197. * Can also be used to scale the metalness values of the metallic texture.
  112198. */
  112199. metallic: Nullable<number>;
  112200. /**
  112201. * Specifies the roughness scalar of the metallic/roughness workflow.
  112202. * Can also be used to scale the roughness values of the metallic texture.
  112203. */
  112204. roughness: Nullable<number>;
  112205. /**
  112206. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112207. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112208. */
  112209. microSurfaceTexture: BaseTexture;
  112210. /**
  112211. * Stores surface normal data used to displace a mesh in a texture.
  112212. */
  112213. bumpTexture: BaseTexture;
  112214. /**
  112215. * Stores the pre-calculated light information of a mesh in a texture.
  112216. */
  112217. lightmapTexture: BaseTexture;
  112218. /**
  112219. * Stores the refracted light information in a texture.
  112220. */
  112221. refractionTexture: Nullable<BaseTexture>;
  112222. /**
  112223. * The color of a material in ambient lighting.
  112224. */
  112225. ambientColor: Color3;
  112226. /**
  112227. * AKA Diffuse Color in other nomenclature.
  112228. */
  112229. albedoColor: Color3;
  112230. /**
  112231. * AKA Specular Color in other nomenclature.
  112232. */
  112233. reflectivityColor: Color3;
  112234. /**
  112235. * The color reflected from the material.
  112236. */
  112237. reflectionColor: Color3;
  112238. /**
  112239. * The color emitted from the material.
  112240. */
  112241. emissiveColor: Color3;
  112242. /**
  112243. * AKA Glossiness in other nomenclature.
  112244. */
  112245. microSurface: number;
  112246. /**
  112247. * source material index of refraction (IOR)' / 'destination material IOR.
  112248. */
  112249. indexOfRefraction: number;
  112250. /**
  112251. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112252. */
  112253. invertRefractionY: boolean;
  112254. /**
  112255. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112256. * Materials half opaque for instance using refraction could benefit from this control.
  112257. */
  112258. linkRefractionWithTransparency: boolean;
  112259. /**
  112260. * If true, the light map contains occlusion information instead of lighting info.
  112261. */
  112262. useLightmapAsShadowmap: boolean;
  112263. /**
  112264. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112265. */
  112266. useAlphaFromAlbedoTexture: boolean;
  112267. /**
  112268. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112269. */
  112270. forceAlphaTest: boolean;
  112271. /**
  112272. * Defines the alpha limits in alpha test mode.
  112273. */
  112274. alphaCutOff: number;
  112275. /**
  112276. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  112277. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112278. */
  112279. useSpecularOverAlpha: boolean;
  112280. /**
  112281. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112282. */
  112283. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112284. /**
  112285. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112286. */
  112287. useRoughnessFromMetallicTextureAlpha: boolean;
  112288. /**
  112289. * Specifies if the metallic texture contains the roughness information in its green channel.
  112290. */
  112291. useRoughnessFromMetallicTextureGreen: boolean;
  112292. /**
  112293. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112294. */
  112295. useMetallnessFromMetallicTextureBlue: boolean;
  112296. /**
  112297. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112298. */
  112299. useAmbientOcclusionFromMetallicTextureRed: boolean;
  112300. /**
  112301. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112302. */
  112303. useAmbientInGrayScale: boolean;
  112304. /**
  112305. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112306. * The material will try to infer what glossiness each pixel should be.
  112307. */
  112308. useAutoMicroSurfaceFromReflectivityMap: boolean;
  112309. /**
  112310. * BJS is using an harcoded light falloff based on a manually sets up range.
  112311. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112312. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112313. */
  112314. /**
  112315. * BJS is using an harcoded light falloff based on a manually sets up range.
  112316. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112317. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112318. */
  112319. usePhysicalLightFalloff: boolean;
  112320. /**
  112321. * In order to support the falloff compatibility with gltf, a special mode has been added
  112322. * to reproduce the gltf light falloff.
  112323. */
  112324. /**
  112325. * In order to support the falloff compatibility with gltf, a special mode has been added
  112326. * to reproduce the gltf light falloff.
  112327. */
  112328. useGLTFLightFalloff: boolean;
  112329. /**
  112330. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112331. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112332. */
  112333. useRadianceOverAlpha: boolean;
  112334. /**
  112335. * Allows using an object space normal map (instead of tangent space).
  112336. */
  112337. useObjectSpaceNormalMap: boolean;
  112338. /**
  112339. * Allows using the bump map in parallax mode.
  112340. */
  112341. useParallax: boolean;
  112342. /**
  112343. * Allows using the bump map in parallax occlusion mode.
  112344. */
  112345. useParallaxOcclusion: boolean;
  112346. /**
  112347. * Controls the scale bias of the parallax mode.
  112348. */
  112349. parallaxScaleBias: number;
  112350. /**
  112351. * If sets to true, disables all the lights affecting the material.
  112352. */
  112353. disableLighting: boolean;
  112354. /**
  112355. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112356. */
  112357. forceIrradianceInFragment: boolean;
  112358. /**
  112359. * Number of Simultaneous lights allowed on the material.
  112360. */
  112361. maxSimultaneousLights: number;
  112362. /**
  112363. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112364. */
  112365. invertNormalMapX: boolean;
  112366. /**
  112367. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112368. */
  112369. invertNormalMapY: boolean;
  112370. /**
  112371. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112372. */
  112373. twoSidedLighting: boolean;
  112374. /**
  112375. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112376. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112377. */
  112378. useAlphaFresnel: boolean;
  112379. /**
  112380. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112381. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112382. */
  112383. useLinearAlphaFresnel: boolean;
  112384. /**
  112385. * Let user defines the brdf lookup texture used for IBL.
  112386. * A default 8bit version is embedded but you could point at :
  112387. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  112388. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  112389. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  112390. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  112391. */
  112392. environmentBRDFTexture: Nullable<BaseTexture>;
  112393. /**
  112394. * Force normal to face away from face.
  112395. */
  112396. forceNormalForward: boolean;
  112397. /**
  112398. * Enables specular anti aliasing in the PBR shader.
  112399. * It will both interacts on the Geometry for analytical and IBL lighting.
  112400. * It also prefilter the roughness map based on the bump values.
  112401. */
  112402. enableSpecularAntiAliasing: boolean;
  112403. /**
  112404. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112405. * makes the reflect vector face the model (under horizon).
  112406. */
  112407. useHorizonOcclusion: boolean;
  112408. /**
  112409. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112410. * too much the area relying on ambient texture to define their ambient occlusion.
  112411. */
  112412. useRadianceOcclusion: boolean;
  112413. /**
  112414. * If set to true, no lighting calculations will be applied.
  112415. */
  112416. unlit: boolean;
  112417. /**
  112418. * Gets the image processing configuration used either in this material.
  112419. */
  112420. /**
  112421. * Sets the Default image processing configuration used either in the this material.
  112422. *
  112423. * If sets to null, the scene one is in use.
  112424. */
  112425. imageProcessingConfiguration: ImageProcessingConfiguration;
  112426. /**
  112427. * Gets wether the color curves effect is enabled.
  112428. */
  112429. /**
  112430. * Sets wether the color curves effect is enabled.
  112431. */
  112432. cameraColorCurvesEnabled: boolean;
  112433. /**
  112434. * Gets wether the color grading effect is enabled.
  112435. */
  112436. /**
  112437. * Gets wether the color grading effect is enabled.
  112438. */
  112439. cameraColorGradingEnabled: boolean;
  112440. /**
  112441. * Gets wether tonemapping is enabled or not.
  112442. */
  112443. /**
  112444. * Sets wether tonemapping is enabled or not
  112445. */
  112446. cameraToneMappingEnabled: boolean;
  112447. /**
  112448. * The camera exposure used on this material.
  112449. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112450. * This corresponds to a photographic exposure.
  112451. */
  112452. /**
  112453. * The camera exposure used on this material.
  112454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112455. * This corresponds to a photographic exposure.
  112456. */
  112457. cameraExposure: number;
  112458. /**
  112459. * Gets The camera contrast used on this material.
  112460. */
  112461. /**
  112462. * Sets The camera contrast used on this material.
  112463. */
  112464. cameraContrast: number;
  112465. /**
  112466. * Gets the Color Grading 2D Lookup Texture.
  112467. */
  112468. /**
  112469. * Sets the Color Grading 2D Lookup Texture.
  112470. */
  112471. cameraColorGradingTexture: Nullable<BaseTexture>;
  112472. /**
  112473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112475. * 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;
  112476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112477. */
  112478. /**
  112479. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112480. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112481. * 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;
  112482. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112483. */
  112484. cameraColorCurves: Nullable<ColorCurves>;
  112485. /**
  112486. * Instantiates a new PBRMaterial instance.
  112487. *
  112488. * @param name The material name
  112489. * @param scene The scene the material will be use in.
  112490. */
  112491. constructor(name: string, scene: Scene);
  112492. /**
  112493. * Returns the name of this material class.
  112494. */
  112495. getClassName(): string;
  112496. /**
  112497. * Makes a duplicate of the current material.
  112498. * @param name - name to use for the new material.
  112499. */
  112500. clone(name: string): PBRMaterial;
  112501. /**
  112502. * Serializes this PBR Material.
  112503. * @returns - An object with the serialized material.
  112504. */
  112505. serialize(): any;
  112506. /**
  112507. * Parses a PBR Material from a serialized object.
  112508. * @param source - Serialized object.
  112509. * @param scene - BJS scene instance.
  112510. * @param rootUrl - url for the scene object
  112511. * @returns - PBRMaterial
  112512. */
  112513. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  112514. }
  112515. }
  112516. declare module BABYLON {
  112517. /**
  112518. * Direct draw surface info
  112519. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  112520. */
  112521. export interface DDSInfo {
  112522. /**
  112523. * Width of the texture
  112524. */
  112525. width: number;
  112526. /**
  112527. * Width of the texture
  112528. */
  112529. height: number;
  112530. /**
  112531. * Number of Mipmaps for the texture
  112532. * @see https://en.wikipedia.org/wiki/Mipmap
  112533. */
  112534. mipmapCount: number;
  112535. /**
  112536. * If the textures format is a known fourCC format
  112537. * @see https://www.fourcc.org/
  112538. */
  112539. isFourCC: boolean;
  112540. /**
  112541. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  112542. */
  112543. isRGB: boolean;
  112544. /**
  112545. * If the texture is a lumincance format
  112546. */
  112547. isLuminance: boolean;
  112548. /**
  112549. * If this is a cube texture
  112550. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  112551. */
  112552. isCube: boolean;
  112553. /**
  112554. * If the texture is a compressed format eg. FOURCC_DXT1
  112555. */
  112556. isCompressed: boolean;
  112557. /**
  112558. * The dxgiFormat of the texture
  112559. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  112560. */
  112561. dxgiFormat: number;
  112562. /**
  112563. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  112564. */
  112565. textureType: number;
  112566. /**
  112567. * Sphericle polynomial created for the dds texture
  112568. */
  112569. sphericalPolynomial?: SphericalPolynomial;
  112570. }
  112571. /**
  112572. * Class used to provide DDS decompression tools
  112573. */
  112574. export class DDSTools {
  112575. /**
  112576. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  112577. */
  112578. static StoreLODInAlphaChannel: boolean;
  112579. /**
  112580. * Gets DDS information from an array buffer
  112581. * @param arrayBuffer defines the array buffer to read data from
  112582. * @returns the DDS information
  112583. */
  112584. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  112585. private static _FloatView;
  112586. private static _Int32View;
  112587. private static _ToHalfFloat;
  112588. private static _FromHalfFloat;
  112589. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  112590. private static _GetHalfFloatRGBAArrayBuffer;
  112591. private static _GetFloatRGBAArrayBuffer;
  112592. private static _GetFloatAsUIntRGBAArrayBuffer;
  112593. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  112594. private static _GetRGBAArrayBuffer;
  112595. private static _ExtractLongWordOrder;
  112596. private static _GetRGBArrayBuffer;
  112597. private static _GetLuminanceArrayBuffer;
  112598. /**
  112599. * Uploads DDS Levels to a Babylon Texture
  112600. * @hidden
  112601. */
  112602. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  112603. }
  112604. interface Engine {
  112605. /**
  112606. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  112607. * @param rootUrl defines the url where the file to load is located
  112608. * @param scene defines the current scene
  112609. * @param lodScale defines scale to apply to the mip map selection
  112610. * @param lodOffset defines offset to apply to the mip map selection
  112611. * @param onLoad defines an optional callback raised when the texture is loaded
  112612. * @param onError defines an optional callback raised if there is an issue to load the texture
  112613. * @param format defines the format of the data
  112614. * @param forcedExtension defines the extension to use to pick the right loader
  112615. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  112616. * @returns the cube texture as an InternalTexture
  112617. */
  112618. 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;
  112619. }
  112620. }
  112621. declare module BABYLON {
  112622. /**
  112623. * Implementation of the DDS Texture Loader.
  112624. * @hidden
  112625. */
  112626. export class _DDSTextureLoader implements IInternalTextureLoader {
  112627. /**
  112628. * Defines wether the loader supports cascade loading the different faces.
  112629. */
  112630. readonly supportCascades: boolean;
  112631. /**
  112632. * This returns if the loader support the current file information.
  112633. * @param extension defines the file extension of the file being loaded
  112634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112635. * @param fallback defines the fallback internal texture if any
  112636. * @param isBase64 defines whether the texture is encoded as a base64
  112637. * @param isBuffer defines whether the texture data are stored as a buffer
  112638. * @returns true if the loader can load the specified file
  112639. */
  112640. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112641. /**
  112642. * Transform the url before loading if required.
  112643. * @param rootUrl the url of the texture
  112644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112645. * @returns the transformed texture
  112646. */
  112647. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112648. /**
  112649. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112650. * @param rootUrl the url of the texture
  112651. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112652. * @returns the fallback texture
  112653. */
  112654. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112655. /**
  112656. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112657. * @param data contains the texture data
  112658. * @param texture defines the BabylonJS internal texture
  112659. * @param createPolynomials will be true if polynomials have been requested
  112660. * @param onLoad defines the callback to trigger once the texture is ready
  112661. * @param onError defines the callback to trigger in case of error
  112662. */
  112663. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112664. /**
  112665. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112666. * @param data contains the texture data
  112667. * @param texture defines the BabylonJS internal texture
  112668. * @param callback defines the method to call once ready to upload
  112669. */
  112670. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112671. }
  112672. }
  112673. declare module BABYLON {
  112674. /** @hidden */
  112675. export var rgbdEncodePixelShader: {
  112676. name: string;
  112677. shader: string;
  112678. };
  112679. }
  112680. declare module BABYLON {
  112681. /**
  112682. * Raw texture data and descriptor sufficient for WebGL texture upload
  112683. */
  112684. export interface EnvironmentTextureInfo {
  112685. /**
  112686. * Version of the environment map
  112687. */
  112688. version: number;
  112689. /**
  112690. * Width of image
  112691. */
  112692. width: number;
  112693. /**
  112694. * Irradiance information stored in the file.
  112695. */
  112696. irradiance: any;
  112697. /**
  112698. * Specular information stored in the file.
  112699. */
  112700. specular: any;
  112701. }
  112702. /**
  112703. * Sets of helpers addressing the serialization and deserialization of environment texture
  112704. * stored in a BabylonJS env file.
  112705. * Those files are usually stored as .env files.
  112706. */
  112707. export class EnvironmentTextureTools {
  112708. /**
  112709. * Magic number identifying the env file.
  112710. */
  112711. private static _MagicBytes;
  112712. /**
  112713. * Gets the environment info from an env file.
  112714. * @param data The array buffer containing the .env bytes.
  112715. * @returns the environment file info (the json header) if successfully parsed.
  112716. */
  112717. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112718. /**
  112719. * Creates an environment texture from a loaded cube texture.
  112720. * @param texture defines the cube texture to convert in env file
  112721. * @return a promise containing the environment data if succesfull.
  112722. */
  112723. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112724. /**
  112725. * Creates a JSON representation of the spherical data.
  112726. * @param texture defines the texture containing the polynomials
  112727. * @return the JSON representation of the spherical info
  112728. */
  112729. private static _CreateEnvTextureIrradiance;
  112730. /**
  112731. * Uploads the texture info contained in the env file to the GPU.
  112732. * @param texture defines the internal texture to upload to
  112733. * @param arrayBuffer defines the buffer cotaining the data to load
  112734. * @param info defines the texture info retrieved through the GetEnvInfo method
  112735. * @returns a promise
  112736. */
  112737. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112738. /**
  112739. * Uploads the levels of image data to the GPU.
  112740. * @param texture defines the internal texture to upload to
  112741. * @param imageData defines the array buffer views of image data [mipmap][face]
  112742. * @returns a promise
  112743. */
  112744. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112745. /**
  112746. * Uploads spherical polynomials information to the texture.
  112747. * @param texture defines the texture we are trying to upload the information to
  112748. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112749. */
  112750. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112751. /** @hidden */
  112752. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112753. }
  112754. }
  112755. declare module BABYLON {
  112756. /**
  112757. * Implementation of the ENV Texture Loader.
  112758. * @hidden
  112759. */
  112760. export class _ENVTextureLoader implements IInternalTextureLoader {
  112761. /**
  112762. * Defines wether the loader supports cascade loading the different faces.
  112763. */
  112764. readonly supportCascades: boolean;
  112765. /**
  112766. * This returns if the loader support the current file information.
  112767. * @param extension defines the file extension of the file being loaded
  112768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112769. * @param fallback defines the fallback internal texture if any
  112770. * @param isBase64 defines whether the texture is encoded as a base64
  112771. * @param isBuffer defines whether the texture data are stored as a buffer
  112772. * @returns true if the loader can load the specified file
  112773. */
  112774. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112775. /**
  112776. * Transform the url before loading if required.
  112777. * @param rootUrl the url of the texture
  112778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112779. * @returns the transformed texture
  112780. */
  112781. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112782. /**
  112783. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112784. * @param rootUrl the url of the texture
  112785. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112786. * @returns the fallback texture
  112787. */
  112788. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112789. /**
  112790. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112791. * @param data contains the texture data
  112792. * @param texture defines the BabylonJS internal texture
  112793. * @param createPolynomials will be true if polynomials have been requested
  112794. * @param onLoad defines the callback to trigger once the texture is ready
  112795. * @param onError defines the callback to trigger in case of error
  112796. */
  112797. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112798. /**
  112799. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112800. * @param data contains the texture data
  112801. * @param texture defines the BabylonJS internal texture
  112802. * @param callback defines the method to call once ready to upload
  112803. */
  112804. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112805. }
  112806. }
  112807. declare module BABYLON {
  112808. /**
  112809. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112810. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112811. */
  112812. export class KhronosTextureContainer {
  112813. /** contents of the KTX container file */
  112814. arrayBuffer: any;
  112815. private static HEADER_LEN;
  112816. private static COMPRESSED_2D;
  112817. private static COMPRESSED_3D;
  112818. private static TEX_2D;
  112819. private static TEX_3D;
  112820. /**
  112821. * Gets the openGL type
  112822. */
  112823. glType: number;
  112824. /**
  112825. * Gets the openGL type size
  112826. */
  112827. glTypeSize: number;
  112828. /**
  112829. * Gets the openGL format
  112830. */
  112831. glFormat: number;
  112832. /**
  112833. * Gets the openGL internal format
  112834. */
  112835. glInternalFormat: number;
  112836. /**
  112837. * Gets the base internal format
  112838. */
  112839. glBaseInternalFormat: number;
  112840. /**
  112841. * Gets image width in pixel
  112842. */
  112843. pixelWidth: number;
  112844. /**
  112845. * Gets image height in pixel
  112846. */
  112847. pixelHeight: number;
  112848. /**
  112849. * Gets image depth in pixels
  112850. */
  112851. pixelDepth: number;
  112852. /**
  112853. * Gets the number of array elements
  112854. */
  112855. numberOfArrayElements: number;
  112856. /**
  112857. * Gets the number of faces
  112858. */
  112859. numberOfFaces: number;
  112860. /**
  112861. * Gets the number of mipmap levels
  112862. */
  112863. numberOfMipmapLevels: number;
  112864. /**
  112865. * Gets the bytes of key value data
  112866. */
  112867. bytesOfKeyValueData: number;
  112868. /**
  112869. * Gets the load type
  112870. */
  112871. loadType: number;
  112872. /**
  112873. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112874. */
  112875. isInvalid: boolean;
  112876. /**
  112877. * Creates a new KhronosTextureContainer
  112878. * @param arrayBuffer contents of the KTX container file
  112879. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112880. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112881. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112882. */
  112883. constructor(
  112884. /** contents of the KTX container file */
  112885. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112886. /**
  112887. * Uploads KTX content to a Babylon Texture.
  112888. * It is assumed that the texture has already been created & is currently bound
  112889. * @hidden
  112890. */
  112891. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112892. private _upload2DCompressedLevels;
  112893. }
  112894. }
  112895. declare module BABYLON {
  112896. /**
  112897. * Implementation of the KTX Texture Loader.
  112898. * @hidden
  112899. */
  112900. export class _KTXTextureLoader implements IInternalTextureLoader {
  112901. /**
  112902. * Defines wether the loader supports cascade loading the different faces.
  112903. */
  112904. readonly supportCascades: boolean;
  112905. /**
  112906. * This returns if the loader support the current file information.
  112907. * @param extension defines the file extension of the file being loaded
  112908. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112909. * @param fallback defines the fallback internal texture if any
  112910. * @param isBase64 defines whether the texture is encoded as a base64
  112911. * @param isBuffer defines whether the texture data are stored as a buffer
  112912. * @returns true if the loader can load the specified file
  112913. */
  112914. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112915. /**
  112916. * Transform the url before loading if required.
  112917. * @param rootUrl the url of the texture
  112918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112919. * @returns the transformed texture
  112920. */
  112921. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112922. /**
  112923. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112924. * @param rootUrl the url of the texture
  112925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112926. * @returns the fallback texture
  112927. */
  112928. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112929. /**
  112930. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112931. * @param data contains the texture data
  112932. * @param texture defines the BabylonJS internal texture
  112933. * @param createPolynomials will be true if polynomials have been requested
  112934. * @param onLoad defines the callback to trigger once the texture is ready
  112935. * @param onError defines the callback to trigger in case of error
  112936. */
  112937. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112938. /**
  112939. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112940. * @param data contains the texture data
  112941. * @param texture defines the BabylonJS internal texture
  112942. * @param callback defines the method to call once ready to upload
  112943. */
  112944. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112945. }
  112946. }
  112947. declare module BABYLON {
  112948. /**
  112949. * Options for the default xr helper
  112950. */
  112951. export class WebXRDefaultExperienceOptions {
  112952. /**
  112953. * Floor meshes that should be used for teleporting
  112954. */
  112955. floorMeshes: Array<AbstractMesh>;
  112956. }
  112957. /**
  112958. * Default experience which provides a similar setup to the previous webVRExperience
  112959. */
  112960. export class WebXRDefaultExperience {
  112961. /**
  112962. * Base experience
  112963. */
  112964. baseExperience: WebXRExperienceHelper;
  112965. /**
  112966. * Input experience extension
  112967. */
  112968. input: WebXRInput;
  112969. /**
  112970. * Loads the controller models
  112971. */
  112972. controllerModelLoader: WebXRControllerModelLoader;
  112973. /**
  112974. * Enables laser pointer and selection
  112975. */
  112976. pointerSelection: WebXRControllerPointerSelection;
  112977. /**
  112978. * Enables teleportation
  112979. */
  112980. teleportation: WebXRControllerTeleportation;
  112981. /**
  112982. * Enables ui for enetering/exiting xr
  112983. */
  112984. enterExitUI: WebXREnterExitUI;
  112985. /**
  112986. * Default output canvas xr should render to
  112987. */
  112988. outputCanvas: WebXRManagedOutputCanvas;
  112989. /**
  112990. * Creates the default xr experience
  112991. * @param scene scene
  112992. * @param options options for basic configuration
  112993. * @returns resulting WebXRDefaultExperience
  112994. */
  112995. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112996. private constructor();
  112997. /**
  112998. * DIsposes of the experience helper
  112999. */
  113000. dispose(): void;
  113001. }
  113002. }
  113003. declare module BABYLON {
  113004. /** @hidden */
  113005. export var _forceSceneHelpersToBundle: boolean;
  113006. interface Scene {
  113007. /**
  113008. * Creates a default light for the scene.
  113009. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  113010. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  113011. */
  113012. createDefaultLight(replace?: boolean): void;
  113013. /**
  113014. * Creates a default camera for the scene.
  113015. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  113016. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113017. * @param replace has default false, when true replaces the active camera in the scene
  113018. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  113019. */
  113020. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113021. /**
  113022. * Creates a default camera and a default light.
  113023. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  113024. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113025. * @param replace has the default false, when true replaces the active camera/light in the scene
  113026. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  113027. */
  113028. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113029. /**
  113030. * Creates a new sky box
  113031. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  113032. * @param environmentTexture defines the texture to use as environment texture
  113033. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  113034. * @param scale defines the overall scale of the skybox
  113035. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  113036. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  113037. * @returns a new mesh holding the sky box
  113038. */
  113039. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  113040. /**
  113041. * Creates a new environment
  113042. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  113043. * @param options defines the options you can use to configure the environment
  113044. * @returns the new EnvironmentHelper
  113045. */
  113046. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  113047. /**
  113048. * Creates a new VREXperienceHelper
  113049. * @see http://doc.babylonjs.com/how_to/webvr_helper
  113050. * @param webVROptions defines the options used to create the new VREXperienceHelper
  113051. * @returns a new VREXperienceHelper
  113052. */
  113053. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  113054. /**
  113055. * Creates a new WebXRDefaultExperience
  113056. * @see http://doc.babylonjs.com/how_to/webxr
  113057. * @param options experience options
  113058. * @returns a promise for a new WebXRDefaultExperience
  113059. */
  113060. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113061. }
  113062. }
  113063. declare module BABYLON {
  113064. /**
  113065. * Contains position and normal vectors for a vertex
  113066. */
  113067. export class PositionNormalVertex {
  113068. /** the position of the vertex (defaut: 0,0,0) */
  113069. position: Vector3;
  113070. /** the normal of the vertex (defaut: 0,1,0) */
  113071. normal: Vector3;
  113072. /**
  113073. * Creates a PositionNormalVertex
  113074. * @param position the position of the vertex (defaut: 0,0,0)
  113075. * @param normal the normal of the vertex (defaut: 0,1,0)
  113076. */
  113077. constructor(
  113078. /** the position of the vertex (defaut: 0,0,0) */
  113079. position?: Vector3,
  113080. /** the normal of the vertex (defaut: 0,1,0) */
  113081. normal?: Vector3);
  113082. /**
  113083. * Clones the PositionNormalVertex
  113084. * @returns the cloned PositionNormalVertex
  113085. */
  113086. clone(): PositionNormalVertex;
  113087. }
  113088. /**
  113089. * Contains position, normal and uv vectors for a vertex
  113090. */
  113091. export class PositionNormalTextureVertex {
  113092. /** the position of the vertex (defaut: 0,0,0) */
  113093. position: Vector3;
  113094. /** the normal of the vertex (defaut: 0,1,0) */
  113095. normal: Vector3;
  113096. /** the uv of the vertex (default: 0,0) */
  113097. uv: Vector2;
  113098. /**
  113099. * Creates a PositionNormalTextureVertex
  113100. * @param position the position of the vertex (defaut: 0,0,0)
  113101. * @param normal the normal of the vertex (defaut: 0,1,0)
  113102. * @param uv the uv of the vertex (default: 0,0)
  113103. */
  113104. constructor(
  113105. /** the position of the vertex (defaut: 0,0,0) */
  113106. position?: Vector3,
  113107. /** the normal of the vertex (defaut: 0,1,0) */
  113108. normal?: Vector3,
  113109. /** the uv of the vertex (default: 0,0) */
  113110. uv?: Vector2);
  113111. /**
  113112. * Clones the PositionNormalTextureVertex
  113113. * @returns the cloned PositionNormalTextureVertex
  113114. */
  113115. clone(): PositionNormalTextureVertex;
  113116. }
  113117. }
  113118. declare module BABYLON {
  113119. /**
  113120. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  113121. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  113122. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  113123. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113124. */
  113125. export class VideoDome extends TransformNode {
  113126. /**
  113127. * Define the video source as a Monoscopic panoramic 360 video.
  113128. */
  113129. static readonly MODE_MONOSCOPIC: number;
  113130. /**
  113131. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113132. */
  113133. static readonly MODE_TOPBOTTOM: number;
  113134. /**
  113135. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113136. */
  113137. static readonly MODE_SIDEBYSIDE: number;
  113138. private _halfDome;
  113139. private _useDirectMapping;
  113140. /**
  113141. * The video texture being displayed on the sphere
  113142. */
  113143. protected _videoTexture: VideoTexture;
  113144. /**
  113145. * Gets the video texture being displayed on the sphere
  113146. */
  113147. readonly videoTexture: VideoTexture;
  113148. /**
  113149. * The skybox material
  113150. */
  113151. protected _material: BackgroundMaterial;
  113152. /**
  113153. * The surface used for the skybox
  113154. */
  113155. protected _mesh: Mesh;
  113156. /**
  113157. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  113158. */
  113159. private _halfDomeMask;
  113160. /**
  113161. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113162. * Also see the options.resolution property.
  113163. */
  113164. fovMultiplier: number;
  113165. private _videoMode;
  113166. /**
  113167. * Gets or set the current video mode for the video. It can be:
  113168. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  113169. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113170. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113171. */
  113172. videoMode: number;
  113173. /**
  113174. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  113175. *
  113176. */
  113177. /**
  113178. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  113179. */
  113180. halfDome: boolean;
  113181. /**
  113182. * Oberserver used in Stereoscopic VR Mode.
  113183. */
  113184. private _onBeforeCameraRenderObserver;
  113185. /**
  113186. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  113187. * @param name Element's name, child elements will append suffixes for their own names.
  113188. * @param urlsOrVideo defines the url(s) or the video element to use
  113189. * @param options An object containing optional or exposed sub element properties
  113190. */
  113191. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  113192. resolution?: number;
  113193. clickToPlay?: boolean;
  113194. autoPlay?: boolean;
  113195. loop?: boolean;
  113196. size?: number;
  113197. poster?: string;
  113198. faceForward?: boolean;
  113199. useDirectMapping?: boolean;
  113200. halfDomeMode?: boolean;
  113201. }, scene: Scene);
  113202. private _changeVideoMode;
  113203. /**
  113204. * Releases resources associated with this node.
  113205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113207. */
  113208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113209. }
  113210. }
  113211. declare module BABYLON {
  113212. /**
  113213. * This class can be used to get instrumentation data from a Babylon engine
  113214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113215. */
  113216. export class EngineInstrumentation implements IDisposable {
  113217. /**
  113218. * Define the instrumented engine.
  113219. */
  113220. engine: Engine;
  113221. private _captureGPUFrameTime;
  113222. private _gpuFrameTimeToken;
  113223. private _gpuFrameTime;
  113224. private _captureShaderCompilationTime;
  113225. private _shaderCompilationTime;
  113226. private _onBeginFrameObserver;
  113227. private _onEndFrameObserver;
  113228. private _onBeforeShaderCompilationObserver;
  113229. private _onAfterShaderCompilationObserver;
  113230. /**
  113231. * Gets the perf counter used for GPU frame time
  113232. */
  113233. readonly gpuFrameTimeCounter: PerfCounter;
  113234. /**
  113235. * Gets the GPU frame time capture status
  113236. */
  113237. /**
  113238. * Enable or disable the GPU frame time capture
  113239. */
  113240. captureGPUFrameTime: boolean;
  113241. /**
  113242. * Gets the perf counter used for shader compilation time
  113243. */
  113244. readonly shaderCompilationTimeCounter: PerfCounter;
  113245. /**
  113246. * Gets the shader compilation time capture status
  113247. */
  113248. /**
  113249. * Enable or disable the shader compilation time capture
  113250. */
  113251. captureShaderCompilationTime: boolean;
  113252. /**
  113253. * Instantiates a new engine instrumentation.
  113254. * This class can be used to get instrumentation data from a Babylon engine
  113255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113256. * @param engine Defines the engine to instrument
  113257. */
  113258. constructor(
  113259. /**
  113260. * Define the instrumented engine.
  113261. */
  113262. engine: Engine);
  113263. /**
  113264. * Dispose and release associated resources.
  113265. */
  113266. dispose(): void;
  113267. }
  113268. }
  113269. declare module BABYLON {
  113270. /**
  113271. * This class can be used to get instrumentation data from a Babylon engine
  113272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113273. */
  113274. export class SceneInstrumentation implements IDisposable {
  113275. /**
  113276. * Defines the scene to instrument
  113277. */
  113278. scene: Scene;
  113279. private _captureActiveMeshesEvaluationTime;
  113280. private _activeMeshesEvaluationTime;
  113281. private _captureRenderTargetsRenderTime;
  113282. private _renderTargetsRenderTime;
  113283. private _captureFrameTime;
  113284. private _frameTime;
  113285. private _captureRenderTime;
  113286. private _renderTime;
  113287. private _captureInterFrameTime;
  113288. private _interFrameTime;
  113289. private _captureParticlesRenderTime;
  113290. private _particlesRenderTime;
  113291. private _captureSpritesRenderTime;
  113292. private _spritesRenderTime;
  113293. private _capturePhysicsTime;
  113294. private _physicsTime;
  113295. private _captureAnimationsTime;
  113296. private _animationsTime;
  113297. private _captureCameraRenderTime;
  113298. private _cameraRenderTime;
  113299. private _onBeforeActiveMeshesEvaluationObserver;
  113300. private _onAfterActiveMeshesEvaluationObserver;
  113301. private _onBeforeRenderTargetsRenderObserver;
  113302. private _onAfterRenderTargetsRenderObserver;
  113303. private _onAfterRenderObserver;
  113304. private _onBeforeDrawPhaseObserver;
  113305. private _onAfterDrawPhaseObserver;
  113306. private _onBeforeAnimationsObserver;
  113307. private _onBeforeParticlesRenderingObserver;
  113308. private _onAfterParticlesRenderingObserver;
  113309. private _onBeforeSpritesRenderingObserver;
  113310. private _onAfterSpritesRenderingObserver;
  113311. private _onBeforePhysicsObserver;
  113312. private _onAfterPhysicsObserver;
  113313. private _onAfterAnimationsObserver;
  113314. private _onBeforeCameraRenderObserver;
  113315. private _onAfterCameraRenderObserver;
  113316. /**
  113317. * Gets the perf counter used for active meshes evaluation time
  113318. */
  113319. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  113320. /**
  113321. * Gets the active meshes evaluation time capture status
  113322. */
  113323. /**
  113324. * Enable or disable the active meshes evaluation time capture
  113325. */
  113326. captureActiveMeshesEvaluationTime: boolean;
  113327. /**
  113328. * Gets the perf counter used for render targets render time
  113329. */
  113330. readonly renderTargetsRenderTimeCounter: PerfCounter;
  113331. /**
  113332. * Gets the render targets render time capture status
  113333. */
  113334. /**
  113335. * Enable or disable the render targets render time capture
  113336. */
  113337. captureRenderTargetsRenderTime: boolean;
  113338. /**
  113339. * Gets the perf counter used for particles render time
  113340. */
  113341. readonly particlesRenderTimeCounter: PerfCounter;
  113342. /**
  113343. * Gets the particles render time capture status
  113344. */
  113345. /**
  113346. * Enable or disable the particles render time capture
  113347. */
  113348. captureParticlesRenderTime: boolean;
  113349. /**
  113350. * Gets the perf counter used for sprites render time
  113351. */
  113352. readonly spritesRenderTimeCounter: PerfCounter;
  113353. /**
  113354. * Gets the sprites render time capture status
  113355. */
  113356. /**
  113357. * Enable or disable the sprites render time capture
  113358. */
  113359. captureSpritesRenderTime: boolean;
  113360. /**
  113361. * Gets the perf counter used for physics time
  113362. */
  113363. readonly physicsTimeCounter: PerfCounter;
  113364. /**
  113365. * Gets the physics time capture status
  113366. */
  113367. /**
  113368. * Enable or disable the physics time capture
  113369. */
  113370. capturePhysicsTime: boolean;
  113371. /**
  113372. * Gets the perf counter used for animations time
  113373. */
  113374. readonly animationsTimeCounter: PerfCounter;
  113375. /**
  113376. * Gets the animations time capture status
  113377. */
  113378. /**
  113379. * Enable or disable the animations time capture
  113380. */
  113381. captureAnimationsTime: boolean;
  113382. /**
  113383. * Gets the perf counter used for frame time capture
  113384. */
  113385. readonly frameTimeCounter: PerfCounter;
  113386. /**
  113387. * Gets the frame time capture status
  113388. */
  113389. /**
  113390. * Enable or disable the frame time capture
  113391. */
  113392. captureFrameTime: boolean;
  113393. /**
  113394. * Gets the perf counter used for inter-frames time capture
  113395. */
  113396. readonly interFrameTimeCounter: PerfCounter;
  113397. /**
  113398. * Gets the inter-frames time capture status
  113399. */
  113400. /**
  113401. * Enable or disable the inter-frames time capture
  113402. */
  113403. captureInterFrameTime: boolean;
  113404. /**
  113405. * Gets the perf counter used for render time capture
  113406. */
  113407. readonly renderTimeCounter: PerfCounter;
  113408. /**
  113409. * Gets the render time capture status
  113410. */
  113411. /**
  113412. * Enable or disable the render time capture
  113413. */
  113414. captureRenderTime: boolean;
  113415. /**
  113416. * Gets the perf counter used for camera render time capture
  113417. */
  113418. readonly cameraRenderTimeCounter: PerfCounter;
  113419. /**
  113420. * Gets the camera render time capture status
  113421. */
  113422. /**
  113423. * Enable or disable the camera render time capture
  113424. */
  113425. captureCameraRenderTime: boolean;
  113426. /**
  113427. * Gets the perf counter used for draw calls
  113428. */
  113429. readonly drawCallsCounter: PerfCounter;
  113430. /**
  113431. * Instantiates a new scene instrumentation.
  113432. * This class can be used to get instrumentation data from a Babylon engine
  113433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113434. * @param scene Defines the scene to instrument
  113435. */
  113436. constructor(
  113437. /**
  113438. * Defines the scene to instrument
  113439. */
  113440. scene: Scene);
  113441. /**
  113442. * Dispose and release associated resources.
  113443. */
  113444. dispose(): void;
  113445. }
  113446. }
  113447. declare module BABYLON {
  113448. /** @hidden */
  113449. export var glowMapGenerationPixelShader: {
  113450. name: string;
  113451. shader: string;
  113452. };
  113453. }
  113454. declare module BABYLON {
  113455. /** @hidden */
  113456. export var glowMapGenerationVertexShader: {
  113457. name: string;
  113458. shader: string;
  113459. };
  113460. }
  113461. declare module BABYLON {
  113462. /**
  113463. * Effect layer options. This helps customizing the behaviour
  113464. * of the effect layer.
  113465. */
  113466. export interface IEffectLayerOptions {
  113467. /**
  113468. * Multiplication factor apply to the canvas size to compute the render target size
  113469. * used to generated the objects (the smaller the faster).
  113470. */
  113471. mainTextureRatio: number;
  113472. /**
  113473. * Enforces a fixed size texture to ensure effect stability across devices.
  113474. */
  113475. mainTextureFixedSize?: number;
  113476. /**
  113477. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  113478. */
  113479. alphaBlendingMode: number;
  113480. /**
  113481. * The camera attached to the layer.
  113482. */
  113483. camera: Nullable<Camera>;
  113484. /**
  113485. * The rendering group to draw the layer in.
  113486. */
  113487. renderingGroupId: number;
  113488. }
  113489. /**
  113490. * The effect layer Helps adding post process effect blended with the main pass.
  113491. *
  113492. * This can be for instance use to generate glow or higlight effects on the scene.
  113493. *
  113494. * The effect layer class can not be used directly and is intented to inherited from to be
  113495. * customized per effects.
  113496. */
  113497. export abstract class EffectLayer {
  113498. private _vertexBuffers;
  113499. private _indexBuffer;
  113500. private _cachedDefines;
  113501. private _effectLayerMapGenerationEffect;
  113502. private _effectLayerOptions;
  113503. private _mergeEffect;
  113504. protected _scene: Scene;
  113505. protected _engine: Engine;
  113506. protected _maxSize: number;
  113507. protected _mainTextureDesiredSize: ISize;
  113508. protected _mainTexture: RenderTargetTexture;
  113509. protected _shouldRender: boolean;
  113510. protected _postProcesses: PostProcess[];
  113511. protected _textures: BaseTexture[];
  113512. protected _emissiveTextureAndColor: {
  113513. texture: Nullable<BaseTexture>;
  113514. color: Color4;
  113515. };
  113516. /**
  113517. * The name of the layer
  113518. */
  113519. name: string;
  113520. /**
  113521. * The clear color of the texture used to generate the glow map.
  113522. */
  113523. neutralColor: Color4;
  113524. /**
  113525. * Specifies wether the highlight layer is enabled or not.
  113526. */
  113527. isEnabled: boolean;
  113528. /**
  113529. * Gets the camera attached to the layer.
  113530. */
  113531. readonly camera: Nullable<Camera>;
  113532. /**
  113533. * Gets the rendering group id the layer should render in.
  113534. */
  113535. renderingGroupId: number;
  113536. /**
  113537. * An event triggered when the effect layer has been disposed.
  113538. */
  113539. onDisposeObservable: Observable<EffectLayer>;
  113540. /**
  113541. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  113542. */
  113543. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  113544. /**
  113545. * An event triggered when the generated texture is being merged in the scene.
  113546. */
  113547. onBeforeComposeObservable: Observable<EffectLayer>;
  113548. /**
  113549. * An event triggered when the generated texture has been merged in the scene.
  113550. */
  113551. onAfterComposeObservable: Observable<EffectLayer>;
  113552. /**
  113553. * An event triggered when the efffect layer changes its size.
  113554. */
  113555. onSizeChangedObservable: Observable<EffectLayer>;
  113556. /** @hidden */
  113557. static _SceneComponentInitialization: (scene: Scene) => void;
  113558. /**
  113559. * Instantiates a new effect Layer and references it in the scene.
  113560. * @param name The name of the layer
  113561. * @param scene The scene to use the layer in
  113562. */
  113563. constructor(
  113564. /** The Friendly of the effect in the scene */
  113565. name: string, scene: Scene);
  113566. /**
  113567. * Get the effect name of the layer.
  113568. * @return The effect name
  113569. */
  113570. abstract getEffectName(): string;
  113571. /**
  113572. * Checks for the readiness of the element composing the layer.
  113573. * @param subMesh the mesh to check for
  113574. * @param useInstances specify wether or not to use instances to render the mesh
  113575. * @return true if ready otherwise, false
  113576. */
  113577. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113578. /**
  113579. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113580. * @returns true if the effect requires stencil during the main canvas render pass.
  113581. */
  113582. abstract needStencil(): boolean;
  113583. /**
  113584. * Create the merge effect. This is the shader use to blit the information back
  113585. * to the main canvas at the end of the scene rendering.
  113586. * @returns The effect containing the shader used to merge the effect on the main canvas
  113587. */
  113588. protected abstract _createMergeEffect(): Effect;
  113589. /**
  113590. * Creates the render target textures and post processes used in the effect layer.
  113591. */
  113592. protected abstract _createTextureAndPostProcesses(): void;
  113593. /**
  113594. * Implementation specific of rendering the generating effect on the main canvas.
  113595. * @param effect The effect used to render through
  113596. */
  113597. protected abstract _internalRender(effect: Effect): void;
  113598. /**
  113599. * Sets the required values for both the emissive texture and and the main color.
  113600. */
  113601. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113602. /**
  113603. * Free any resources and references associated to a mesh.
  113604. * Internal use
  113605. * @param mesh The mesh to free.
  113606. */
  113607. abstract _disposeMesh(mesh: Mesh): void;
  113608. /**
  113609. * Serializes this layer (Glow or Highlight for example)
  113610. * @returns a serialized layer object
  113611. */
  113612. abstract serialize?(): any;
  113613. /**
  113614. * Initializes the effect layer with the required options.
  113615. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  113616. */
  113617. protected _init(options: Partial<IEffectLayerOptions>): void;
  113618. /**
  113619. * Generates the index buffer of the full screen quad blending to the main canvas.
  113620. */
  113621. private _generateIndexBuffer;
  113622. /**
  113623. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  113624. */
  113625. private _generateVertexBuffer;
  113626. /**
  113627. * Sets the main texture desired size which is the closest power of two
  113628. * of the engine canvas size.
  113629. */
  113630. private _setMainTextureSize;
  113631. /**
  113632. * Creates the main texture for the effect layer.
  113633. */
  113634. protected _createMainTexture(): void;
  113635. /**
  113636. * Adds specific effects defines.
  113637. * @param defines The defines to add specifics to.
  113638. */
  113639. protected _addCustomEffectDefines(defines: string[]): void;
  113640. /**
  113641. * Checks for the readiness of the element composing the layer.
  113642. * @param subMesh the mesh to check for
  113643. * @param useInstances specify wether or not to use instances to render the mesh
  113644. * @param emissiveTexture the associated emissive texture used to generate the glow
  113645. * @return true if ready otherwise, false
  113646. */
  113647. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113648. /**
  113649. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113650. */
  113651. render(): void;
  113652. /**
  113653. * Determine if a given mesh will be used in the current effect.
  113654. * @param mesh mesh to test
  113655. * @returns true if the mesh will be used
  113656. */
  113657. hasMesh(mesh: AbstractMesh): boolean;
  113658. /**
  113659. * Returns true if the layer contains information to display, otherwise false.
  113660. * @returns true if the glow layer should be rendered
  113661. */
  113662. shouldRender(): boolean;
  113663. /**
  113664. * Returns true if the mesh should render, otherwise false.
  113665. * @param mesh The mesh to render
  113666. * @returns true if it should render otherwise false
  113667. */
  113668. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113669. /**
  113670. * Returns true if the mesh can be rendered, otherwise false.
  113671. * @param mesh The mesh to render
  113672. * @param material The material used on the mesh
  113673. * @returns true if it can be rendered otherwise false
  113674. */
  113675. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113676. /**
  113677. * Returns true if the mesh should render, otherwise false.
  113678. * @param mesh The mesh to render
  113679. * @returns true if it should render otherwise false
  113680. */
  113681. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113682. /**
  113683. * Renders the submesh passed in parameter to the generation map.
  113684. */
  113685. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113686. /**
  113687. * Rebuild the required buffers.
  113688. * @hidden Internal use only.
  113689. */
  113690. _rebuild(): void;
  113691. /**
  113692. * Dispose only the render target textures and post process.
  113693. */
  113694. private _disposeTextureAndPostProcesses;
  113695. /**
  113696. * Dispose the highlight layer and free resources.
  113697. */
  113698. dispose(): void;
  113699. /**
  113700. * Gets the class name of the effect layer
  113701. * @returns the string with the class name of the effect layer
  113702. */
  113703. getClassName(): string;
  113704. /**
  113705. * Creates an effect layer from parsed effect layer data
  113706. * @param parsedEffectLayer defines effect layer data
  113707. * @param scene defines the current scene
  113708. * @param rootUrl defines the root URL containing the effect layer information
  113709. * @returns a parsed effect Layer
  113710. */
  113711. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113712. }
  113713. }
  113714. declare module BABYLON {
  113715. interface AbstractScene {
  113716. /**
  113717. * The list of effect layers (highlights/glow) added to the scene
  113718. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113719. * @see http://doc.babylonjs.com/how_to/glow_layer
  113720. */
  113721. effectLayers: Array<EffectLayer>;
  113722. /**
  113723. * Removes the given effect layer from this scene.
  113724. * @param toRemove defines the effect layer to remove
  113725. * @returns the index of the removed effect layer
  113726. */
  113727. removeEffectLayer(toRemove: EffectLayer): number;
  113728. /**
  113729. * Adds the given effect layer to this scene
  113730. * @param newEffectLayer defines the effect layer to add
  113731. */
  113732. addEffectLayer(newEffectLayer: EffectLayer): void;
  113733. }
  113734. /**
  113735. * Defines the layer scene component responsible to manage any effect layers
  113736. * in a given scene.
  113737. */
  113738. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113739. /**
  113740. * The component name helpfull to identify the component in the list of scene components.
  113741. */
  113742. readonly name: string;
  113743. /**
  113744. * The scene the component belongs to.
  113745. */
  113746. scene: Scene;
  113747. private _engine;
  113748. private _renderEffects;
  113749. private _needStencil;
  113750. private _previousStencilState;
  113751. /**
  113752. * Creates a new instance of the component for the given scene
  113753. * @param scene Defines the scene to register the component in
  113754. */
  113755. constructor(scene: Scene);
  113756. /**
  113757. * Registers the component in a given scene
  113758. */
  113759. register(): void;
  113760. /**
  113761. * Rebuilds the elements related to this component in case of
  113762. * context lost for instance.
  113763. */
  113764. rebuild(): void;
  113765. /**
  113766. * Serializes the component data to the specified json object
  113767. * @param serializationObject The object to serialize to
  113768. */
  113769. serialize(serializationObject: any): void;
  113770. /**
  113771. * Adds all the elements from the container to the scene
  113772. * @param container the container holding the elements
  113773. */
  113774. addFromContainer(container: AbstractScene): void;
  113775. /**
  113776. * Removes all the elements in the container from the scene
  113777. * @param container contains the elements to remove
  113778. * @param dispose if the removed element should be disposed (default: false)
  113779. */
  113780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113781. /**
  113782. * Disposes the component and the associated ressources.
  113783. */
  113784. dispose(): void;
  113785. private _isReadyForMesh;
  113786. private _renderMainTexture;
  113787. private _setStencil;
  113788. private _setStencilBack;
  113789. private _draw;
  113790. private _drawCamera;
  113791. private _drawRenderingGroup;
  113792. }
  113793. }
  113794. declare module BABYLON {
  113795. /** @hidden */
  113796. export var glowMapMergePixelShader: {
  113797. name: string;
  113798. shader: string;
  113799. };
  113800. }
  113801. declare module BABYLON {
  113802. /** @hidden */
  113803. export var glowMapMergeVertexShader: {
  113804. name: string;
  113805. shader: string;
  113806. };
  113807. }
  113808. declare module BABYLON {
  113809. interface AbstractScene {
  113810. /**
  113811. * Return a the first highlight layer of the scene with a given name.
  113812. * @param name The name of the highlight layer to look for.
  113813. * @return The highlight layer if found otherwise null.
  113814. */
  113815. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113816. }
  113817. /**
  113818. * Glow layer options. This helps customizing the behaviour
  113819. * of the glow layer.
  113820. */
  113821. export interface IGlowLayerOptions {
  113822. /**
  113823. * Multiplication factor apply to the canvas size to compute the render target size
  113824. * used to generated the glowing objects (the smaller the faster).
  113825. */
  113826. mainTextureRatio: number;
  113827. /**
  113828. * Enforces a fixed size texture to ensure resize independant blur.
  113829. */
  113830. mainTextureFixedSize?: number;
  113831. /**
  113832. * How big is the kernel of the blur texture.
  113833. */
  113834. blurKernelSize: number;
  113835. /**
  113836. * The camera attached to the layer.
  113837. */
  113838. camera: Nullable<Camera>;
  113839. /**
  113840. * Enable MSAA by chosing the number of samples.
  113841. */
  113842. mainTextureSamples?: number;
  113843. /**
  113844. * The rendering group to draw the layer in.
  113845. */
  113846. renderingGroupId: number;
  113847. }
  113848. /**
  113849. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113850. *
  113851. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113852. * glowy meshes to your scene.
  113853. *
  113854. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113855. */
  113856. export class GlowLayer extends EffectLayer {
  113857. /**
  113858. * Effect Name of the layer.
  113859. */
  113860. static readonly EffectName: string;
  113861. /**
  113862. * The default blur kernel size used for the glow.
  113863. */
  113864. static DefaultBlurKernelSize: number;
  113865. /**
  113866. * The default texture size ratio used for the glow.
  113867. */
  113868. static DefaultTextureRatio: number;
  113869. /**
  113870. * Sets the kernel size of the blur.
  113871. */
  113872. /**
  113873. * Gets the kernel size of the blur.
  113874. */
  113875. blurKernelSize: number;
  113876. /**
  113877. * Sets the glow intensity.
  113878. */
  113879. /**
  113880. * Gets the glow intensity.
  113881. */
  113882. intensity: number;
  113883. private _options;
  113884. private _intensity;
  113885. private _horizontalBlurPostprocess1;
  113886. private _verticalBlurPostprocess1;
  113887. private _horizontalBlurPostprocess2;
  113888. private _verticalBlurPostprocess2;
  113889. private _blurTexture1;
  113890. private _blurTexture2;
  113891. private _postProcesses1;
  113892. private _postProcesses2;
  113893. private _includedOnlyMeshes;
  113894. private _excludedMeshes;
  113895. /**
  113896. * Callback used to let the user override the color selection on a per mesh basis
  113897. */
  113898. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113899. /**
  113900. * Callback used to let the user override the texture selection on a per mesh basis
  113901. */
  113902. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113903. /**
  113904. * Instantiates a new glow Layer and references it to the scene.
  113905. * @param name The name of the layer
  113906. * @param scene The scene to use the layer in
  113907. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113908. */
  113909. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113910. /**
  113911. * Get the effect name of the layer.
  113912. * @return The effect name
  113913. */
  113914. getEffectName(): string;
  113915. /**
  113916. * Create the merge effect. This is the shader use to blit the information back
  113917. * to the main canvas at the end of the scene rendering.
  113918. */
  113919. protected _createMergeEffect(): Effect;
  113920. /**
  113921. * Creates the render target textures and post processes used in the glow layer.
  113922. */
  113923. protected _createTextureAndPostProcesses(): void;
  113924. /**
  113925. * Checks for the readiness of the element composing the layer.
  113926. * @param subMesh the mesh to check for
  113927. * @param useInstances specify wether or not to use instances to render the mesh
  113928. * @param emissiveTexture the associated emissive texture used to generate the glow
  113929. * @return true if ready otherwise, false
  113930. */
  113931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113932. /**
  113933. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113934. */
  113935. needStencil(): boolean;
  113936. /**
  113937. * Returns true if the mesh can be rendered, otherwise false.
  113938. * @param mesh The mesh to render
  113939. * @param material The material used on the mesh
  113940. * @returns true if it can be rendered otherwise false
  113941. */
  113942. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113943. /**
  113944. * Implementation specific of rendering the generating effect on the main canvas.
  113945. * @param effect The effect used to render through
  113946. */
  113947. protected _internalRender(effect: Effect): void;
  113948. /**
  113949. * Sets the required values for both the emissive texture and and the main color.
  113950. */
  113951. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113952. /**
  113953. * Returns true if the mesh should render, otherwise false.
  113954. * @param mesh The mesh to render
  113955. * @returns true if it should render otherwise false
  113956. */
  113957. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113958. /**
  113959. * Adds specific effects defines.
  113960. * @param defines The defines to add specifics to.
  113961. */
  113962. protected _addCustomEffectDefines(defines: string[]): void;
  113963. /**
  113964. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113965. * @param mesh The mesh to exclude from the glow layer
  113966. */
  113967. addExcludedMesh(mesh: Mesh): void;
  113968. /**
  113969. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113970. * @param mesh The mesh to remove
  113971. */
  113972. removeExcludedMesh(mesh: Mesh): void;
  113973. /**
  113974. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113975. * @param mesh The mesh to include in the glow layer
  113976. */
  113977. addIncludedOnlyMesh(mesh: Mesh): void;
  113978. /**
  113979. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113980. * @param mesh The mesh to remove
  113981. */
  113982. removeIncludedOnlyMesh(mesh: Mesh): void;
  113983. /**
  113984. * Determine if a given mesh will be used in the glow layer
  113985. * @param mesh The mesh to test
  113986. * @returns true if the mesh will be highlighted by the current glow layer
  113987. */
  113988. hasMesh(mesh: AbstractMesh): boolean;
  113989. /**
  113990. * Free any resources and references associated to a mesh.
  113991. * Internal use
  113992. * @param mesh The mesh to free.
  113993. * @hidden
  113994. */
  113995. _disposeMesh(mesh: Mesh): void;
  113996. /**
  113997. * Gets the class name of the effect layer
  113998. * @returns the string with the class name of the effect layer
  113999. */
  114000. getClassName(): string;
  114001. /**
  114002. * Serializes this glow layer
  114003. * @returns a serialized glow layer object
  114004. */
  114005. serialize(): any;
  114006. /**
  114007. * Creates a Glow Layer from parsed glow layer data
  114008. * @param parsedGlowLayer defines glow layer data
  114009. * @param scene defines the current scene
  114010. * @param rootUrl defines the root URL containing the glow layer information
  114011. * @returns a parsed Glow Layer
  114012. */
  114013. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  114014. }
  114015. }
  114016. declare module BABYLON {
  114017. /** @hidden */
  114018. export var glowBlurPostProcessPixelShader: {
  114019. name: string;
  114020. shader: string;
  114021. };
  114022. }
  114023. declare module BABYLON {
  114024. interface AbstractScene {
  114025. /**
  114026. * Return a the first highlight layer of the scene with a given name.
  114027. * @param name The name of the highlight layer to look for.
  114028. * @return The highlight layer if found otherwise null.
  114029. */
  114030. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  114031. }
  114032. /**
  114033. * Highlight layer options. This helps customizing the behaviour
  114034. * of the highlight layer.
  114035. */
  114036. export interface IHighlightLayerOptions {
  114037. /**
  114038. * Multiplication factor apply to the canvas size to compute the render target size
  114039. * used to generated the glowing objects (the smaller the faster).
  114040. */
  114041. mainTextureRatio: number;
  114042. /**
  114043. * Enforces a fixed size texture to ensure resize independant blur.
  114044. */
  114045. mainTextureFixedSize?: number;
  114046. /**
  114047. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  114048. * of the picture to blur (the smaller the faster).
  114049. */
  114050. blurTextureSizeRatio: number;
  114051. /**
  114052. * How big in texel of the blur texture is the vertical blur.
  114053. */
  114054. blurVerticalSize: number;
  114055. /**
  114056. * How big in texel of the blur texture is the horizontal blur.
  114057. */
  114058. blurHorizontalSize: number;
  114059. /**
  114060. * Alpha blending mode used to apply the blur. Default is combine.
  114061. */
  114062. alphaBlendingMode: number;
  114063. /**
  114064. * The camera attached to the layer.
  114065. */
  114066. camera: Nullable<Camera>;
  114067. /**
  114068. * Should we display highlight as a solid stroke?
  114069. */
  114070. isStroke?: boolean;
  114071. /**
  114072. * The rendering group to draw the layer in.
  114073. */
  114074. renderingGroupId: number;
  114075. }
  114076. /**
  114077. * The highlight layer Helps adding a glow effect around a mesh.
  114078. *
  114079. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114080. * glowy meshes to your scene.
  114081. *
  114082. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  114083. */
  114084. export class HighlightLayer extends EffectLayer {
  114085. name: string;
  114086. /**
  114087. * Effect Name of the highlight layer.
  114088. */
  114089. static readonly EffectName: string;
  114090. /**
  114091. * The neutral color used during the preparation of the glow effect.
  114092. * This is black by default as the blend operation is a blend operation.
  114093. */
  114094. static NeutralColor: Color4;
  114095. /**
  114096. * Stencil value used for glowing meshes.
  114097. */
  114098. static GlowingMeshStencilReference: number;
  114099. /**
  114100. * Stencil value used for the other meshes in the scene.
  114101. */
  114102. static NormalMeshStencilReference: number;
  114103. /**
  114104. * Specifies whether or not the inner glow is ACTIVE in the layer.
  114105. */
  114106. innerGlow: boolean;
  114107. /**
  114108. * Specifies whether or not the outer glow is ACTIVE in the layer.
  114109. */
  114110. outerGlow: boolean;
  114111. /**
  114112. * Specifies the horizontal size of the blur.
  114113. */
  114114. /**
  114115. * Gets the horizontal size of the blur.
  114116. */
  114117. blurHorizontalSize: number;
  114118. /**
  114119. * Specifies the vertical size of the blur.
  114120. */
  114121. /**
  114122. * Gets the vertical size of the blur.
  114123. */
  114124. blurVerticalSize: number;
  114125. /**
  114126. * An event triggered when the highlight layer is being blurred.
  114127. */
  114128. onBeforeBlurObservable: Observable<HighlightLayer>;
  114129. /**
  114130. * An event triggered when the highlight layer has been blurred.
  114131. */
  114132. onAfterBlurObservable: Observable<HighlightLayer>;
  114133. private _instanceGlowingMeshStencilReference;
  114134. private _options;
  114135. private _downSamplePostprocess;
  114136. private _horizontalBlurPostprocess;
  114137. private _verticalBlurPostprocess;
  114138. private _blurTexture;
  114139. private _meshes;
  114140. private _excludedMeshes;
  114141. /**
  114142. * Instantiates a new highlight Layer and references it to the scene..
  114143. * @param name The name of the layer
  114144. * @param scene The scene to use the layer in
  114145. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  114146. */
  114147. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  114148. /**
  114149. * Get the effect name of the layer.
  114150. * @return The effect name
  114151. */
  114152. getEffectName(): string;
  114153. /**
  114154. * Create the merge effect. This is the shader use to blit the information back
  114155. * to the main canvas at the end of the scene rendering.
  114156. */
  114157. protected _createMergeEffect(): Effect;
  114158. /**
  114159. * Creates the render target textures and post processes used in the highlight layer.
  114160. */
  114161. protected _createTextureAndPostProcesses(): void;
  114162. /**
  114163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114164. */
  114165. needStencil(): boolean;
  114166. /**
  114167. * Checks for the readiness of the element composing the layer.
  114168. * @param subMesh the mesh to check for
  114169. * @param useInstances specify wether or not to use instances to render the mesh
  114170. * @param emissiveTexture the associated emissive texture used to generate the glow
  114171. * @return true if ready otherwise, false
  114172. */
  114173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114174. /**
  114175. * Implementation specific of rendering the generating effect on the main canvas.
  114176. * @param effect The effect used to render through
  114177. */
  114178. protected _internalRender(effect: Effect): void;
  114179. /**
  114180. * Returns true if the layer contains information to display, otherwise false.
  114181. */
  114182. shouldRender(): boolean;
  114183. /**
  114184. * Returns true if the mesh should render, otherwise false.
  114185. * @param mesh The mesh to render
  114186. * @returns true if it should render otherwise false
  114187. */
  114188. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114189. /**
  114190. * Sets the required values for both the emissive texture and and the main color.
  114191. */
  114192. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114193. /**
  114194. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  114195. * @param mesh The mesh to exclude from the highlight layer
  114196. */
  114197. addExcludedMesh(mesh: Mesh): void;
  114198. /**
  114199. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  114200. * @param mesh The mesh to highlight
  114201. */
  114202. removeExcludedMesh(mesh: Mesh): void;
  114203. /**
  114204. * Determine if a given mesh will be highlighted by the current HighlightLayer
  114205. * @param mesh mesh to test
  114206. * @returns true if the mesh will be highlighted by the current HighlightLayer
  114207. */
  114208. hasMesh(mesh: AbstractMesh): boolean;
  114209. /**
  114210. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  114211. * @param mesh The mesh to highlight
  114212. * @param color The color of the highlight
  114213. * @param glowEmissiveOnly Extract the glow from the emissive texture
  114214. */
  114215. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  114216. /**
  114217. * Remove a mesh from the highlight layer in order to make it stop glowing.
  114218. * @param mesh The mesh to highlight
  114219. */
  114220. removeMesh(mesh: Mesh): void;
  114221. /**
  114222. * Force the stencil to the normal expected value for none glowing parts
  114223. */
  114224. private _defaultStencilReference;
  114225. /**
  114226. * Free any resources and references associated to a mesh.
  114227. * Internal use
  114228. * @param mesh The mesh to free.
  114229. * @hidden
  114230. */
  114231. _disposeMesh(mesh: Mesh): void;
  114232. /**
  114233. * Dispose the highlight layer and free resources.
  114234. */
  114235. dispose(): void;
  114236. /**
  114237. * Gets the class name of the effect layer
  114238. * @returns the string with the class name of the effect layer
  114239. */
  114240. getClassName(): string;
  114241. /**
  114242. * Serializes this Highlight layer
  114243. * @returns a serialized Highlight layer object
  114244. */
  114245. serialize(): any;
  114246. /**
  114247. * Creates a Highlight layer from parsed Highlight layer data
  114248. * @param parsedHightlightLayer defines the Highlight layer data
  114249. * @param scene defines the current scene
  114250. * @param rootUrl defines the root URL containing the Highlight layer information
  114251. * @returns a parsed Highlight layer
  114252. */
  114253. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  114254. }
  114255. }
  114256. declare module BABYLON {
  114257. interface AbstractScene {
  114258. /**
  114259. * The list of layers (background and foreground) of the scene
  114260. */
  114261. layers: Array<Layer>;
  114262. }
  114263. /**
  114264. * Defines the layer scene component responsible to manage any layers
  114265. * in a given scene.
  114266. */
  114267. export class LayerSceneComponent implements ISceneComponent {
  114268. /**
  114269. * The component name helpfull to identify the component in the list of scene components.
  114270. */
  114271. readonly name: string;
  114272. /**
  114273. * The scene the component belongs to.
  114274. */
  114275. scene: Scene;
  114276. private _engine;
  114277. /**
  114278. * Creates a new instance of the component for the given scene
  114279. * @param scene Defines the scene to register the component in
  114280. */
  114281. constructor(scene: Scene);
  114282. /**
  114283. * Registers the component in a given scene
  114284. */
  114285. register(): void;
  114286. /**
  114287. * Rebuilds the elements related to this component in case of
  114288. * context lost for instance.
  114289. */
  114290. rebuild(): void;
  114291. /**
  114292. * Disposes the component and the associated ressources.
  114293. */
  114294. dispose(): void;
  114295. private _draw;
  114296. private _drawCameraPredicate;
  114297. private _drawCameraBackground;
  114298. private _drawCameraForeground;
  114299. private _drawRenderTargetPredicate;
  114300. private _drawRenderTargetBackground;
  114301. private _drawRenderTargetForeground;
  114302. /**
  114303. * Adds all the elements from the container to the scene
  114304. * @param container the container holding the elements
  114305. */
  114306. addFromContainer(container: AbstractScene): void;
  114307. /**
  114308. * Removes all the elements in the container from the scene
  114309. * @param container contains the elements to remove
  114310. * @param dispose if the removed element should be disposed (default: false)
  114311. */
  114312. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114313. }
  114314. }
  114315. declare module BABYLON {
  114316. /** @hidden */
  114317. export var layerPixelShader: {
  114318. name: string;
  114319. shader: string;
  114320. };
  114321. }
  114322. declare module BABYLON {
  114323. /** @hidden */
  114324. export var layerVertexShader: {
  114325. name: string;
  114326. shader: string;
  114327. };
  114328. }
  114329. declare module BABYLON {
  114330. /**
  114331. * This represents a full screen 2d layer.
  114332. * This can be useful to display a picture in the background of your scene for instance.
  114333. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114334. */
  114335. export class Layer {
  114336. /**
  114337. * Define the name of the layer.
  114338. */
  114339. name: string;
  114340. /**
  114341. * Define the texture the layer should display.
  114342. */
  114343. texture: Nullable<Texture>;
  114344. /**
  114345. * Is the layer in background or foreground.
  114346. */
  114347. isBackground: boolean;
  114348. /**
  114349. * Define the color of the layer (instead of texture).
  114350. */
  114351. color: Color4;
  114352. /**
  114353. * Define the scale of the layer in order to zoom in out of the texture.
  114354. */
  114355. scale: Vector2;
  114356. /**
  114357. * Define an offset for the layer in order to shift the texture.
  114358. */
  114359. offset: Vector2;
  114360. /**
  114361. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  114362. */
  114363. alphaBlendingMode: number;
  114364. /**
  114365. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  114366. * Alpha test will not mix with the background color in case of transparency.
  114367. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  114368. */
  114369. alphaTest: boolean;
  114370. /**
  114371. * Define a mask to restrict the layer to only some of the scene cameras.
  114372. */
  114373. layerMask: number;
  114374. /**
  114375. * Define the list of render target the layer is visible into.
  114376. */
  114377. renderTargetTextures: RenderTargetTexture[];
  114378. /**
  114379. * Define if the layer is only used in renderTarget or if it also
  114380. * renders in the main frame buffer of the canvas.
  114381. */
  114382. renderOnlyInRenderTargetTextures: boolean;
  114383. private _scene;
  114384. private _vertexBuffers;
  114385. private _indexBuffer;
  114386. private _effect;
  114387. private _alphaTestEffect;
  114388. /**
  114389. * An event triggered when the layer is disposed.
  114390. */
  114391. onDisposeObservable: Observable<Layer>;
  114392. private _onDisposeObserver;
  114393. /**
  114394. * Back compatibility with callback before the onDisposeObservable existed.
  114395. * The set callback will be triggered when the layer has been disposed.
  114396. */
  114397. onDispose: () => void;
  114398. /**
  114399. * An event triggered before rendering the scene
  114400. */
  114401. onBeforeRenderObservable: Observable<Layer>;
  114402. private _onBeforeRenderObserver;
  114403. /**
  114404. * Back compatibility with callback before the onBeforeRenderObservable existed.
  114405. * The set callback will be triggered just before rendering the layer.
  114406. */
  114407. onBeforeRender: () => void;
  114408. /**
  114409. * An event triggered after rendering the scene
  114410. */
  114411. onAfterRenderObservable: Observable<Layer>;
  114412. private _onAfterRenderObserver;
  114413. /**
  114414. * Back compatibility with callback before the onAfterRenderObservable existed.
  114415. * The set callback will be triggered just after rendering the layer.
  114416. */
  114417. onAfterRender: () => void;
  114418. /**
  114419. * Instantiates a new layer.
  114420. * This represents a full screen 2d layer.
  114421. * This can be useful to display a picture in the background of your scene for instance.
  114422. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114423. * @param name Define the name of the layer in the scene
  114424. * @param imgUrl Define the url of the texture to display in the layer
  114425. * @param scene Define the scene the layer belongs to
  114426. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  114427. * @param color Defines a color for the layer
  114428. */
  114429. constructor(
  114430. /**
  114431. * Define the name of the layer.
  114432. */
  114433. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  114434. private _createIndexBuffer;
  114435. /** @hidden */
  114436. _rebuild(): void;
  114437. /**
  114438. * Renders the layer in the scene.
  114439. */
  114440. render(): void;
  114441. /**
  114442. * Disposes and releases the associated ressources.
  114443. */
  114444. dispose(): void;
  114445. }
  114446. }
  114447. declare module BABYLON {
  114448. /** @hidden */
  114449. export var lensFlarePixelShader: {
  114450. name: string;
  114451. shader: string;
  114452. };
  114453. }
  114454. declare module BABYLON {
  114455. /** @hidden */
  114456. export var lensFlareVertexShader: {
  114457. name: string;
  114458. shader: string;
  114459. };
  114460. }
  114461. declare module BABYLON {
  114462. /**
  114463. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114464. * It is usually composed of several `lensFlare`.
  114465. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114466. */
  114467. export class LensFlareSystem {
  114468. /**
  114469. * Define the name of the lens flare system
  114470. */
  114471. name: string;
  114472. /**
  114473. * List of lens flares used in this system.
  114474. */
  114475. lensFlares: LensFlare[];
  114476. /**
  114477. * Define a limit from the border the lens flare can be visible.
  114478. */
  114479. borderLimit: number;
  114480. /**
  114481. * Define a viewport border we do not want to see the lens flare in.
  114482. */
  114483. viewportBorder: number;
  114484. /**
  114485. * Define a predicate which could limit the list of meshes able to occlude the effect.
  114486. */
  114487. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114488. /**
  114489. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  114490. */
  114491. layerMask: number;
  114492. /**
  114493. * Define the id of the lens flare system in the scene.
  114494. * (equal to name by default)
  114495. */
  114496. id: string;
  114497. private _scene;
  114498. private _emitter;
  114499. private _vertexBuffers;
  114500. private _indexBuffer;
  114501. private _effect;
  114502. private _positionX;
  114503. private _positionY;
  114504. private _isEnabled;
  114505. /** @hidden */
  114506. static _SceneComponentInitialization: (scene: Scene) => void;
  114507. /**
  114508. * Instantiates a lens flare system.
  114509. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114510. * It is usually composed of several `lensFlare`.
  114511. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114512. * @param name Define the name of the lens flare system in the scene
  114513. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  114514. * @param scene Define the scene the lens flare system belongs to
  114515. */
  114516. constructor(
  114517. /**
  114518. * Define the name of the lens flare system
  114519. */
  114520. name: string, emitter: any, scene: Scene);
  114521. /**
  114522. * Define if the lens flare system is enabled.
  114523. */
  114524. isEnabled: boolean;
  114525. /**
  114526. * Get the scene the effects belongs to.
  114527. * @returns the scene holding the lens flare system
  114528. */
  114529. getScene(): Scene;
  114530. /**
  114531. * Get the emitter of the lens flare system.
  114532. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114533. * @returns the emitter of the lens flare system
  114534. */
  114535. getEmitter(): any;
  114536. /**
  114537. * Set the emitter of the lens flare system.
  114538. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114539. * @param newEmitter Define the new emitter of the system
  114540. */
  114541. setEmitter(newEmitter: any): void;
  114542. /**
  114543. * Get the lens flare system emitter position.
  114544. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  114545. * @returns the position
  114546. */
  114547. getEmitterPosition(): Vector3;
  114548. /**
  114549. * @hidden
  114550. */
  114551. computeEffectivePosition(globalViewport: Viewport): boolean;
  114552. /** @hidden */
  114553. _isVisible(): boolean;
  114554. /**
  114555. * @hidden
  114556. */
  114557. render(): boolean;
  114558. /**
  114559. * Dispose and release the lens flare with its associated resources.
  114560. */
  114561. dispose(): void;
  114562. /**
  114563. * Parse a lens flare system from a JSON repressentation
  114564. * @param parsedLensFlareSystem Define the JSON to parse
  114565. * @param scene Define the scene the parsed system should be instantiated in
  114566. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  114567. * @returns the parsed system
  114568. */
  114569. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  114570. /**
  114571. * Serialize the current Lens Flare System into a JSON representation.
  114572. * @returns the serialized JSON
  114573. */
  114574. serialize(): any;
  114575. }
  114576. }
  114577. declare module BABYLON {
  114578. /**
  114579. * This represents one of the lens effect in a `lensFlareSystem`.
  114580. * It controls one of the indiviual texture used in the effect.
  114581. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114582. */
  114583. export class LensFlare {
  114584. /**
  114585. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114586. */
  114587. size: number;
  114588. /**
  114589. * 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.
  114590. */
  114591. position: number;
  114592. /**
  114593. * Define the lens color.
  114594. */
  114595. color: Color3;
  114596. /**
  114597. * Define the lens texture.
  114598. */
  114599. texture: Nullable<Texture>;
  114600. /**
  114601. * Define the alpha mode to render this particular lens.
  114602. */
  114603. alphaMode: number;
  114604. private _system;
  114605. /**
  114606. * Creates a new Lens Flare.
  114607. * This represents one of the lens effect in a `lensFlareSystem`.
  114608. * It controls one of the indiviual texture used in the effect.
  114609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114610. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  114611. * @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.
  114612. * @param color Define the lens color
  114613. * @param imgUrl Define the lens texture url
  114614. * @param system Define the `lensFlareSystem` this flare is part of
  114615. * @returns The newly created Lens Flare
  114616. */
  114617. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  114618. /**
  114619. * Instantiates a new Lens Flare.
  114620. * This represents one of the lens effect in a `lensFlareSystem`.
  114621. * It controls one of the indiviual texture used in the effect.
  114622. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114623. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  114624. * @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.
  114625. * @param color Define the lens color
  114626. * @param imgUrl Define the lens texture url
  114627. * @param system Define the `lensFlareSystem` this flare is part of
  114628. */
  114629. constructor(
  114630. /**
  114631. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114632. */
  114633. size: number,
  114634. /**
  114635. * 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.
  114636. */
  114637. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114638. /**
  114639. * Dispose and release the lens flare with its associated resources.
  114640. */
  114641. dispose(): void;
  114642. }
  114643. }
  114644. declare module BABYLON {
  114645. interface AbstractScene {
  114646. /**
  114647. * The list of lens flare system added to the scene
  114648. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114649. */
  114650. lensFlareSystems: Array<LensFlareSystem>;
  114651. /**
  114652. * Removes the given lens flare system from this scene.
  114653. * @param toRemove The lens flare system to remove
  114654. * @returns The index of the removed lens flare system
  114655. */
  114656. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114657. /**
  114658. * Adds the given lens flare system to this scene
  114659. * @param newLensFlareSystem The lens flare system to add
  114660. */
  114661. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114662. /**
  114663. * Gets a lens flare system using its name
  114664. * @param name defines the name to look for
  114665. * @returns the lens flare system or null if not found
  114666. */
  114667. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114668. /**
  114669. * Gets a lens flare system using its id
  114670. * @param id defines the id to look for
  114671. * @returns the lens flare system or null if not found
  114672. */
  114673. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114674. }
  114675. /**
  114676. * Defines the lens flare scene component responsible to manage any lens flares
  114677. * in a given scene.
  114678. */
  114679. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114680. /**
  114681. * The component name helpfull to identify the component in the list of scene components.
  114682. */
  114683. readonly name: string;
  114684. /**
  114685. * The scene the component belongs to.
  114686. */
  114687. scene: Scene;
  114688. /**
  114689. * Creates a new instance of the component for the given scene
  114690. * @param scene Defines the scene to register the component in
  114691. */
  114692. constructor(scene: Scene);
  114693. /**
  114694. * Registers the component in a given scene
  114695. */
  114696. register(): void;
  114697. /**
  114698. * Rebuilds the elements related to this component in case of
  114699. * context lost for instance.
  114700. */
  114701. rebuild(): void;
  114702. /**
  114703. * Adds all the elements from the container to the scene
  114704. * @param container the container holding the elements
  114705. */
  114706. addFromContainer(container: AbstractScene): void;
  114707. /**
  114708. * Removes all the elements in the container from the scene
  114709. * @param container contains the elements to remove
  114710. * @param dispose if the removed element should be disposed (default: false)
  114711. */
  114712. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114713. /**
  114714. * Serializes the component data to the specified json object
  114715. * @param serializationObject The object to serialize to
  114716. */
  114717. serialize(serializationObject: any): void;
  114718. /**
  114719. * Disposes the component and the associated ressources.
  114720. */
  114721. dispose(): void;
  114722. private _draw;
  114723. }
  114724. }
  114725. declare module BABYLON {
  114726. /**
  114727. * Defines the shadow generator component responsible to manage any shadow generators
  114728. * in a given scene.
  114729. */
  114730. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114731. /**
  114732. * The component name helpfull to identify the component in the list of scene components.
  114733. */
  114734. readonly name: string;
  114735. /**
  114736. * The scene the component belongs to.
  114737. */
  114738. scene: Scene;
  114739. /**
  114740. * Creates a new instance of the component for the given scene
  114741. * @param scene Defines the scene to register the component in
  114742. */
  114743. constructor(scene: Scene);
  114744. /**
  114745. * Registers the component in a given scene
  114746. */
  114747. register(): void;
  114748. /**
  114749. * Rebuilds the elements related to this component in case of
  114750. * context lost for instance.
  114751. */
  114752. rebuild(): void;
  114753. /**
  114754. * Serializes the component data to the specified json object
  114755. * @param serializationObject The object to serialize to
  114756. */
  114757. serialize(serializationObject: any): void;
  114758. /**
  114759. * Adds all the elements from the container to the scene
  114760. * @param container the container holding the elements
  114761. */
  114762. addFromContainer(container: AbstractScene): void;
  114763. /**
  114764. * Removes all the elements in the container from the scene
  114765. * @param container contains the elements to remove
  114766. * @param dispose if the removed element should be disposed (default: false)
  114767. */
  114768. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114769. /**
  114770. * Rebuilds the elements related to this component in case of
  114771. * context lost for instance.
  114772. */
  114773. dispose(): void;
  114774. private _gatherRenderTargets;
  114775. }
  114776. }
  114777. declare module BABYLON {
  114778. /**
  114779. * A point light is a light defined by an unique point in world space.
  114780. * The light is emitted in every direction from this point.
  114781. * A good example of a point light is a standard light bulb.
  114782. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114783. */
  114784. export class PointLight extends ShadowLight {
  114785. private _shadowAngle;
  114786. /**
  114787. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114788. * This specifies what angle the shadow will use to be created.
  114789. *
  114790. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114791. */
  114792. /**
  114793. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114794. * This specifies what angle the shadow will use to be created.
  114795. *
  114796. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114797. */
  114798. shadowAngle: number;
  114799. /**
  114800. * Gets the direction if it has been set.
  114801. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114802. */
  114803. /**
  114804. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114805. */
  114806. direction: Vector3;
  114807. /**
  114808. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114809. * A PointLight emits the light in every direction.
  114810. * It can cast shadows.
  114811. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114812. * ```javascript
  114813. * var pointLight = new PointLight("pl", camera.position, scene);
  114814. * ```
  114815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114816. * @param name The light friendly name
  114817. * @param position The position of the point light in the scene
  114818. * @param scene The scene the lights belongs to
  114819. */
  114820. constructor(name: string, position: Vector3, scene: Scene);
  114821. /**
  114822. * Returns the string "PointLight"
  114823. * @returns the class name
  114824. */
  114825. getClassName(): string;
  114826. /**
  114827. * Returns the integer 0.
  114828. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114829. */
  114830. getTypeID(): number;
  114831. /**
  114832. * Specifies wether or not the shadowmap should be a cube texture.
  114833. * @returns true if the shadowmap needs to be a cube texture.
  114834. */
  114835. needCube(): boolean;
  114836. /**
  114837. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114840. */
  114841. getShadowDirection(faceIndex?: number): Vector3;
  114842. /**
  114843. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114844. * - fov = PI / 2
  114845. * - aspect ratio : 1.0
  114846. * - z-near and far equal to the active camera minZ and maxZ.
  114847. * Returns the PointLight.
  114848. */
  114849. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114850. protected _buildUniformLayout(): void;
  114851. /**
  114852. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114853. * @param effect The effect to update
  114854. * @param lightIndex The index of the light in the effect to update
  114855. * @returns The point light
  114856. */
  114857. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114858. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114859. /**
  114860. * Prepares the list of defines specific to the light type.
  114861. * @param defines the list of defines
  114862. * @param lightIndex defines the index of the light for the effect
  114863. */
  114864. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114865. }
  114866. }
  114867. declare module BABYLON {
  114868. /**
  114869. * Header information of HDR texture files.
  114870. */
  114871. export interface HDRInfo {
  114872. /**
  114873. * The height of the texture in pixels.
  114874. */
  114875. height: number;
  114876. /**
  114877. * The width of the texture in pixels.
  114878. */
  114879. width: number;
  114880. /**
  114881. * The index of the beginning of the data in the binary file.
  114882. */
  114883. dataPosition: number;
  114884. }
  114885. /**
  114886. * This groups tools to convert HDR texture to native colors array.
  114887. */
  114888. export class HDRTools {
  114889. private static Ldexp;
  114890. private static Rgbe2float;
  114891. private static readStringLine;
  114892. /**
  114893. * Reads header information from an RGBE texture stored in a native array.
  114894. * More information on this format are available here:
  114895. * https://en.wikipedia.org/wiki/RGBE_image_format
  114896. *
  114897. * @param uint8array The binary file stored in native array.
  114898. * @return The header information.
  114899. */
  114900. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114901. /**
  114902. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114903. * This RGBE texture needs to store the information as a panorama.
  114904. *
  114905. * More information on this format are available here:
  114906. * https://en.wikipedia.org/wiki/RGBE_image_format
  114907. *
  114908. * @param buffer The binary file stored in an array buffer.
  114909. * @param size The expected size of the extracted cubemap.
  114910. * @return The Cube Map information.
  114911. */
  114912. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114913. /**
  114914. * Returns the pixels data extracted from an RGBE texture.
  114915. * This pixels will be stored left to right up to down in the R G B order in one array.
  114916. *
  114917. * More information on this format are available here:
  114918. * https://en.wikipedia.org/wiki/RGBE_image_format
  114919. *
  114920. * @param uint8array The binary file stored in an array buffer.
  114921. * @param hdrInfo The header information of the file.
  114922. * @return The pixels data in RGB right to left up to down order.
  114923. */
  114924. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114925. private static RGBE_ReadPixels_RLE;
  114926. }
  114927. }
  114928. declare module BABYLON {
  114929. /**
  114930. * This represents a texture coming from an HDR input.
  114931. *
  114932. * The only supported format is currently panorama picture stored in RGBE format.
  114933. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114934. */
  114935. export class HDRCubeTexture extends BaseTexture {
  114936. private static _facesMapping;
  114937. private _generateHarmonics;
  114938. private _noMipmap;
  114939. private _textureMatrix;
  114940. private _size;
  114941. private _onLoad;
  114942. private _onError;
  114943. /**
  114944. * The texture URL.
  114945. */
  114946. url: string;
  114947. /**
  114948. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114949. */
  114950. coordinatesMode: number;
  114951. protected _isBlocking: boolean;
  114952. /**
  114953. * Sets wether or not the texture is blocking during loading.
  114954. */
  114955. /**
  114956. * Gets wether or not the texture is blocking during loading.
  114957. */
  114958. isBlocking: boolean;
  114959. protected _rotationY: number;
  114960. /**
  114961. * Sets texture matrix rotation angle around Y axis in radians.
  114962. */
  114963. /**
  114964. * Gets texture matrix rotation angle around Y axis radians.
  114965. */
  114966. rotationY: number;
  114967. /**
  114968. * Gets or sets the center of the bounding box associated with the cube texture
  114969. * It must define where the camera used to render the texture was set
  114970. */
  114971. boundingBoxPosition: Vector3;
  114972. private _boundingBoxSize;
  114973. /**
  114974. * Gets or sets the size of the bounding box associated with the cube texture
  114975. * When defined, the cubemap will switch to local mode
  114976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114977. * @example https://www.babylonjs-playground.com/#RNASML
  114978. */
  114979. boundingBoxSize: Vector3;
  114980. /**
  114981. * Instantiates an HDRTexture from the following parameters.
  114982. *
  114983. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114984. * @param scene The scene the texture will be used in
  114985. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114986. * @param noMipmap Forces to not generate the mipmap if true
  114987. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114988. * @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)
  114989. * @param reserved Reserved flag for internal use.
  114990. */
  114991. 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>);
  114992. /**
  114993. * Get the current class name of the texture useful for serialization or dynamic coding.
  114994. * @returns "HDRCubeTexture"
  114995. */
  114996. getClassName(): string;
  114997. /**
  114998. * Occurs when the file is raw .hdr file.
  114999. */
  115000. private loadTexture;
  115001. clone(): HDRCubeTexture;
  115002. delayLoad(): void;
  115003. /**
  115004. * Get the texture reflection matrix used to rotate/transform the reflection.
  115005. * @returns the reflection matrix
  115006. */
  115007. getReflectionTextureMatrix(): Matrix;
  115008. /**
  115009. * Set the texture reflection matrix used to rotate/transform the reflection.
  115010. * @param value Define the reflection matrix to set
  115011. */
  115012. setReflectionTextureMatrix(value: Matrix): void;
  115013. /**
  115014. * Parses a JSON representation of an HDR Texture in order to create the texture
  115015. * @param parsedTexture Define the JSON representation
  115016. * @param scene Define the scene the texture should be created in
  115017. * @param rootUrl Define the root url in case we need to load relative dependencies
  115018. * @returns the newly created texture after parsing
  115019. */
  115020. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  115021. serialize(): any;
  115022. }
  115023. }
  115024. declare module BABYLON {
  115025. /**
  115026. * Class used to control physics engine
  115027. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115028. */
  115029. export class PhysicsEngine implements IPhysicsEngine {
  115030. private _physicsPlugin;
  115031. /**
  115032. * Global value used to control the smallest number supported by the simulation
  115033. */
  115034. static Epsilon: number;
  115035. private _impostors;
  115036. private _joints;
  115037. /**
  115038. * Gets the gravity vector used by the simulation
  115039. */
  115040. gravity: Vector3;
  115041. /**
  115042. * Factory used to create the default physics plugin.
  115043. * @returns The default physics plugin
  115044. */
  115045. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  115046. /**
  115047. * Creates a new Physics Engine
  115048. * @param gravity defines the gravity vector used by the simulation
  115049. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  115050. */
  115051. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  115052. /**
  115053. * Sets the gravity vector used by the simulation
  115054. * @param gravity defines the gravity vector to use
  115055. */
  115056. setGravity(gravity: Vector3): void;
  115057. /**
  115058. * Set the time step of the physics engine.
  115059. * Default is 1/60.
  115060. * To slow it down, enter 1/600 for example.
  115061. * To speed it up, 1/30
  115062. * @param newTimeStep defines the new timestep to apply to this world.
  115063. */
  115064. setTimeStep(newTimeStep?: number): void;
  115065. /**
  115066. * Get the time step of the physics engine.
  115067. * @returns the current time step
  115068. */
  115069. getTimeStep(): number;
  115070. /**
  115071. * Release all resources
  115072. */
  115073. dispose(): void;
  115074. /**
  115075. * Gets the name of the current physics plugin
  115076. * @returns the name of the plugin
  115077. */
  115078. getPhysicsPluginName(): string;
  115079. /**
  115080. * Adding a new impostor for the impostor tracking.
  115081. * This will be done by the impostor itself.
  115082. * @param impostor the impostor to add
  115083. */
  115084. addImpostor(impostor: PhysicsImpostor): void;
  115085. /**
  115086. * Remove an impostor from the engine.
  115087. * This impostor and its mesh will not longer be updated by the physics engine.
  115088. * @param impostor the impostor to remove
  115089. */
  115090. removeImpostor(impostor: PhysicsImpostor): void;
  115091. /**
  115092. * Add a joint to the physics engine
  115093. * @param mainImpostor defines the main impostor to which the joint is added.
  115094. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  115095. * @param joint defines the joint that will connect both impostors.
  115096. */
  115097. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115098. /**
  115099. * Removes a joint from the simulation
  115100. * @param mainImpostor defines the impostor used with the joint
  115101. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  115102. * @param joint defines the joint to remove
  115103. */
  115104. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115105. /**
  115106. * Called by the scene. No need to call it.
  115107. * @param delta defines the timespam between frames
  115108. */
  115109. _step(delta: number): void;
  115110. /**
  115111. * Gets the current plugin used to run the simulation
  115112. * @returns current plugin
  115113. */
  115114. getPhysicsPlugin(): IPhysicsEnginePlugin;
  115115. /**
  115116. * Gets the list of physic impostors
  115117. * @returns an array of PhysicsImpostor
  115118. */
  115119. getImpostors(): Array<PhysicsImpostor>;
  115120. /**
  115121. * Gets the impostor for a physics enabled object
  115122. * @param object defines the object impersonated by the impostor
  115123. * @returns the PhysicsImpostor or null if not found
  115124. */
  115125. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  115126. /**
  115127. * Gets the impostor for a physics body object
  115128. * @param body defines physics body used by the impostor
  115129. * @returns the PhysicsImpostor or null if not found
  115130. */
  115131. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  115132. /**
  115133. * Does a raycast in the physics world
  115134. * @param from when should the ray start?
  115135. * @param to when should the ray end?
  115136. * @returns PhysicsRaycastResult
  115137. */
  115138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115139. }
  115140. }
  115141. declare module BABYLON {
  115142. /** @hidden */
  115143. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  115144. private _useDeltaForWorldStep;
  115145. world: any;
  115146. name: string;
  115147. private _physicsMaterials;
  115148. private _fixedTimeStep;
  115149. private _cannonRaycastResult;
  115150. private _raycastResult;
  115151. private _physicsBodysToRemoveAfterStep;
  115152. BJSCANNON: any;
  115153. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  115154. setGravity(gravity: Vector3): void;
  115155. setTimeStep(timeStep: number): void;
  115156. getTimeStep(): number;
  115157. executeStep(delta: number): void;
  115158. private _removeMarkedPhysicsBodiesFromWorld;
  115159. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115160. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115161. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115162. private _processChildMeshes;
  115163. removePhysicsBody(impostor: PhysicsImpostor): void;
  115164. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115165. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115166. private _addMaterial;
  115167. private _checkWithEpsilon;
  115168. private _createShape;
  115169. private _createHeightmap;
  115170. private _minus90X;
  115171. private _plus90X;
  115172. private _tmpPosition;
  115173. private _tmpDeltaPosition;
  115174. private _tmpUnityRotation;
  115175. private _updatePhysicsBodyTransformation;
  115176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115178. isSupported(): boolean;
  115179. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115180. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115181. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115182. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115183. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115184. getBodyMass(impostor: PhysicsImpostor): number;
  115185. getBodyFriction(impostor: PhysicsImpostor): number;
  115186. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115187. getBodyRestitution(impostor: PhysicsImpostor): number;
  115188. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115189. sleepBody(impostor: PhysicsImpostor): void;
  115190. wakeUpBody(impostor: PhysicsImpostor): void;
  115191. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  115192. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115193. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115195. getRadius(impostor: PhysicsImpostor): number;
  115196. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115197. dispose(): void;
  115198. private _extendNamespace;
  115199. /**
  115200. * Does a raycast in the physics world
  115201. * @param from when should the ray start?
  115202. * @param to when should the ray end?
  115203. * @returns PhysicsRaycastResult
  115204. */
  115205. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115206. }
  115207. }
  115208. declare module BABYLON {
  115209. /** @hidden */
  115210. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  115211. world: any;
  115212. name: string;
  115213. BJSOIMO: any;
  115214. private _raycastResult;
  115215. constructor(iterations?: number, oimoInjection?: any);
  115216. setGravity(gravity: Vector3): void;
  115217. setTimeStep(timeStep: number): void;
  115218. getTimeStep(): number;
  115219. private _tmpImpostorsArray;
  115220. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115221. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115222. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115223. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115224. private _tmpPositionVector;
  115225. removePhysicsBody(impostor: PhysicsImpostor): void;
  115226. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115227. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115228. isSupported(): boolean;
  115229. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115230. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115231. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115232. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115235. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115236. getBodyMass(impostor: PhysicsImpostor): number;
  115237. getBodyFriction(impostor: PhysicsImpostor): number;
  115238. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115239. getBodyRestitution(impostor: PhysicsImpostor): number;
  115240. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115241. sleepBody(impostor: PhysicsImpostor): void;
  115242. wakeUpBody(impostor: PhysicsImpostor): void;
  115243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115244. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  115245. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  115246. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115247. getRadius(impostor: PhysicsImpostor): number;
  115248. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115249. dispose(): void;
  115250. /**
  115251. * Does a raycast in the physics world
  115252. * @param from when should the ray start?
  115253. * @param to when should the ray end?
  115254. * @returns PhysicsRaycastResult
  115255. */
  115256. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115257. }
  115258. }
  115259. declare module BABYLON {
  115260. /**
  115261. * Class containing static functions to help procedurally build meshes
  115262. */
  115263. export class RibbonBuilder {
  115264. /**
  115265. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115266. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115267. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115268. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115269. * * 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
  115270. * * 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
  115271. * * 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
  115272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115275. * * 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
  115276. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115277. * * 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
  115278. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115280. * @param name defines the name of the mesh
  115281. * @param options defines the options used to create the mesh
  115282. * @param scene defines the hosting scene
  115283. * @returns the ribbon mesh
  115284. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115285. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115286. */
  115287. static CreateRibbon(name: string, options: {
  115288. pathArray: Vector3[][];
  115289. closeArray?: boolean;
  115290. closePath?: boolean;
  115291. offset?: number;
  115292. updatable?: boolean;
  115293. sideOrientation?: number;
  115294. frontUVs?: Vector4;
  115295. backUVs?: Vector4;
  115296. instance?: Mesh;
  115297. invertUV?: boolean;
  115298. uvs?: Vector2[];
  115299. colors?: Color4[];
  115300. }, scene?: Nullable<Scene>): Mesh;
  115301. }
  115302. }
  115303. declare module BABYLON {
  115304. /**
  115305. * Class containing static functions to help procedurally build meshes
  115306. */
  115307. export class ShapeBuilder {
  115308. /**
  115309. * 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.
  115310. * * 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.
  115311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115312. * * 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.
  115313. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115314. * * 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
  115315. * * 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
  115316. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115319. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115321. * @param name defines the name of the mesh
  115322. * @param options defines the options used to create the mesh
  115323. * @param scene defines the hosting scene
  115324. * @returns the extruded shape mesh
  115325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115327. */
  115328. static ExtrudeShape(name: string, options: {
  115329. shape: Vector3[];
  115330. path: Vector3[];
  115331. scale?: number;
  115332. rotation?: number;
  115333. cap?: number;
  115334. updatable?: boolean;
  115335. sideOrientation?: number;
  115336. frontUVs?: Vector4;
  115337. backUVs?: Vector4;
  115338. instance?: Mesh;
  115339. invertUV?: boolean;
  115340. }, scene?: Nullable<Scene>): Mesh;
  115341. /**
  115342. * Creates an custom extruded shape mesh.
  115343. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115344. * * 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.
  115345. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115346. * * 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
  115347. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115348. * * 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
  115349. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115350. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115351. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115352. * * 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
  115353. * * 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
  115354. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115359. * @param name defines the name of the mesh
  115360. * @param options defines the options used to create the mesh
  115361. * @param scene defines the hosting scene
  115362. * @returns the custom extruded shape mesh
  115363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115366. */
  115367. static ExtrudeShapeCustom(name: string, options: {
  115368. shape: Vector3[];
  115369. path: Vector3[];
  115370. scaleFunction?: any;
  115371. rotationFunction?: any;
  115372. ribbonCloseArray?: boolean;
  115373. ribbonClosePath?: boolean;
  115374. cap?: number;
  115375. updatable?: boolean;
  115376. sideOrientation?: number;
  115377. frontUVs?: Vector4;
  115378. backUVs?: Vector4;
  115379. instance?: Mesh;
  115380. invertUV?: boolean;
  115381. }, scene?: Nullable<Scene>): Mesh;
  115382. private static _ExtrudeShapeGeneric;
  115383. }
  115384. }
  115385. declare module BABYLON {
  115386. /**
  115387. * AmmoJS Physics plugin
  115388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115389. * @see https://github.com/kripken/ammo.js/
  115390. */
  115391. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  115392. private _useDeltaForWorldStep;
  115393. /**
  115394. * Reference to the Ammo library
  115395. */
  115396. bjsAMMO: any;
  115397. /**
  115398. * Created ammoJS world which physics bodies are added to
  115399. */
  115400. world: any;
  115401. /**
  115402. * Name of the plugin
  115403. */
  115404. name: string;
  115405. private _timeStep;
  115406. private _fixedTimeStep;
  115407. private _maxSteps;
  115408. private _tmpQuaternion;
  115409. private _tmpAmmoTransform;
  115410. private _tmpAmmoQuaternion;
  115411. private _tmpAmmoConcreteContactResultCallback;
  115412. private _collisionConfiguration;
  115413. private _dispatcher;
  115414. private _overlappingPairCache;
  115415. private _solver;
  115416. private _softBodySolver;
  115417. private _tmpAmmoVectorA;
  115418. private _tmpAmmoVectorB;
  115419. private _tmpAmmoVectorC;
  115420. private _tmpAmmoVectorD;
  115421. private _tmpContactCallbackResult;
  115422. private _tmpAmmoVectorRCA;
  115423. private _tmpAmmoVectorRCB;
  115424. private _raycastResult;
  115425. private static readonly DISABLE_COLLISION_FLAG;
  115426. private static readonly KINEMATIC_FLAG;
  115427. private static readonly DISABLE_DEACTIVATION_FLAG;
  115428. /**
  115429. * Initializes the ammoJS plugin
  115430. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  115431. * @param ammoInjection can be used to inject your own ammo reference
  115432. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  115433. */
  115434. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  115435. /**
  115436. * Sets the gravity of the physics world (m/(s^2))
  115437. * @param gravity Gravity to set
  115438. */
  115439. setGravity(gravity: Vector3): void;
  115440. /**
  115441. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  115442. * @param timeStep timestep to use in seconds
  115443. */
  115444. setTimeStep(timeStep: number): void;
  115445. /**
  115446. * 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)
  115447. * @param fixedTimeStep fixedTimeStep to use in seconds
  115448. */
  115449. setFixedTimeStep(fixedTimeStep: number): void;
  115450. /**
  115451. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  115452. * @param maxSteps the maximum number of steps by the physics engine per frame
  115453. */
  115454. setMaxSteps(maxSteps: number): void;
  115455. /**
  115456. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  115457. * @returns the current timestep in seconds
  115458. */
  115459. getTimeStep(): number;
  115460. private _isImpostorInContact;
  115461. private _isImpostorPairInContact;
  115462. private _stepSimulation;
  115463. /**
  115464. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  115465. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  115466. * After the step the babylon meshes are set to the position of the physics imposters
  115467. * @param delta amount of time to step forward
  115468. * @param impostors array of imposters to update before/after the step
  115469. */
  115470. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115471. /**
  115472. * Update babylon mesh to match physics world object
  115473. * @param impostor imposter to match
  115474. */
  115475. private _afterSoftStep;
  115476. /**
  115477. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115478. * @param impostor imposter to match
  115479. */
  115480. private _ropeStep;
  115481. /**
  115482. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115483. * @param impostor imposter to match
  115484. */
  115485. private _softbodyOrClothStep;
  115486. private _tmpVector;
  115487. private _tmpMatrix;
  115488. /**
  115489. * Applies an impulse on the imposter
  115490. * @param impostor imposter to apply impulse to
  115491. * @param force amount of force to be applied to the imposter
  115492. * @param contactPoint the location to apply the impulse on the imposter
  115493. */
  115494. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115495. /**
  115496. * Applies a force on the imposter
  115497. * @param impostor imposter to apply force
  115498. * @param force amount of force to be applied to the imposter
  115499. * @param contactPoint the location to apply the force on the imposter
  115500. */
  115501. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115502. /**
  115503. * Creates a physics body using the plugin
  115504. * @param impostor the imposter to create the physics body on
  115505. */
  115506. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115507. /**
  115508. * Removes the physics body from the imposter and disposes of the body's memory
  115509. * @param impostor imposter to remove the physics body from
  115510. */
  115511. removePhysicsBody(impostor: PhysicsImpostor): void;
  115512. /**
  115513. * Generates a joint
  115514. * @param impostorJoint the imposter joint to create the joint with
  115515. */
  115516. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115517. /**
  115518. * Removes a joint
  115519. * @param impostorJoint the imposter joint to remove the joint from
  115520. */
  115521. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115522. private _addMeshVerts;
  115523. /**
  115524. * Initialise the soft body vertices to match its object's (mesh) vertices
  115525. * Softbody vertices (nodes) are in world space and to match this
  115526. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  115527. * @param impostor to create the softbody for
  115528. */
  115529. private _softVertexData;
  115530. /**
  115531. * Create an impostor's soft body
  115532. * @param impostor to create the softbody for
  115533. */
  115534. private _createSoftbody;
  115535. /**
  115536. * Create cloth for an impostor
  115537. * @param impostor to create the softbody for
  115538. */
  115539. private _createCloth;
  115540. /**
  115541. * Create rope for an impostor
  115542. * @param impostor to create the softbody for
  115543. */
  115544. private _createRope;
  115545. private _addHullVerts;
  115546. private _createShape;
  115547. /**
  115548. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  115549. * @param impostor imposter containing the physics body and babylon object
  115550. */
  115551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115552. /**
  115553. * Sets the babylon object's position/rotation from the physics body's position/rotation
  115554. * @param impostor imposter containing the physics body and babylon object
  115555. * @param newPosition new position
  115556. * @param newRotation new rotation
  115557. */
  115558. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115559. /**
  115560. * If this plugin is supported
  115561. * @returns true if its supported
  115562. */
  115563. isSupported(): boolean;
  115564. /**
  115565. * Sets the linear velocity of the physics body
  115566. * @param impostor imposter to set the velocity on
  115567. * @param velocity velocity to set
  115568. */
  115569. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115570. /**
  115571. * Sets the angular velocity of the physics body
  115572. * @param impostor imposter to set the velocity on
  115573. * @param velocity velocity to set
  115574. */
  115575. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115576. /**
  115577. * gets the linear velocity
  115578. * @param impostor imposter to get linear velocity from
  115579. * @returns linear velocity
  115580. */
  115581. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115582. /**
  115583. * gets the angular velocity
  115584. * @param impostor imposter to get angular velocity from
  115585. * @returns angular velocity
  115586. */
  115587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115588. /**
  115589. * Sets the mass of physics body
  115590. * @param impostor imposter to set the mass on
  115591. * @param mass mass to set
  115592. */
  115593. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115594. /**
  115595. * Gets the mass of the physics body
  115596. * @param impostor imposter to get the mass from
  115597. * @returns mass
  115598. */
  115599. getBodyMass(impostor: PhysicsImpostor): number;
  115600. /**
  115601. * Gets friction of the impostor
  115602. * @param impostor impostor to get friction from
  115603. * @returns friction value
  115604. */
  115605. getBodyFriction(impostor: PhysicsImpostor): number;
  115606. /**
  115607. * Sets friction of the impostor
  115608. * @param impostor impostor to set friction on
  115609. * @param friction friction value
  115610. */
  115611. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115612. /**
  115613. * Gets restitution of the impostor
  115614. * @param impostor impostor to get restitution from
  115615. * @returns restitution value
  115616. */
  115617. getBodyRestitution(impostor: PhysicsImpostor): number;
  115618. /**
  115619. * Sets resitution of the impostor
  115620. * @param impostor impostor to set resitution on
  115621. * @param restitution resitution value
  115622. */
  115623. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115624. /**
  115625. * Gets pressure inside the impostor
  115626. * @param impostor impostor to get pressure from
  115627. * @returns pressure value
  115628. */
  115629. getBodyPressure(impostor: PhysicsImpostor): number;
  115630. /**
  115631. * Sets pressure inside a soft body impostor
  115632. * Cloth and rope must remain 0 pressure
  115633. * @param impostor impostor to set pressure on
  115634. * @param pressure pressure value
  115635. */
  115636. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115637. /**
  115638. * Gets stiffness of the impostor
  115639. * @param impostor impostor to get stiffness from
  115640. * @returns pressure value
  115641. */
  115642. getBodyStiffness(impostor: PhysicsImpostor): number;
  115643. /**
  115644. * Sets stiffness of the impostor
  115645. * @param impostor impostor to set stiffness on
  115646. * @param stiffness stiffness value from 0 to 1
  115647. */
  115648. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115649. /**
  115650. * Gets velocityIterations of the impostor
  115651. * @param impostor impostor to get velocity iterations from
  115652. * @returns velocityIterations value
  115653. */
  115654. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115655. /**
  115656. * Sets velocityIterations of the impostor
  115657. * @param impostor impostor to set velocity iterations on
  115658. * @param velocityIterations velocityIterations value
  115659. */
  115660. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115661. /**
  115662. * Gets positionIterations of the impostor
  115663. * @param impostor impostor to get position iterations from
  115664. * @returns positionIterations value
  115665. */
  115666. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115667. /**
  115668. * Sets positionIterations of the impostor
  115669. * @param impostor impostor to set position on
  115670. * @param positionIterations positionIterations value
  115671. */
  115672. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115673. /**
  115674. * Append an anchor to a cloth object
  115675. * @param impostor is the cloth impostor to add anchor to
  115676. * @param otherImpostor is the rigid impostor to anchor to
  115677. * @param width ratio across width from 0 to 1
  115678. * @param height ratio up height from 0 to 1
  115679. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115680. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115681. */
  115682. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115683. /**
  115684. * Append an hook to a rope object
  115685. * @param impostor is the rope impostor to add hook to
  115686. * @param otherImpostor is the rigid impostor to hook to
  115687. * @param length ratio along the rope from 0 to 1
  115688. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115689. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115690. */
  115691. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115692. /**
  115693. * Sleeps the physics body and stops it from being active
  115694. * @param impostor impostor to sleep
  115695. */
  115696. sleepBody(impostor: PhysicsImpostor): void;
  115697. /**
  115698. * Activates the physics body
  115699. * @param impostor impostor to activate
  115700. */
  115701. wakeUpBody(impostor: PhysicsImpostor): void;
  115702. /**
  115703. * Updates the distance parameters of the joint
  115704. * @param joint joint to update
  115705. * @param maxDistance maximum distance of the joint
  115706. * @param minDistance minimum distance of the joint
  115707. */
  115708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115709. /**
  115710. * Sets a motor on the joint
  115711. * @param joint joint to set motor on
  115712. * @param speed speed of the motor
  115713. * @param maxForce maximum force of the motor
  115714. * @param motorIndex index of the motor
  115715. */
  115716. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115717. /**
  115718. * Sets the motors limit
  115719. * @param joint joint to set limit on
  115720. * @param upperLimit upper limit
  115721. * @param lowerLimit lower limit
  115722. */
  115723. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115724. /**
  115725. * Syncs the position and rotation of a mesh with the impostor
  115726. * @param mesh mesh to sync
  115727. * @param impostor impostor to update the mesh with
  115728. */
  115729. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115730. /**
  115731. * Gets the radius of the impostor
  115732. * @param impostor impostor to get radius from
  115733. * @returns the radius
  115734. */
  115735. getRadius(impostor: PhysicsImpostor): number;
  115736. /**
  115737. * Gets the box size of the impostor
  115738. * @param impostor impostor to get box size from
  115739. * @param result the resulting box size
  115740. */
  115741. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115742. /**
  115743. * Disposes of the impostor
  115744. */
  115745. dispose(): void;
  115746. /**
  115747. * Does a raycast in the physics world
  115748. * @param from when should the ray start?
  115749. * @param to when should the ray end?
  115750. * @returns PhysicsRaycastResult
  115751. */
  115752. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115753. }
  115754. }
  115755. declare module BABYLON {
  115756. interface AbstractScene {
  115757. /**
  115758. * The list of reflection probes added to the scene
  115759. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115760. */
  115761. reflectionProbes: Array<ReflectionProbe>;
  115762. /**
  115763. * Removes the given reflection probe from this scene.
  115764. * @param toRemove The reflection probe to remove
  115765. * @returns The index of the removed reflection probe
  115766. */
  115767. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115768. /**
  115769. * Adds the given reflection probe to this scene.
  115770. * @param newReflectionProbe The reflection probe to add
  115771. */
  115772. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115773. }
  115774. /**
  115775. * Class used to generate realtime reflection / refraction cube textures
  115776. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115777. */
  115778. export class ReflectionProbe {
  115779. /** defines the name of the probe */
  115780. name: string;
  115781. private _scene;
  115782. private _renderTargetTexture;
  115783. private _projectionMatrix;
  115784. private _viewMatrix;
  115785. private _target;
  115786. private _add;
  115787. private _attachedMesh;
  115788. private _invertYAxis;
  115789. /** Gets or sets probe position (center of the cube map) */
  115790. position: Vector3;
  115791. /**
  115792. * Creates a new reflection probe
  115793. * @param name defines the name of the probe
  115794. * @param size defines the texture resolution (for each face)
  115795. * @param scene defines the hosting scene
  115796. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115797. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115798. */
  115799. constructor(
  115800. /** defines the name of the probe */
  115801. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115802. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115803. samples: number;
  115804. /** Gets or sets the refresh rate to use (on every frame by default) */
  115805. refreshRate: number;
  115806. /**
  115807. * Gets the hosting scene
  115808. * @returns a Scene
  115809. */
  115810. getScene(): Scene;
  115811. /** Gets the internal CubeTexture used to render to */
  115812. readonly cubeTexture: RenderTargetTexture;
  115813. /** Gets the list of meshes to render */
  115814. readonly renderList: Nullable<AbstractMesh[]>;
  115815. /**
  115816. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115817. * @param mesh defines the mesh to attach to
  115818. */
  115819. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115820. /**
  115821. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115822. * @param renderingGroupId The rendering group id corresponding to its index
  115823. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115824. */
  115825. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115826. /**
  115827. * Clean all associated resources
  115828. */
  115829. dispose(): void;
  115830. /**
  115831. * Converts the reflection probe information to a readable string for debug purpose.
  115832. * @param fullDetails Supports for multiple levels of logging within scene loading
  115833. * @returns the human readable reflection probe info
  115834. */
  115835. toString(fullDetails?: boolean): string;
  115836. /**
  115837. * Get the class name of the relfection probe.
  115838. * @returns "ReflectionProbe"
  115839. */
  115840. getClassName(): string;
  115841. /**
  115842. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115843. * @returns The JSON representation of the texture
  115844. */
  115845. serialize(): any;
  115846. /**
  115847. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115848. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115849. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115850. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115851. * @returns The parsed reflection probe if successful
  115852. */
  115853. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115854. }
  115855. }
  115856. declare module BABYLON {
  115857. /** @hidden */
  115858. export var _BabylonLoaderRegistered: boolean;
  115859. }
  115860. declare module BABYLON {
  115861. /**
  115862. * The Physically based simple base material of BJS.
  115863. *
  115864. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115865. * It is used as the base class for both the specGloss and metalRough conventions.
  115866. */
  115867. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115868. /**
  115869. * Number of Simultaneous lights allowed on the material.
  115870. */
  115871. maxSimultaneousLights: number;
  115872. /**
  115873. * If sets to true, disables all the lights affecting the material.
  115874. */
  115875. disableLighting: boolean;
  115876. /**
  115877. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115878. */
  115879. environmentTexture: BaseTexture;
  115880. /**
  115881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115882. */
  115883. invertNormalMapX: boolean;
  115884. /**
  115885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115886. */
  115887. invertNormalMapY: boolean;
  115888. /**
  115889. * Normal map used in the model.
  115890. */
  115891. normalTexture: BaseTexture;
  115892. /**
  115893. * Emissivie color used to self-illuminate the model.
  115894. */
  115895. emissiveColor: Color3;
  115896. /**
  115897. * Emissivie texture used to self-illuminate the model.
  115898. */
  115899. emissiveTexture: BaseTexture;
  115900. /**
  115901. * Occlusion Channel Strenght.
  115902. */
  115903. occlusionStrength: number;
  115904. /**
  115905. * Occlusion Texture of the material (adding extra occlusion effects).
  115906. */
  115907. occlusionTexture: BaseTexture;
  115908. /**
  115909. * Defines the alpha limits in alpha test mode.
  115910. */
  115911. alphaCutOff: number;
  115912. /**
  115913. * Gets the current double sided mode.
  115914. */
  115915. /**
  115916. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115917. */
  115918. doubleSided: boolean;
  115919. /**
  115920. * Stores the pre-calculated light information of a mesh in a texture.
  115921. */
  115922. lightmapTexture: BaseTexture;
  115923. /**
  115924. * If true, the light map contains occlusion information instead of lighting info.
  115925. */
  115926. useLightmapAsShadowmap: boolean;
  115927. /**
  115928. * Instantiates a new PBRMaterial instance.
  115929. *
  115930. * @param name The material name
  115931. * @param scene The scene the material will be use in.
  115932. */
  115933. constructor(name: string, scene: Scene);
  115934. getClassName(): string;
  115935. }
  115936. }
  115937. declare module BABYLON {
  115938. /**
  115939. * The PBR material of BJS following the metal roughness convention.
  115940. *
  115941. * This fits to the PBR convention in the GLTF definition:
  115942. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115943. */
  115944. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115945. /**
  115946. * The base color has two different interpretations depending on the value of metalness.
  115947. * When the material is a metal, the base color is the specific measured reflectance value
  115948. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115949. * of the material.
  115950. */
  115951. baseColor: Color3;
  115952. /**
  115953. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115954. * well as opacity information in the alpha channel.
  115955. */
  115956. baseTexture: BaseTexture;
  115957. /**
  115958. * Specifies the metallic scalar value of the material.
  115959. * Can also be used to scale the metalness values of the metallic texture.
  115960. */
  115961. metallic: number;
  115962. /**
  115963. * Specifies the roughness scalar value of the material.
  115964. * Can also be used to scale the roughness values of the metallic texture.
  115965. */
  115966. roughness: number;
  115967. /**
  115968. * Texture containing both the metallic value in the B channel and the
  115969. * roughness value in the G channel to keep better precision.
  115970. */
  115971. metallicRoughnessTexture: BaseTexture;
  115972. /**
  115973. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115974. *
  115975. * @param name The material name
  115976. * @param scene The scene the material will be use in.
  115977. */
  115978. constructor(name: string, scene: Scene);
  115979. /**
  115980. * Return the currrent class name of the material.
  115981. */
  115982. getClassName(): string;
  115983. /**
  115984. * Makes a duplicate of the current material.
  115985. * @param name - name to use for the new material.
  115986. */
  115987. clone(name: string): PBRMetallicRoughnessMaterial;
  115988. /**
  115989. * Serialize the material to a parsable JSON object.
  115990. */
  115991. serialize(): any;
  115992. /**
  115993. * Parses a JSON object correponding to the serialize function.
  115994. */
  115995. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115996. }
  115997. }
  115998. declare module BABYLON {
  115999. /**
  116000. * The PBR material of BJS following the specular glossiness convention.
  116001. *
  116002. * This fits to the PBR convention in the GLTF definition:
  116003. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  116004. */
  116005. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  116006. /**
  116007. * Specifies the diffuse color of the material.
  116008. */
  116009. diffuseColor: Color3;
  116010. /**
  116011. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  116012. * channel.
  116013. */
  116014. diffuseTexture: BaseTexture;
  116015. /**
  116016. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  116017. */
  116018. specularColor: Color3;
  116019. /**
  116020. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  116021. */
  116022. glossiness: number;
  116023. /**
  116024. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  116025. */
  116026. specularGlossinessTexture: BaseTexture;
  116027. /**
  116028. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  116029. *
  116030. * @param name The material name
  116031. * @param scene The scene the material will be use in.
  116032. */
  116033. constructor(name: string, scene: Scene);
  116034. /**
  116035. * Return the currrent class name of the material.
  116036. */
  116037. getClassName(): string;
  116038. /**
  116039. * Makes a duplicate of the current material.
  116040. * @param name - name to use for the new material.
  116041. */
  116042. clone(name: string): PBRSpecularGlossinessMaterial;
  116043. /**
  116044. * Serialize the material to a parsable JSON object.
  116045. */
  116046. serialize(): any;
  116047. /**
  116048. * Parses a JSON object correponding to the serialize function.
  116049. */
  116050. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  116051. }
  116052. }
  116053. declare module BABYLON {
  116054. /**
  116055. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  116056. * It can help converting any input color in a desired output one. This can then be used to create effects
  116057. * from sepia, black and white to sixties or futuristic rendering...
  116058. *
  116059. * The only supported format is currently 3dl.
  116060. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  116061. */
  116062. export class ColorGradingTexture extends BaseTexture {
  116063. /**
  116064. * The current texture matrix. (will always be identity in color grading texture)
  116065. */
  116066. private _textureMatrix;
  116067. /**
  116068. * The texture URL.
  116069. */
  116070. url: string;
  116071. /**
  116072. * Empty line regex stored for GC.
  116073. */
  116074. private static _noneEmptyLineRegex;
  116075. private _engine;
  116076. /**
  116077. * Instantiates a ColorGradingTexture from the following parameters.
  116078. *
  116079. * @param url The location of the color gradind data (currently only supporting 3dl)
  116080. * @param scene The scene the texture will be used in
  116081. */
  116082. constructor(url: string, scene: Scene);
  116083. /**
  116084. * Returns the texture matrix used in most of the material.
  116085. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  116086. */
  116087. getTextureMatrix(): Matrix;
  116088. /**
  116089. * Occurs when the file being loaded is a .3dl LUT file.
  116090. */
  116091. private load3dlTexture;
  116092. /**
  116093. * Starts the loading process of the texture.
  116094. */
  116095. private loadTexture;
  116096. /**
  116097. * Clones the color gradind texture.
  116098. */
  116099. clone(): ColorGradingTexture;
  116100. /**
  116101. * Called during delayed load for textures.
  116102. */
  116103. delayLoad(): void;
  116104. /**
  116105. * Parses a color grading texture serialized by Babylon.
  116106. * @param parsedTexture The texture information being parsedTexture
  116107. * @param scene The scene to load the texture in
  116108. * @param rootUrl The root url of the data assets to load
  116109. * @return A color gradind texture
  116110. */
  116111. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  116112. /**
  116113. * Serializes the LUT texture to json format.
  116114. */
  116115. serialize(): any;
  116116. }
  116117. }
  116118. declare module BABYLON {
  116119. /**
  116120. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  116121. */
  116122. export class EquiRectangularCubeTexture extends BaseTexture {
  116123. /** The six faces of the cube. */
  116124. private static _FacesMapping;
  116125. private _noMipmap;
  116126. private _onLoad;
  116127. private _onError;
  116128. /** The size of the cubemap. */
  116129. private _size;
  116130. /** The buffer of the image. */
  116131. private _buffer;
  116132. /** The width of the input image. */
  116133. private _width;
  116134. /** The height of the input image. */
  116135. private _height;
  116136. /** The URL to the image. */
  116137. url: string;
  116138. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  116139. coordinatesMode: number;
  116140. /**
  116141. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  116142. * @param url The location of the image
  116143. * @param scene The scene the texture will be used in
  116144. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116145. * @param noMipmap Forces to not generate the mipmap if true
  116146. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  116147. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  116148. * @param onLoad — defines a callback called when texture is loaded
  116149. * @param onError — defines a callback called if there is an error
  116150. */
  116151. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  116152. /**
  116153. * Load the image data, by putting the image on a canvas and extracting its buffer.
  116154. */
  116155. private loadImage;
  116156. /**
  116157. * Convert the image buffer into a cubemap and create a CubeTexture.
  116158. */
  116159. private loadTexture;
  116160. /**
  116161. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  116162. * @param buffer The ArrayBuffer that should be converted.
  116163. * @returns The buffer as Float32Array.
  116164. */
  116165. private getFloat32ArrayFromArrayBuffer;
  116166. /**
  116167. * Get the current class name of the texture useful for serialization or dynamic coding.
  116168. * @returns "EquiRectangularCubeTexture"
  116169. */
  116170. getClassName(): string;
  116171. /**
  116172. * Create a clone of the current EquiRectangularCubeTexture and return it.
  116173. * @returns A clone of the current EquiRectangularCubeTexture.
  116174. */
  116175. clone(): EquiRectangularCubeTexture;
  116176. }
  116177. }
  116178. declare module BABYLON {
  116179. /**
  116180. * Based on jsTGALoader - Javascript loader for TGA file
  116181. * By Vincent Thibault
  116182. * @see http://blog.robrowser.com/javascript-tga-loader.html
  116183. */
  116184. export class TGATools {
  116185. private static _TYPE_INDEXED;
  116186. private static _TYPE_RGB;
  116187. private static _TYPE_GREY;
  116188. private static _TYPE_RLE_INDEXED;
  116189. private static _TYPE_RLE_RGB;
  116190. private static _TYPE_RLE_GREY;
  116191. private static _ORIGIN_MASK;
  116192. private static _ORIGIN_SHIFT;
  116193. private static _ORIGIN_BL;
  116194. private static _ORIGIN_BR;
  116195. private static _ORIGIN_UL;
  116196. private static _ORIGIN_UR;
  116197. /**
  116198. * Gets the header of a TGA file
  116199. * @param data defines the TGA data
  116200. * @returns the header
  116201. */
  116202. static GetTGAHeader(data: Uint8Array): any;
  116203. /**
  116204. * Uploads TGA content to a Babylon Texture
  116205. * @hidden
  116206. */
  116207. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  116208. /** @hidden */
  116209. 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;
  116210. /** @hidden */
  116211. 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;
  116212. /** @hidden */
  116213. 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;
  116214. /** @hidden */
  116215. 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;
  116216. /** @hidden */
  116217. 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;
  116218. /** @hidden */
  116219. 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;
  116220. }
  116221. }
  116222. declare module BABYLON {
  116223. /**
  116224. * Implementation of the TGA Texture Loader.
  116225. * @hidden
  116226. */
  116227. export class _TGATextureLoader implements IInternalTextureLoader {
  116228. /**
  116229. * Defines wether the loader supports cascade loading the different faces.
  116230. */
  116231. readonly supportCascades: boolean;
  116232. /**
  116233. * This returns if the loader support the current file information.
  116234. * @param extension defines the file extension of the file being loaded
  116235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116236. * @param fallback defines the fallback internal texture if any
  116237. * @param isBase64 defines whether the texture is encoded as a base64
  116238. * @param isBuffer defines whether the texture data are stored as a buffer
  116239. * @returns true if the loader can load the specified file
  116240. */
  116241. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116242. /**
  116243. * Transform the url before loading if required.
  116244. * @param rootUrl the url of the texture
  116245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116246. * @returns the transformed texture
  116247. */
  116248. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116249. /**
  116250. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116251. * @param rootUrl the url of the texture
  116252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116253. * @returns the fallback texture
  116254. */
  116255. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116256. /**
  116257. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116258. * @param data contains the texture data
  116259. * @param texture defines the BabylonJS internal texture
  116260. * @param createPolynomials will be true if polynomials have been requested
  116261. * @param onLoad defines the callback to trigger once the texture is ready
  116262. * @param onError defines the callback to trigger in case of error
  116263. */
  116264. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116265. /**
  116266. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116267. * @param data contains the texture data
  116268. * @param texture defines the BabylonJS internal texture
  116269. * @param callback defines the method to call once ready to upload
  116270. */
  116271. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116272. }
  116273. }
  116274. declare module BABYLON {
  116275. /**
  116276. * Info about the .basis files
  116277. */
  116278. class BasisFileInfo {
  116279. /**
  116280. * If the file has alpha
  116281. */
  116282. hasAlpha: boolean;
  116283. /**
  116284. * Info about each image of the basis file
  116285. */
  116286. images: Array<{
  116287. levels: Array<{
  116288. width: number;
  116289. height: number;
  116290. transcodedPixels: ArrayBufferView;
  116291. }>;
  116292. }>;
  116293. }
  116294. /**
  116295. * Result of transcoding a basis file
  116296. */
  116297. class TranscodeResult {
  116298. /**
  116299. * Info about the .basis file
  116300. */
  116301. fileInfo: BasisFileInfo;
  116302. /**
  116303. * Format to use when loading the file
  116304. */
  116305. format: number;
  116306. }
  116307. /**
  116308. * Configuration options for the Basis transcoder
  116309. */
  116310. export class BasisTranscodeConfiguration {
  116311. /**
  116312. * Supported compression formats used to determine the supported output format of the transcoder
  116313. */
  116314. supportedCompressionFormats?: {
  116315. /**
  116316. * etc1 compression format
  116317. */
  116318. etc1?: boolean;
  116319. /**
  116320. * s3tc compression format
  116321. */
  116322. s3tc?: boolean;
  116323. /**
  116324. * pvrtc compression format
  116325. */
  116326. pvrtc?: boolean;
  116327. /**
  116328. * etc2 compression format
  116329. */
  116330. etc2?: boolean;
  116331. };
  116332. /**
  116333. * If mipmap levels should be loaded for transcoded images (Default: true)
  116334. */
  116335. loadMipmapLevels?: boolean;
  116336. /**
  116337. * Index of a single image to load (Default: all images)
  116338. */
  116339. loadSingleImage?: number;
  116340. }
  116341. /**
  116342. * Used to load .Basis files
  116343. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  116344. */
  116345. export class BasisTools {
  116346. private static _IgnoreSupportedFormats;
  116347. /**
  116348. * URL to use when loading the basis transcoder
  116349. */
  116350. static JSModuleURL: string;
  116351. /**
  116352. * URL to use when loading the wasm module for the transcoder
  116353. */
  116354. static WasmModuleURL: string;
  116355. /**
  116356. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  116357. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  116358. * @returns internal format corresponding to the Basis format
  116359. */
  116360. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  116361. private static _WorkerPromise;
  116362. private static _Worker;
  116363. private static _actionId;
  116364. private static _CreateWorkerAsync;
  116365. /**
  116366. * Transcodes a loaded image file to compressed pixel data
  116367. * @param imageData image data to transcode
  116368. * @param config configuration options for the transcoding
  116369. * @returns a promise resulting in the transcoded image
  116370. */
  116371. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  116372. /**
  116373. * Loads a texture from the transcode result
  116374. * @param texture texture load to
  116375. * @param transcodeResult the result of transcoding the basis file to load from
  116376. */
  116377. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  116378. }
  116379. }
  116380. declare module BABYLON {
  116381. /**
  116382. * Loader for .basis file format
  116383. */
  116384. export class _BasisTextureLoader implements IInternalTextureLoader {
  116385. /**
  116386. * Defines whether the loader supports cascade loading the different faces.
  116387. */
  116388. readonly supportCascades: boolean;
  116389. /**
  116390. * This returns if the loader support the current file information.
  116391. * @param extension defines the file extension of the file being loaded
  116392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116393. * @param fallback defines the fallback internal texture if any
  116394. * @param isBase64 defines whether the texture is encoded as a base64
  116395. * @param isBuffer defines whether the texture data are stored as a buffer
  116396. * @returns true if the loader can load the specified file
  116397. */
  116398. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116399. /**
  116400. * Transform the url before loading if required.
  116401. * @param rootUrl the url of the texture
  116402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116403. * @returns the transformed texture
  116404. */
  116405. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116406. /**
  116407. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116408. * @param rootUrl the url of the texture
  116409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116410. * @returns the fallback texture
  116411. */
  116412. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116413. /**
  116414. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  116415. * @param data contains the texture data
  116416. * @param texture defines the BabylonJS internal texture
  116417. * @param createPolynomials will be true if polynomials have been requested
  116418. * @param onLoad defines the callback to trigger once the texture is ready
  116419. * @param onError defines the callback to trigger in case of error
  116420. */
  116421. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116422. /**
  116423. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116424. * @param data contains the texture data
  116425. * @param texture defines the BabylonJS internal texture
  116426. * @param callback defines the method to call once ready to upload
  116427. */
  116428. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116429. }
  116430. }
  116431. declare module BABYLON {
  116432. /**
  116433. * 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.
  116434. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116435. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116436. */
  116437. export class CustomProceduralTexture extends ProceduralTexture {
  116438. private _animate;
  116439. private _time;
  116440. private _config;
  116441. private _texturePath;
  116442. /**
  116443. * Instantiates a new Custom Procedural Texture.
  116444. * 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.
  116445. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116446. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116447. * @param name Define the name of the texture
  116448. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  116449. * @param size Define the size of the texture to create
  116450. * @param scene Define the scene the texture belongs to
  116451. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  116452. * @param generateMipMaps Define if the texture should creates mip maps or not
  116453. */
  116454. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116455. private _loadJson;
  116456. /**
  116457. * Is the texture ready to be used ? (rendered at least once)
  116458. * @returns true if ready, otherwise, false.
  116459. */
  116460. isReady(): boolean;
  116461. /**
  116462. * Render the texture to its associated render target.
  116463. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  116464. */
  116465. render(useCameraPostProcess?: boolean): void;
  116466. /**
  116467. * Update the list of dependant textures samplers in the shader.
  116468. */
  116469. updateTextures(): void;
  116470. /**
  116471. * Update the uniform values of the procedural texture in the shader.
  116472. */
  116473. updateShaderUniforms(): void;
  116474. /**
  116475. * Define if the texture animates or not.
  116476. */
  116477. animate: boolean;
  116478. }
  116479. }
  116480. declare module BABYLON {
  116481. /** @hidden */
  116482. export var noisePixelShader: {
  116483. name: string;
  116484. shader: string;
  116485. };
  116486. }
  116487. declare module BABYLON {
  116488. /**
  116489. * Class used to generate noise procedural textures
  116490. */
  116491. export class NoiseProceduralTexture extends ProceduralTexture {
  116492. private _time;
  116493. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  116494. brightness: number;
  116495. /** Defines the number of octaves to process */
  116496. octaves: number;
  116497. /** Defines the level of persistence (0.8 by default) */
  116498. persistence: number;
  116499. /** Gets or sets animation speed factor (default is 1) */
  116500. animationSpeedFactor: number;
  116501. /**
  116502. * Creates a new NoiseProceduralTexture
  116503. * @param name defines the name fo the texture
  116504. * @param size defines the size of the texture (default is 256)
  116505. * @param scene defines the hosting scene
  116506. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  116507. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  116508. */
  116509. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116510. private _updateShaderUniforms;
  116511. protected _getDefines(): string;
  116512. /** Generate the current state of the procedural texture */
  116513. render(useCameraPostProcess?: boolean): void;
  116514. /**
  116515. * Serializes this noise procedural texture
  116516. * @returns a serialized noise procedural texture object
  116517. */
  116518. serialize(): any;
  116519. /**
  116520. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  116521. * @param parsedTexture defines parsed texture data
  116522. * @param scene defines the current scene
  116523. * @param rootUrl defines the root URL containing noise procedural texture information
  116524. * @returns a parsed NoiseProceduralTexture
  116525. */
  116526. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  116527. }
  116528. }
  116529. declare module BABYLON {
  116530. /**
  116531. * Raw cube texture where the raw buffers are passed in
  116532. */
  116533. export class RawCubeTexture extends CubeTexture {
  116534. /**
  116535. * Creates a cube texture where the raw buffers are passed in.
  116536. * @param scene defines the scene the texture is attached to
  116537. * @param data defines the array of data to use to create each face
  116538. * @param size defines the size of the textures
  116539. * @param format defines the format of the data
  116540. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  116541. * @param generateMipMaps defines if the engine should generate the mip levels
  116542. * @param invertY defines if data must be stored with Y axis inverted
  116543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  116544. * @param compression defines the compression used (null by default)
  116545. */
  116546. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  116547. /**
  116548. * Updates the raw cube texture.
  116549. * @param data defines the data to store
  116550. * @param format defines the data format
  116551. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  116552. * @param invertY defines if data must be stored with Y axis inverted
  116553. * @param compression defines the compression used (null by default)
  116554. * @param level defines which level of the texture to update
  116555. */
  116556. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  116557. /**
  116558. * Updates a raw cube texture with RGBD encoded data.
  116559. * @param data defines the array of data [mipmap][face] to use to create each face
  116560. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  116561. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  116562. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  116563. * @returns a promsie that resolves when the operation is complete
  116564. */
  116565. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  116566. /**
  116567. * Clones the raw cube texture.
  116568. * @return a new cube texture
  116569. */
  116570. clone(): CubeTexture;
  116571. /** @hidden */
  116572. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  116573. }
  116574. }
  116575. declare module BABYLON {
  116576. /**
  116577. * Class used to store 3D textures containing user data
  116578. */
  116579. export class RawTexture3D extends Texture {
  116580. /** Gets or sets the texture format to use */
  116581. format: number;
  116582. private _engine;
  116583. /**
  116584. * Create a new RawTexture3D
  116585. * @param data defines the data of the texture
  116586. * @param width defines the width of the texture
  116587. * @param height defines the height of the texture
  116588. * @param depth defines the depth of the texture
  116589. * @param format defines the texture format to use
  116590. * @param scene defines the hosting scene
  116591. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  116592. * @param invertY defines if texture must be stored with Y axis inverted
  116593. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  116594. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  116595. */
  116596. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  116597. /** Gets or sets the texture format to use */
  116598. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  116599. /**
  116600. * Update the texture with new data
  116601. * @param data defines the data to store in the texture
  116602. */
  116603. update(data: ArrayBufferView): void;
  116604. }
  116605. }
  116606. declare module BABYLON {
  116607. /**
  116608. * Creates a refraction texture used by refraction channel of the standard material.
  116609. * It is like a mirror but to see through a material.
  116610. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116611. */
  116612. export class RefractionTexture extends RenderTargetTexture {
  116613. /**
  116614. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  116615. * 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.
  116616. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116617. */
  116618. refractionPlane: Plane;
  116619. /**
  116620. * Define how deep under the surface we should see.
  116621. */
  116622. depth: number;
  116623. /**
  116624. * Creates a refraction texture used by refraction channel of the standard material.
  116625. * It is like a mirror but to see through a material.
  116626. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116627. * @param name Define the texture name
  116628. * @param size Define the size of the underlying texture
  116629. * @param scene Define the scene the refraction belongs to
  116630. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116631. */
  116632. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116633. /**
  116634. * Clone the refraction texture.
  116635. * @returns the cloned texture
  116636. */
  116637. clone(): RefractionTexture;
  116638. /**
  116639. * Serialize the texture to a JSON representation you could use in Parse later on
  116640. * @returns the serialized JSON representation
  116641. */
  116642. serialize(): any;
  116643. }
  116644. }
  116645. declare module BABYLON {
  116646. /**
  116647. * Defines the options related to the creation of an HtmlElementTexture
  116648. */
  116649. export interface IHtmlElementTextureOptions {
  116650. /**
  116651. * Defines wether mip maps should be created or not.
  116652. */
  116653. generateMipMaps?: boolean;
  116654. /**
  116655. * Defines the sampling mode of the texture.
  116656. */
  116657. samplingMode?: number;
  116658. /**
  116659. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116660. */
  116661. engine: Nullable<Engine>;
  116662. /**
  116663. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116664. */
  116665. scene: Nullable<Scene>;
  116666. }
  116667. /**
  116668. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116669. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116670. * is automatically managed.
  116671. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116672. * in your application.
  116673. *
  116674. * As the update is not automatic, you need to call them manually.
  116675. */
  116676. export class HtmlElementTexture extends BaseTexture {
  116677. /**
  116678. * The texture URL.
  116679. */
  116680. element: HTMLVideoElement | HTMLCanvasElement;
  116681. private static readonly DefaultOptions;
  116682. private _textureMatrix;
  116683. private _engine;
  116684. private _isVideo;
  116685. private _generateMipMaps;
  116686. private _samplingMode;
  116687. /**
  116688. * Instantiates a HtmlElementTexture from the following parameters.
  116689. *
  116690. * @param name Defines the name of the texture
  116691. * @param element Defines the video or canvas the texture is filled with
  116692. * @param options Defines the other none mandatory texture creation options
  116693. */
  116694. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116695. private _createInternalTexture;
  116696. /**
  116697. * Returns the texture matrix used in most of the material.
  116698. */
  116699. getTextureMatrix(): Matrix;
  116700. /**
  116701. * Updates the content of the texture.
  116702. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116703. */
  116704. update(invertY?: Nullable<boolean>): void;
  116705. }
  116706. }
  116707. declare module BABYLON {
  116708. /**
  116709. * Enum used to define the target of a block
  116710. */
  116711. export enum NodeMaterialBlockTargets {
  116712. /** Vertex shader */
  116713. Vertex = 1,
  116714. /** Fragment shader */
  116715. Fragment = 2,
  116716. /** Neutral */
  116717. Neutral = 4,
  116718. /** Vertex and Fragment */
  116719. VertexAndFragment = 3
  116720. }
  116721. }
  116722. declare module BABYLON {
  116723. /**
  116724. * Defines the kind of connection point for node based material
  116725. */
  116726. export enum NodeMaterialBlockConnectionPointTypes {
  116727. /** Float */
  116728. Float = 1,
  116729. /** Int */
  116730. Int = 2,
  116731. /** Vector2 */
  116732. Vector2 = 4,
  116733. /** Vector3 */
  116734. Vector3 = 8,
  116735. /** Vector4 */
  116736. Vector4 = 16,
  116737. /** Color3 */
  116738. Color3 = 32,
  116739. /** Color4 */
  116740. Color4 = 64,
  116741. /** Matrix */
  116742. Matrix = 128,
  116743. /** Detect type based on connection */
  116744. AutoDetect = 1024,
  116745. /** Output type that will be defined by input type */
  116746. BasedOnInput = 2048
  116747. }
  116748. }
  116749. declare module BABYLON {
  116750. /**
  116751. * Root class for all node material optimizers
  116752. */
  116753. export class NodeMaterialOptimizer {
  116754. /**
  116755. * Function used to optimize a NodeMaterial graph
  116756. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116757. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116758. */
  116759. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116760. }
  116761. }
  116762. declare module BABYLON {
  116763. /**
  116764. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116765. */
  116766. export class TransformBlock extends NodeMaterialBlock {
  116767. /**
  116768. * Defines the value to use to complement W value to transform it to a Vector4
  116769. */
  116770. complementW: number;
  116771. /**
  116772. * Defines the value to use to complement z value to transform it to a Vector4
  116773. */
  116774. complementZ: number;
  116775. /**
  116776. * Creates a new TransformBlock
  116777. * @param name defines the block name
  116778. */
  116779. constructor(name: string);
  116780. /**
  116781. * Gets the current class name
  116782. * @returns the class name
  116783. */
  116784. getClassName(): string;
  116785. /**
  116786. * Gets the vector input
  116787. */
  116788. readonly vector: NodeMaterialConnectionPoint;
  116789. /**
  116790. * Gets the output component
  116791. */
  116792. readonly output: NodeMaterialConnectionPoint;
  116793. /**
  116794. * Gets the matrix transform input
  116795. */
  116796. readonly transform: NodeMaterialConnectionPoint;
  116797. protected _buildBlock(state: NodeMaterialBuildState): this;
  116798. serialize(): any;
  116799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116800. protected _dumpPropertiesCode(): string;
  116801. }
  116802. }
  116803. declare module BABYLON {
  116804. /**
  116805. * Block used to output the vertex position
  116806. */
  116807. export class VertexOutputBlock extends NodeMaterialBlock {
  116808. /**
  116809. * Creates a new VertexOutputBlock
  116810. * @param name defines the block name
  116811. */
  116812. constructor(name: string);
  116813. /**
  116814. * Gets the current class name
  116815. * @returns the class name
  116816. */
  116817. getClassName(): string;
  116818. /**
  116819. * Gets the vector input component
  116820. */
  116821. readonly vector: NodeMaterialConnectionPoint;
  116822. protected _buildBlock(state: NodeMaterialBuildState): this;
  116823. }
  116824. }
  116825. declare module BABYLON {
  116826. /**
  116827. * Block used to output the final color
  116828. */
  116829. export class FragmentOutputBlock extends NodeMaterialBlock {
  116830. /**
  116831. * Create a new FragmentOutputBlock
  116832. * @param name defines the block name
  116833. */
  116834. constructor(name: string);
  116835. /**
  116836. * Gets the current class name
  116837. * @returns the class name
  116838. */
  116839. getClassName(): string;
  116840. /**
  116841. * Gets the rgba input component
  116842. */
  116843. readonly rgba: NodeMaterialConnectionPoint;
  116844. /**
  116845. * Gets the rgb input component
  116846. */
  116847. readonly rgb: NodeMaterialConnectionPoint;
  116848. /**
  116849. * Gets the a input component
  116850. */
  116851. readonly a: NodeMaterialConnectionPoint;
  116852. protected _buildBlock(state: NodeMaterialBuildState): this;
  116853. }
  116854. }
  116855. declare module BABYLON {
  116856. /**
  116857. * Enum used to define well known values e.g. values automatically provided by the system
  116858. */
  116859. export enum NodeMaterialWellKnownValues {
  116860. /** World */
  116861. World = 1,
  116862. /** View */
  116863. View = 2,
  116864. /** Projection */
  116865. Projection = 3,
  116866. /** ViewProjection */
  116867. ViewProjection = 4,
  116868. /** WorldView */
  116869. WorldView = 5,
  116870. /** WorldViewProjection */
  116871. WorldViewProjection = 6,
  116872. /** CameraPosition */
  116873. CameraPosition = 7,
  116874. /** Fog Color */
  116875. FogColor = 8
  116876. }
  116877. }
  116878. declare module BABYLON {
  116879. /**
  116880. * Block used to read a reflection texture from a sampler
  116881. */
  116882. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116883. private _define3DName;
  116884. private _defineCubicName;
  116885. private _defineExplicitName;
  116886. private _defineProjectionName;
  116887. private _defineLocalCubicName;
  116888. private _defineSphericalName;
  116889. private _definePlanarName;
  116890. private _defineEquirectangularName;
  116891. private _defineMirroredEquirectangularFixedName;
  116892. private _defineEquirectangularFixedName;
  116893. private _defineSkyboxName;
  116894. private _cubeSamplerName;
  116895. private _2DSamplerName;
  116896. private _positionUVWName;
  116897. private _directionWName;
  116898. private _reflectionCoordsName;
  116899. private _reflection2DCoordsName;
  116900. private _reflectionColorName;
  116901. private _reflectionMatrixName;
  116902. /**
  116903. * Gets or sets the texture associated with the node
  116904. */
  116905. texture: Nullable<BaseTexture>;
  116906. /**
  116907. * Create a new TextureBlock
  116908. * @param name defines the block name
  116909. */
  116910. constructor(name: string);
  116911. /**
  116912. * Gets the current class name
  116913. * @returns the class name
  116914. */
  116915. getClassName(): string;
  116916. /**
  116917. * Gets the world position input component
  116918. */
  116919. readonly position: NodeMaterialConnectionPoint;
  116920. /**
  116921. * Gets the world position input component
  116922. */
  116923. readonly worldPosition: NodeMaterialConnectionPoint;
  116924. /**
  116925. * Gets the world normal input component
  116926. */
  116927. readonly worldNormal: NodeMaterialConnectionPoint;
  116928. /**
  116929. * Gets the world input component
  116930. */
  116931. readonly world: NodeMaterialConnectionPoint;
  116932. /**
  116933. * Gets the camera (or eye) position component
  116934. */
  116935. readonly cameraPosition: NodeMaterialConnectionPoint;
  116936. /**
  116937. * Gets the view input component
  116938. */
  116939. readonly view: NodeMaterialConnectionPoint;
  116940. /**
  116941. * Gets the rgb output component
  116942. */
  116943. readonly rgb: NodeMaterialConnectionPoint;
  116944. /**
  116945. * Gets the r output component
  116946. */
  116947. readonly r: NodeMaterialConnectionPoint;
  116948. /**
  116949. * Gets the g output component
  116950. */
  116951. readonly g: NodeMaterialConnectionPoint;
  116952. /**
  116953. * Gets the b output component
  116954. */
  116955. readonly b: NodeMaterialConnectionPoint;
  116956. autoConfigure(material: NodeMaterial): void;
  116957. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116958. isReady(): boolean;
  116959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116960. private _injectVertexCode;
  116961. private _writeOutput;
  116962. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116963. serialize(): any;
  116964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116965. }
  116966. }
  116967. declare module BABYLON {
  116968. /**
  116969. * Interface used to configure the node material editor
  116970. */
  116971. export interface INodeMaterialEditorOptions {
  116972. /** Define the URl to load node editor script */
  116973. editorURL?: string;
  116974. }
  116975. /** @hidden */
  116976. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116977. /** BONES */
  116978. NUM_BONE_INFLUENCERS: number;
  116979. BonesPerMesh: number;
  116980. BONETEXTURE: boolean;
  116981. /** MORPH TARGETS */
  116982. MORPHTARGETS: boolean;
  116983. MORPHTARGETS_NORMAL: boolean;
  116984. MORPHTARGETS_TANGENT: boolean;
  116985. MORPHTARGETS_UV: boolean;
  116986. NUM_MORPH_INFLUENCERS: number;
  116987. /** IMAGE PROCESSING */
  116988. IMAGEPROCESSING: boolean;
  116989. VIGNETTE: boolean;
  116990. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116991. VIGNETTEBLENDMODEOPAQUE: boolean;
  116992. TONEMAPPING: boolean;
  116993. TONEMAPPING_ACES: boolean;
  116994. CONTRAST: boolean;
  116995. EXPOSURE: boolean;
  116996. COLORCURVES: boolean;
  116997. COLORGRADING: boolean;
  116998. COLORGRADING3D: boolean;
  116999. SAMPLER3DGREENDEPTH: boolean;
  117000. SAMPLER3DBGRMAP: boolean;
  117001. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117002. constructor();
  117003. setValue(name: string, value: boolean): void;
  117004. }
  117005. /**
  117006. * Class used to configure NodeMaterial
  117007. */
  117008. export interface INodeMaterialOptions {
  117009. /**
  117010. * Defines if blocks should emit comments
  117011. */
  117012. emitComments: boolean;
  117013. }
  117014. /**
  117015. * Class used to create a node based material built by assembling shader blocks
  117016. */
  117017. export class NodeMaterial extends PushMaterial {
  117018. private static _BuildIdGenerator;
  117019. private _options;
  117020. private _vertexCompilationState;
  117021. private _fragmentCompilationState;
  117022. private _sharedData;
  117023. private _buildId;
  117024. private _buildWasSuccessful;
  117025. private _cachedWorldViewMatrix;
  117026. private _cachedWorldViewProjectionMatrix;
  117027. private _optimizers;
  117028. private _animationFrame;
  117029. /** Define the URl to load node editor script */
  117030. static EditorURL: string;
  117031. private BJSNODEMATERIALEDITOR;
  117032. /** Get the inspector from bundle or global */
  117033. private _getGlobalNodeMaterialEditor;
  117034. /**
  117035. * 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)
  117036. */
  117037. ignoreAlpha: boolean;
  117038. /**
  117039. * Defines the maximum number of lights that can be used in the material
  117040. */
  117041. maxSimultaneousLights: number;
  117042. /**
  117043. * Observable raised when the material is built
  117044. */
  117045. onBuildObservable: Observable<NodeMaterial>;
  117046. /**
  117047. * Gets or sets the root nodes of the material vertex shader
  117048. */
  117049. _vertexOutputNodes: NodeMaterialBlock[];
  117050. /**
  117051. * Gets or sets the root nodes of the material fragment (pixel) shader
  117052. */
  117053. _fragmentOutputNodes: NodeMaterialBlock[];
  117054. /** Gets or sets options to control the node material overall behavior */
  117055. options: INodeMaterialOptions;
  117056. /**
  117057. * Default configuration related to image processing available in the standard Material.
  117058. */
  117059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117060. /**
  117061. * Gets the image processing configuration used either in this material.
  117062. */
  117063. /**
  117064. * Sets the Default image processing configuration used either in the this material.
  117065. *
  117066. * If sets to null, the scene one is in use.
  117067. */
  117068. imageProcessingConfiguration: ImageProcessingConfiguration;
  117069. /**
  117070. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  117071. */
  117072. attachedBlocks: NodeMaterialBlock[];
  117073. /**
  117074. * Create a new node based material
  117075. * @param name defines the material name
  117076. * @param scene defines the hosting scene
  117077. * @param options defines creation option
  117078. */
  117079. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  117080. /**
  117081. * Gets the current class name of the material e.g. "NodeMaterial"
  117082. * @returns the class name
  117083. */
  117084. getClassName(): string;
  117085. /**
  117086. * Keep track of the image processing observer to allow dispose and replace.
  117087. */
  117088. private _imageProcessingObserver;
  117089. /**
  117090. * Attaches a new image processing configuration to the Standard Material.
  117091. * @param configuration
  117092. */
  117093. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117094. /**
  117095. * Get a block by its name
  117096. * @param name defines the name of the block to retrieve
  117097. * @returns the required block or null if not found
  117098. */
  117099. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  117100. /**
  117101. * Get a block by its name
  117102. * @param predicate defines the predicate used to find the good candidate
  117103. * @returns the required block or null if not found
  117104. */
  117105. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  117106. /**
  117107. * Get an input block by its name
  117108. * @param predicate defines the predicate used to find the good candidate
  117109. * @returns the required input block or null if not found
  117110. */
  117111. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  117112. /**
  117113. * Gets the list of input blocks attached to this material
  117114. * @returns an array of InputBlocks
  117115. */
  117116. getInputBlocks(): InputBlock[];
  117117. /**
  117118. * Adds a new optimizer to the list of optimizers
  117119. * @param optimizer defines the optimizers to add
  117120. * @returns the current material
  117121. */
  117122. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117123. /**
  117124. * Remove an optimizer from the list of optimizers
  117125. * @param optimizer defines the optimizers to remove
  117126. * @returns the current material
  117127. */
  117128. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117129. /**
  117130. * Add a new block to the list of output nodes
  117131. * @param node defines the node to add
  117132. * @returns the current material
  117133. */
  117134. addOutputNode(node: NodeMaterialBlock): this;
  117135. /**
  117136. * Remove a block from the list of root nodes
  117137. * @param node defines the node to remove
  117138. * @returns the current material
  117139. */
  117140. removeOutputNode(node: NodeMaterialBlock): this;
  117141. private _addVertexOutputNode;
  117142. private _removeVertexOutputNode;
  117143. private _addFragmentOutputNode;
  117144. private _removeFragmentOutputNode;
  117145. /**
  117146. * Specifies if the material will require alpha blending
  117147. * @returns a boolean specifying if alpha blending is needed
  117148. */
  117149. needAlphaBlending(): boolean;
  117150. /**
  117151. * Specifies if this material should be rendered in alpha test mode
  117152. * @returns a boolean specifying if an alpha test is needed.
  117153. */
  117154. needAlphaTesting(): boolean;
  117155. private _initializeBlock;
  117156. private _resetDualBlocks;
  117157. /**
  117158. * Build the material and generates the inner effect
  117159. * @param verbose defines if the build should log activity
  117160. */
  117161. build(verbose?: boolean): void;
  117162. /**
  117163. * Runs an otpimization phase to try to improve the shader code
  117164. */
  117165. optimize(): void;
  117166. private _prepareDefinesForAttributes;
  117167. /**
  117168. * Get if the submesh is ready to be used and all its information available.
  117169. * Child classes can use it to update shaders
  117170. * @param mesh defines the mesh to check
  117171. * @param subMesh defines which submesh to check
  117172. * @param useInstances specifies that instances should be used
  117173. * @returns a boolean indicating that the submesh is ready or not
  117174. */
  117175. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117176. /**
  117177. * Get a string representing the shaders built by the current node graph
  117178. */
  117179. readonly compiledShaders: string;
  117180. /**
  117181. * Binds the world matrix to the material
  117182. * @param world defines the world transformation matrix
  117183. */
  117184. bindOnlyWorldMatrix(world: Matrix): void;
  117185. /**
  117186. * Binds the submesh to this material by preparing the effect and shader to draw
  117187. * @param world defines the world transformation matrix
  117188. * @param mesh defines the mesh containing the submesh
  117189. * @param subMesh defines the submesh to bind the material to
  117190. */
  117191. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117192. /**
  117193. * Gets the active textures from the material
  117194. * @returns an array of textures
  117195. */
  117196. getActiveTextures(): BaseTexture[];
  117197. /**
  117198. * Gets the list of texture blocks
  117199. * @returns an array of texture blocks
  117200. */
  117201. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  117202. /**
  117203. * Specifies if the material uses a texture
  117204. * @param texture defines the texture to check against the material
  117205. * @returns a boolean specifying if the material uses the texture
  117206. */
  117207. hasTexture(texture: BaseTexture): boolean;
  117208. /**
  117209. * Disposes the material
  117210. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  117211. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  117212. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  117213. */
  117214. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  117215. /** Creates the node editor window. */
  117216. private _createNodeEditor;
  117217. /**
  117218. * Launch the node material editor
  117219. * @param config Define the configuration of the editor
  117220. * @return a promise fulfilled when the node editor is visible
  117221. */
  117222. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  117223. /**
  117224. * Clear the current material
  117225. */
  117226. clear(): void;
  117227. /**
  117228. * Clear the current material and set it to a default state
  117229. */
  117230. setToDefault(): void;
  117231. /**
  117232. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  117233. * @param url defines the url to load from
  117234. * @returns a promise that will fullfil when the material is fully loaded
  117235. */
  117236. loadAsync(url: string): Promise<unknown>;
  117237. private _gatherBlocks;
  117238. /**
  117239. * Generate a string containing the code declaration required to create an equivalent of this material
  117240. * @returns a string
  117241. */
  117242. generateCode(): string;
  117243. /**
  117244. * Serializes this material in a JSON representation
  117245. * @returns the serialized material object
  117246. */
  117247. serialize(): any;
  117248. private _restoreConnections;
  117249. /**
  117250. * Clear the current graph and load a new one from a serialization object
  117251. * @param source defines the JSON representation of the material
  117252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117253. */
  117254. loadFromSerialization(source: any, rootUrl?: string): void;
  117255. /**
  117256. * Creates a node material from parsed material data
  117257. * @param source defines the JSON representation of the material
  117258. * @param scene defines the hosting scene
  117259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117260. * @returns a new node material
  117261. */
  117262. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  117263. /**
  117264. * Creates a new node material set to default basic configuration
  117265. * @param name defines the name of the material
  117266. * @param scene defines the hosting scene
  117267. * @returns a new NodeMaterial
  117268. */
  117269. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  117270. }
  117271. }
  117272. declare module BABYLON {
  117273. /**
  117274. * Block used to read a texture from a sampler
  117275. */
  117276. export class TextureBlock extends NodeMaterialBlock {
  117277. private _defineName;
  117278. private _samplerName;
  117279. private _transformedUVName;
  117280. private _textureTransformName;
  117281. private _textureInfoName;
  117282. private _mainUVName;
  117283. private _mainUVDefineName;
  117284. /**
  117285. * Gets or sets the texture associated with the node
  117286. */
  117287. texture: Nullable<BaseTexture>;
  117288. /**
  117289. * Create a new TextureBlock
  117290. * @param name defines the block name
  117291. */
  117292. constructor(name: string);
  117293. /**
  117294. * Gets the current class name
  117295. * @returns the class name
  117296. */
  117297. getClassName(): string;
  117298. /**
  117299. * Gets the uv input component
  117300. */
  117301. readonly uv: NodeMaterialConnectionPoint;
  117302. /**
  117303. * Gets the rgba output component
  117304. */
  117305. readonly rgba: NodeMaterialConnectionPoint;
  117306. /**
  117307. * Gets the rgb output component
  117308. */
  117309. readonly rgb: NodeMaterialConnectionPoint;
  117310. /**
  117311. * Gets the r output component
  117312. */
  117313. readonly r: NodeMaterialConnectionPoint;
  117314. /**
  117315. * Gets the g output component
  117316. */
  117317. readonly g: NodeMaterialConnectionPoint;
  117318. /**
  117319. * Gets the b output component
  117320. */
  117321. readonly b: NodeMaterialConnectionPoint;
  117322. /**
  117323. * Gets the a output component
  117324. */
  117325. readonly a: NodeMaterialConnectionPoint;
  117326. readonly target: NodeMaterialBlockTargets;
  117327. autoConfigure(material: NodeMaterial): void;
  117328. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117330. isReady(): boolean;
  117331. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117332. private readonly _isMixed;
  117333. private _injectVertexCode;
  117334. private _writeOutput;
  117335. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117336. protected _dumpPropertiesCode(): string;
  117337. serialize(): any;
  117338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117339. }
  117340. }
  117341. declare module BABYLON {
  117342. /**
  117343. * Class used to store shared data between 2 NodeMaterialBuildState
  117344. */
  117345. export class NodeMaterialBuildStateSharedData {
  117346. /**
  117347. * Gets the list of emitted varyings
  117348. */
  117349. temps: string[];
  117350. /**
  117351. * Gets the list of emitted varyings
  117352. */
  117353. varyings: string[];
  117354. /**
  117355. * Gets the varying declaration string
  117356. */
  117357. varyingDeclaration: string;
  117358. /**
  117359. * Input blocks
  117360. */
  117361. inputBlocks: InputBlock[];
  117362. /**
  117363. * Input blocks
  117364. */
  117365. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  117366. /**
  117367. * Bindable blocks (Blocks that need to set data to the effect)
  117368. */
  117369. bindableBlocks: NodeMaterialBlock[];
  117370. /**
  117371. * List of blocks that can provide a compilation fallback
  117372. */
  117373. blocksWithFallbacks: NodeMaterialBlock[];
  117374. /**
  117375. * List of blocks that can provide a define update
  117376. */
  117377. blocksWithDefines: NodeMaterialBlock[];
  117378. /**
  117379. * List of blocks that can provide a repeatable content
  117380. */
  117381. repeatableContentBlocks: NodeMaterialBlock[];
  117382. /**
  117383. * List of blocks that can provide a dynamic list of uniforms
  117384. */
  117385. dynamicUniformBlocks: NodeMaterialBlock[];
  117386. /**
  117387. * List of blocks that can block the isReady function for the material
  117388. */
  117389. blockingBlocks: NodeMaterialBlock[];
  117390. /**
  117391. * Gets the list of animated inputs
  117392. */
  117393. animatedInputs: InputBlock[];
  117394. /**
  117395. * Build Id used to avoid multiple recompilations
  117396. */
  117397. buildId: number;
  117398. /** List of emitted variables */
  117399. variableNames: {
  117400. [key: string]: number;
  117401. };
  117402. /** List of emitted defines */
  117403. defineNames: {
  117404. [key: string]: number;
  117405. };
  117406. /** Should emit comments? */
  117407. emitComments: boolean;
  117408. /** Emit build activity */
  117409. verbose: boolean;
  117410. /**
  117411. * Gets the compilation hints emitted at compilation time
  117412. */
  117413. hints: {
  117414. needWorldViewMatrix: boolean;
  117415. needWorldViewProjectionMatrix: boolean;
  117416. needAlphaBlending: boolean;
  117417. needAlphaTesting: boolean;
  117418. };
  117419. /**
  117420. * List of compilation checks
  117421. */
  117422. checks: {
  117423. emitVertex: boolean;
  117424. emitFragment: boolean;
  117425. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  117426. };
  117427. /** Creates a new shared data */
  117428. constructor();
  117429. /**
  117430. * Emits console errors and exceptions if there is a failing check
  117431. */
  117432. emitErrors(): void;
  117433. }
  117434. }
  117435. declare module BABYLON {
  117436. /**
  117437. * Class used to store node based material build state
  117438. */
  117439. export class NodeMaterialBuildState {
  117440. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  117441. supportUniformBuffers: boolean;
  117442. /**
  117443. * Gets the list of emitted attributes
  117444. */
  117445. attributes: string[];
  117446. /**
  117447. * Gets the list of emitted uniforms
  117448. */
  117449. uniforms: string[];
  117450. /**
  117451. * Gets the list of emitted uniform buffers
  117452. */
  117453. uniformBuffers: string[];
  117454. /**
  117455. * Gets the list of emitted samplers
  117456. */
  117457. samplers: string[];
  117458. /**
  117459. * Gets the list of emitted functions
  117460. */
  117461. functions: {
  117462. [key: string]: string;
  117463. };
  117464. /**
  117465. * Gets the target of the compilation state
  117466. */
  117467. target: NodeMaterialBlockTargets;
  117468. /**
  117469. * Gets the list of emitted counters
  117470. */
  117471. counters: {
  117472. [key: string]: number;
  117473. };
  117474. /**
  117475. * Shared data between multiple NodeMaterialBuildState instances
  117476. */
  117477. sharedData: NodeMaterialBuildStateSharedData;
  117478. /** @hidden */
  117479. _vertexState: NodeMaterialBuildState;
  117480. /** @hidden */
  117481. _attributeDeclaration: string;
  117482. /** @hidden */
  117483. _uniformDeclaration: string;
  117484. /** @hidden */
  117485. _samplerDeclaration: string;
  117486. /** @hidden */
  117487. _varyingTransfer: string;
  117488. private _repeatableContentAnchorIndex;
  117489. /** @hidden */
  117490. _builtCompilationString: string;
  117491. /**
  117492. * Gets the emitted compilation strings
  117493. */
  117494. compilationString: string;
  117495. /**
  117496. * Finalize the compilation strings
  117497. * @param state defines the current compilation state
  117498. */
  117499. finalize(state: NodeMaterialBuildState): void;
  117500. /** @hidden */
  117501. readonly _repeatableContentAnchor: string;
  117502. /** @hidden */
  117503. _getFreeVariableName(prefix: string): string;
  117504. /** @hidden */
  117505. _getFreeDefineName(prefix: string): string;
  117506. /** @hidden */
  117507. _excludeVariableName(name: string): void;
  117508. /** @hidden */
  117509. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  117510. /** @hidden */
  117511. _emitFunction(name: string, code: string, comments: string): void;
  117512. /** @hidden */
  117513. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  117514. replaceStrings?: {
  117515. search: RegExp;
  117516. replace: string;
  117517. }[];
  117518. repeatKey?: string;
  117519. }): string;
  117520. /** @hidden */
  117521. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  117522. repeatKey?: string;
  117523. removeAttributes?: boolean;
  117524. removeUniforms?: boolean;
  117525. removeVaryings?: boolean;
  117526. removeIfDef?: boolean;
  117527. replaceStrings?: {
  117528. search: RegExp;
  117529. replace: string;
  117530. }[];
  117531. }, storeKey?: string): void;
  117532. /** @hidden */
  117533. _registerTempVariable(name: string): boolean;
  117534. /** @hidden */
  117535. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  117536. /** @hidden */
  117537. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  117538. }
  117539. }
  117540. declare module BABYLON {
  117541. /**
  117542. * Defines a block that can be used inside a node based material
  117543. */
  117544. export class NodeMaterialBlock {
  117545. private _buildId;
  117546. private _buildTarget;
  117547. private _target;
  117548. private _isFinalMerger;
  117549. private _isInput;
  117550. /** @hidden */
  117551. _codeVariableName: string;
  117552. /** @hidden */
  117553. _inputs: NodeMaterialConnectionPoint[];
  117554. /** @hidden */
  117555. _outputs: NodeMaterialConnectionPoint[];
  117556. /** @hidden */
  117557. _preparationId: number;
  117558. /**
  117559. * Gets or sets the name of the block
  117560. */
  117561. name: string;
  117562. /**
  117563. * Gets or sets the unique id of the node
  117564. */
  117565. uniqueId: number;
  117566. /**
  117567. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  117568. */
  117569. readonly isFinalMerger: boolean;
  117570. /**
  117571. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  117572. */
  117573. readonly isInput: boolean;
  117574. /**
  117575. * Gets or sets the build Id
  117576. */
  117577. buildId: number;
  117578. /**
  117579. * Gets or sets the target of the block
  117580. */
  117581. target: NodeMaterialBlockTargets;
  117582. /**
  117583. * Gets the list of input points
  117584. */
  117585. readonly inputs: NodeMaterialConnectionPoint[];
  117586. /** Gets the list of output points */
  117587. readonly outputs: NodeMaterialConnectionPoint[];
  117588. /**
  117589. * Find an input by its name
  117590. * @param name defines the name of the input to look for
  117591. * @returns the input or null if not found
  117592. */
  117593. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117594. /**
  117595. * Find an output by its name
  117596. * @param name defines the name of the outputto look for
  117597. * @returns the output or null if not found
  117598. */
  117599. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117600. /**
  117601. * Creates a new NodeMaterialBlock
  117602. * @param name defines the block name
  117603. * @param target defines the target of that block (Vertex by default)
  117604. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  117605. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  117606. */
  117607. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  117608. /**
  117609. * Initialize the block and prepare the context for build
  117610. * @param state defines the state that will be used for the build
  117611. */
  117612. initialize(state: NodeMaterialBuildState): void;
  117613. /**
  117614. * Bind data to effect. Will only be called for blocks with isBindable === true
  117615. * @param effect defines the effect to bind data to
  117616. * @param nodeMaterial defines the hosting NodeMaterial
  117617. * @param mesh defines the mesh that will be rendered
  117618. */
  117619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117620. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  117621. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  117622. protected _writeFloat(value: number): string;
  117623. /**
  117624. * Gets the current class name e.g. "NodeMaterialBlock"
  117625. * @returns the class name
  117626. */
  117627. getClassName(): string;
  117628. /**
  117629. * Register a new input. Must be called inside a block constructor
  117630. * @param name defines the connection point name
  117631. * @param type defines the connection point type
  117632. * @param isOptional defines a boolean indicating that this input can be omitted
  117633. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  117634. * @returns the current block
  117635. */
  117636. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  117637. /**
  117638. * Register a new output. Must be called inside a block constructor
  117639. * @param name defines the connection point name
  117640. * @param type defines the connection point type
  117641. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  117642. * @returns the current block
  117643. */
  117644. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  117645. /**
  117646. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  117647. * @param forOutput defines an optional connection point to check compatibility with
  117648. * @returns the first available input or null
  117649. */
  117650. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  117651. /**
  117652. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  117653. * @param forBlock defines an optional block to check compatibility with
  117654. * @returns the first available input or null
  117655. */
  117656. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  117657. /**
  117658. * Gets the sibling of the given output
  117659. * @param current defines the current output
  117660. * @returns the next output in the list or null
  117661. */
  117662. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  117663. /**
  117664. * Connect current block with another block
  117665. * @param other defines the block to connect with
  117666. * @param options define the various options to help pick the right connections
  117667. * @returns the current block
  117668. */
  117669. connectTo(other: NodeMaterialBlock, options?: {
  117670. input?: string;
  117671. output?: string;
  117672. outputSwizzle?: string;
  117673. }): this | undefined;
  117674. protected _buildBlock(state: NodeMaterialBuildState): void;
  117675. /**
  117676. * Add uniforms, samplers and uniform buffers at compilation time
  117677. * @param state defines the state to update
  117678. * @param nodeMaterial defines the node material requesting the update
  117679. * @param defines defines the material defines to update
  117680. */
  117681. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117682. /**
  117683. * Add potential fallbacks if shader compilation fails
  117684. * @param mesh defines the mesh to be rendered
  117685. * @param fallbacks defines the current prioritized list of fallbacks
  117686. */
  117687. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117688. /**
  117689. * Update defines for shader compilation
  117690. * @param mesh defines the mesh to be rendered
  117691. * @param nodeMaterial defines the node material requesting the update
  117692. * @param defines defines the material defines to update
  117693. * @param useInstances specifies that instances should be used
  117694. */
  117695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117696. /**
  117697. * Initialize defines for shader compilation
  117698. * @param mesh defines the mesh to be rendered
  117699. * @param nodeMaterial defines the node material requesting the update
  117700. * @param defines defines the material defines to be prepared
  117701. * @param useInstances specifies that instances should be used
  117702. */
  117703. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117704. /**
  117705. * Lets the block try to connect some inputs automatically
  117706. * @param material defines the hosting NodeMaterial
  117707. */
  117708. autoConfigure(material: NodeMaterial): void;
  117709. /**
  117710. * Function called when a block is declared as repeatable content generator
  117711. * @param vertexShaderState defines the current compilation state for the vertex shader
  117712. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117713. * @param mesh defines the mesh to be rendered
  117714. * @param defines defines the material defines to update
  117715. */
  117716. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117717. /**
  117718. * Checks if the block is ready
  117719. * @param mesh defines the mesh to be rendered
  117720. * @param nodeMaterial defines the node material requesting the update
  117721. * @param defines defines the material defines to update
  117722. * @param useInstances specifies that instances should be used
  117723. * @returns true if the block is ready
  117724. */
  117725. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117726. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  117727. private _processBuild;
  117728. /**
  117729. * Compile the current node and generate the shader code
  117730. * @param state defines the current compilation state (uniforms, samplers, current string)
  117731. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  117732. * @returns true if already built
  117733. */
  117734. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  117735. protected _inputRename(name: string): string;
  117736. protected _outputRename(name: string): string;
  117737. protected _dumpPropertiesCode(): string;
  117738. /** @hidden */
  117739. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  117740. /**
  117741. * Clone the current block to a new identical block
  117742. * @param scene defines the hosting scene
  117743. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117744. * @returns a copy of the current block
  117745. */
  117746. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  117747. /**
  117748. * Serializes this block in a JSON representation
  117749. * @returns the serialized block object
  117750. */
  117751. serialize(): any;
  117752. /** @hidden */
  117753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117754. }
  117755. }
  117756. declare module BABYLON {
  117757. /**
  117758. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117759. */
  117760. export enum NodeMaterialBlockConnectionPointMode {
  117761. /** Value is an uniform */
  117762. Uniform = 0,
  117763. /** Value is a mesh attribute */
  117764. Attribute = 1,
  117765. /** Value is a varying between vertex and fragment shaders */
  117766. Varying = 2,
  117767. /** Mode is undefined */
  117768. Undefined = 3
  117769. }
  117770. }
  117771. declare module BABYLON {
  117772. /**
  117773. * Enum defining the type of animations supported by InputBlock
  117774. */
  117775. export enum AnimatedInputBlockTypes {
  117776. /** No animation */
  117777. None = 0,
  117778. /** Time based animation. Will only work for floats */
  117779. Time = 1
  117780. }
  117781. }
  117782. declare module BABYLON {
  117783. /**
  117784. * Block used to expose an input value
  117785. */
  117786. export class InputBlock extends NodeMaterialBlock {
  117787. private _mode;
  117788. private _associatedVariableName;
  117789. private _storedValue;
  117790. private _valueCallback;
  117791. private _type;
  117792. private _animationType;
  117793. /** @hidden */
  117794. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117795. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  117796. visibleInInspector: boolean;
  117797. /**
  117798. * Gets or sets the connection point type (default is float)
  117799. */
  117800. readonly type: NodeMaterialBlockConnectionPointTypes;
  117801. /**
  117802. * Creates a new InputBlock
  117803. * @param name defines the block name
  117804. * @param target defines the target of that block (Vertex by default)
  117805. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117806. */
  117807. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117808. /**
  117809. * Gets the output component
  117810. */
  117811. readonly output: NodeMaterialConnectionPoint;
  117812. /**
  117813. * Set the source of this connection point to a vertex attribute
  117814. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117815. * @returns the current connection point
  117816. */
  117817. setAsAttribute(attributeName?: string): InputBlock;
  117818. /**
  117819. * Set the source of this connection point to a well known value
  117820. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117821. * @returns the current connection point
  117822. */
  117823. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117824. /**
  117825. * Gets or sets the value of that point.
  117826. * Please note that this value will be ignored if valueCallback is defined
  117827. */
  117828. value: any;
  117829. /**
  117830. * Gets or sets a callback used to get the value of that point.
  117831. * Please note that setting this value will force the connection point to ignore the value property
  117832. */
  117833. valueCallback: () => any;
  117834. /**
  117835. * Gets or sets the associated variable name in the shader
  117836. */
  117837. associatedVariableName: string;
  117838. /** Gets or sets the type of animation applied to the input */
  117839. animationType: AnimatedInputBlockTypes;
  117840. /**
  117841. * Gets a boolean indicating that this connection point not defined yet
  117842. */
  117843. readonly isUndefined: boolean;
  117844. /**
  117845. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117846. * In this case the connection point name must be the name of the uniform to use.
  117847. * Can only be set on inputs
  117848. */
  117849. isUniform: boolean;
  117850. /**
  117851. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117852. * In this case the connection point name must be the name of the attribute to use
  117853. * Can only be set on inputs
  117854. */
  117855. isAttribute: boolean;
  117856. /**
  117857. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117858. * Can only be set on exit points
  117859. */
  117860. isVarying: boolean;
  117861. /**
  117862. * Gets a boolean indicating that the current connection point is a well known value
  117863. */
  117864. readonly isWellKnownValue: boolean;
  117865. /**
  117866. * Gets or sets the current well known value or null if not defined as well know value
  117867. */
  117868. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117869. /**
  117870. * Gets the current class name
  117871. * @returns the class name
  117872. */
  117873. getClassName(): string;
  117874. /**
  117875. * Animate the input if animationType !== None
  117876. * @param scene defines the rendering scene
  117877. */
  117878. animate(scene: Scene): void;
  117879. private _emitDefine;
  117880. /**
  117881. * Set the input block to its default value (based on its type)
  117882. */
  117883. setDefaultValue(): void;
  117884. protected _dumpPropertiesCode(): string;
  117885. private _emit;
  117886. /** @hidden */
  117887. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117888. /** @hidden */
  117889. _transmit(effect: Effect, scene: Scene): void;
  117890. protected _buildBlock(state: NodeMaterialBuildState): void;
  117891. serialize(): any;
  117892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117893. }
  117894. }
  117895. declare module BABYLON {
  117896. /**
  117897. * Defines a connection point for a block
  117898. */
  117899. export class NodeMaterialConnectionPoint {
  117900. /** @hidden */
  117901. _ownerBlock: NodeMaterialBlock;
  117902. /** @hidden */
  117903. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117904. private _endpoints;
  117905. private _associatedVariableName;
  117906. /** @hidden */
  117907. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117908. /** @hidden */
  117909. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117910. private _type;
  117911. /** @hidden */
  117912. _enforceAssociatedVariableName: boolean;
  117913. /**
  117914. * Gets or sets the additional types supported byt this connection point
  117915. */
  117916. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117917. /**
  117918. * Gets or sets the associated variable name in the shader
  117919. */
  117920. associatedVariableName: string;
  117921. /**
  117922. * Gets or sets the connection point type (default is float)
  117923. */
  117924. type: NodeMaterialBlockConnectionPointTypes;
  117925. /**
  117926. * Gets or sets the connection point name
  117927. */
  117928. name: string;
  117929. /**
  117930. * Gets or sets a boolean indicating that this connection point can be omitted
  117931. */
  117932. isOptional: boolean;
  117933. /**
  117934. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117935. */
  117936. define: string;
  117937. /** Gets or sets the target of that connection point */
  117938. target: NodeMaterialBlockTargets;
  117939. /**
  117940. * Gets a boolean indicating that the current point is connected
  117941. */
  117942. readonly isConnected: boolean;
  117943. /**
  117944. * Gets a boolean indicating that the current point is connected to an input block
  117945. */
  117946. readonly isConnectedToInputBlock: boolean;
  117947. /**
  117948. * Gets a the connected input block (if any)
  117949. */
  117950. readonly connectInputBlock: Nullable<InputBlock>;
  117951. /** Get the other side of the connection (if any) */
  117952. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117953. /** Get the block that owns this connection point */
  117954. readonly ownerBlock: NodeMaterialBlock;
  117955. /** Get the block connected on the other side of this connection (if any) */
  117956. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117957. /** Get the block connected on the endpoints of this connection (if any) */
  117958. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117959. /** Gets the list of connected endpoints */
  117960. readonly endpoints: NodeMaterialConnectionPoint[];
  117961. /** Gets a boolean indicating if that output point is connected to at least one input */
  117962. readonly hasEndpoints: boolean;
  117963. /**
  117964. * Creates a new connection point
  117965. * @param name defines the connection point name
  117966. * @param ownerBlock defines the block hosting this connection point
  117967. */
  117968. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117969. /**
  117970. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117971. * @returns the class name
  117972. */
  117973. getClassName(): string;
  117974. /**
  117975. * Gets an boolean indicating if the current point can be connected to another point
  117976. * @param connectionPoint defines the other connection point
  117977. * @returns true if the connection is possible
  117978. */
  117979. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117980. /**
  117981. * Connect this point to another connection point
  117982. * @param connectionPoint defines the other connection point
  117983. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  117984. * @returns the current connection point
  117985. */
  117986. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  117987. /**
  117988. * Disconnect this point from one of his endpoint
  117989. * @param endpoint defines the other connection point
  117990. * @returns the current connection point
  117991. */
  117992. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117993. /**
  117994. * Serializes this point in a JSON representation
  117995. * @returns the serialized point object
  117996. */
  117997. serialize(): any;
  117998. }
  117999. }
  118000. declare module BABYLON {
  118001. /**
  118002. * Block used to add support for vertex skinning (bones)
  118003. */
  118004. export class BonesBlock extends NodeMaterialBlock {
  118005. /**
  118006. * Creates a new BonesBlock
  118007. * @param name defines the block name
  118008. */
  118009. constructor(name: string);
  118010. /**
  118011. * Initialize the block and prepare the context for build
  118012. * @param state defines the state that will be used for the build
  118013. */
  118014. initialize(state: NodeMaterialBuildState): void;
  118015. /**
  118016. * Gets the current class name
  118017. * @returns the class name
  118018. */
  118019. getClassName(): string;
  118020. /**
  118021. * Gets the matrix indices input component
  118022. */
  118023. readonly matricesIndices: NodeMaterialConnectionPoint;
  118024. /**
  118025. * Gets the matrix weights input component
  118026. */
  118027. readonly matricesWeights: NodeMaterialConnectionPoint;
  118028. /**
  118029. * Gets the extra matrix indices input component
  118030. */
  118031. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  118032. /**
  118033. * Gets the extra matrix weights input component
  118034. */
  118035. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  118036. /**
  118037. * Gets the world input component
  118038. */
  118039. readonly world: NodeMaterialConnectionPoint;
  118040. /**
  118041. * Gets the output component
  118042. */
  118043. readonly output: NodeMaterialConnectionPoint;
  118044. autoConfigure(material: NodeMaterial): void;
  118045. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118048. protected _buildBlock(state: NodeMaterialBuildState): this;
  118049. }
  118050. }
  118051. declare module BABYLON {
  118052. /**
  118053. * Block used to add support for instances
  118054. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118055. */
  118056. export class InstancesBlock extends NodeMaterialBlock {
  118057. /**
  118058. * Creates a new InstancesBlock
  118059. * @param name defines the block name
  118060. */
  118061. constructor(name: string);
  118062. /**
  118063. * Gets the current class name
  118064. * @returns the class name
  118065. */
  118066. getClassName(): string;
  118067. /**
  118068. * Gets the first world row input component
  118069. */
  118070. readonly world0: NodeMaterialConnectionPoint;
  118071. /**
  118072. * Gets the second world row input component
  118073. */
  118074. readonly world1: NodeMaterialConnectionPoint;
  118075. /**
  118076. * Gets the third world row input component
  118077. */
  118078. readonly world2: NodeMaterialConnectionPoint;
  118079. /**
  118080. * Gets the forth world row input component
  118081. */
  118082. readonly world3: NodeMaterialConnectionPoint;
  118083. /**
  118084. * Gets the world input component
  118085. */
  118086. readonly world: NodeMaterialConnectionPoint;
  118087. /**
  118088. * Gets the output component
  118089. */
  118090. readonly output: NodeMaterialConnectionPoint;
  118091. autoConfigure(material: NodeMaterial): void;
  118092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118093. protected _buildBlock(state: NodeMaterialBuildState): this;
  118094. }
  118095. }
  118096. declare module BABYLON {
  118097. /**
  118098. * Block used to add morph targets support to vertex shader
  118099. */
  118100. export class MorphTargetsBlock extends NodeMaterialBlock {
  118101. private _repeatableContentAnchor;
  118102. private _repeatebleContentGenerated;
  118103. /**
  118104. * Create a new MorphTargetsBlock
  118105. * @param name defines the block name
  118106. */
  118107. constructor(name: string);
  118108. /**
  118109. * Gets the current class name
  118110. * @returns the class name
  118111. */
  118112. getClassName(): string;
  118113. /**
  118114. * Gets the position input component
  118115. */
  118116. readonly position: NodeMaterialConnectionPoint;
  118117. /**
  118118. * Gets the normal input component
  118119. */
  118120. readonly normal: NodeMaterialConnectionPoint;
  118121. /**
  118122. * Gets the tangent input component
  118123. */
  118124. readonly tangent: NodeMaterialConnectionPoint;
  118125. /**
  118126. * Gets the tangent input component
  118127. */
  118128. readonly uv: NodeMaterialConnectionPoint;
  118129. /**
  118130. * Gets the position output component
  118131. */
  118132. readonly positionOutput: NodeMaterialConnectionPoint;
  118133. /**
  118134. * Gets the normal output component
  118135. */
  118136. readonly normalOutput: NodeMaterialConnectionPoint;
  118137. /**
  118138. * Gets the tangent output component
  118139. */
  118140. readonly tangentOutput: NodeMaterialConnectionPoint;
  118141. /**
  118142. * Gets the tangent output component
  118143. */
  118144. readonly uvOutput: NodeMaterialConnectionPoint;
  118145. initialize(state: NodeMaterialBuildState): void;
  118146. autoConfigure(material: NodeMaterial): void;
  118147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118148. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118149. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118150. protected _buildBlock(state: NodeMaterialBuildState): this;
  118151. }
  118152. }
  118153. declare module BABYLON {
  118154. /**
  118155. * Block used to get data information from a light
  118156. */
  118157. export class LightInformationBlock extends NodeMaterialBlock {
  118158. private _lightDataDefineName;
  118159. private _lightColorDefineName;
  118160. /**
  118161. * Gets or sets the light associated with this block
  118162. */
  118163. light: Nullable<Light>;
  118164. /**
  118165. * Creates a new LightInformationBlock
  118166. * @param name defines the block name
  118167. */
  118168. constructor(name: string);
  118169. /**
  118170. * Gets the current class name
  118171. * @returns the class name
  118172. */
  118173. getClassName(): string;
  118174. /**
  118175. * Gets the world position input component
  118176. */
  118177. readonly worldPosition: NodeMaterialConnectionPoint;
  118178. /**
  118179. * Gets the direction output component
  118180. */
  118181. readonly direction: NodeMaterialConnectionPoint;
  118182. /**
  118183. * Gets the direction output component
  118184. */
  118185. readonly color: NodeMaterialConnectionPoint;
  118186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118187. protected _buildBlock(state: NodeMaterialBuildState): this;
  118188. serialize(): any;
  118189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118190. }
  118191. }
  118192. declare module BABYLON {
  118193. /**
  118194. * Block used to add an alpha test in the fragment shader
  118195. */
  118196. export class AlphaTestBlock extends NodeMaterialBlock {
  118197. /**
  118198. * Gets or sets the alpha value where alpha testing happens
  118199. */
  118200. alphaCutOff: number;
  118201. /**
  118202. * Create a new AlphaTestBlock
  118203. * @param name defines the block name
  118204. */
  118205. constructor(name: string);
  118206. /**
  118207. * Gets the current class name
  118208. * @returns the class name
  118209. */
  118210. getClassName(): string;
  118211. /**
  118212. * Gets the color input component
  118213. */
  118214. readonly color: NodeMaterialConnectionPoint;
  118215. /**
  118216. * Gets the alpha input component
  118217. */
  118218. readonly alpha: NodeMaterialConnectionPoint;
  118219. protected _buildBlock(state: NodeMaterialBuildState): this;
  118220. protected _dumpPropertiesCode(): string;
  118221. serialize(): any;
  118222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118223. }
  118224. }
  118225. declare module BABYLON {
  118226. /**
  118227. * Block used to add image processing support to fragment shader
  118228. */
  118229. export class ImageProcessingBlock extends NodeMaterialBlock {
  118230. /**
  118231. * Create a new ImageProcessingBlock
  118232. * @param name defines the block name
  118233. */
  118234. constructor(name: string);
  118235. /**
  118236. * Gets the current class name
  118237. * @returns the class name
  118238. */
  118239. getClassName(): string;
  118240. /**
  118241. * Gets the color input component
  118242. */
  118243. readonly color: NodeMaterialConnectionPoint;
  118244. /**
  118245. * Gets the output component
  118246. */
  118247. readonly output: NodeMaterialConnectionPoint;
  118248. /**
  118249. * Initialize the block and prepare the context for build
  118250. * @param state defines the state that will be used for the build
  118251. */
  118252. initialize(state: NodeMaterialBuildState): void;
  118253. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  118254. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118256. protected _buildBlock(state: NodeMaterialBuildState): this;
  118257. }
  118258. }
  118259. declare module BABYLON {
  118260. /**
  118261. * Block used to add support for scene fog
  118262. */
  118263. export class FogBlock extends NodeMaterialBlock {
  118264. private _fogDistanceName;
  118265. private _fogParameters;
  118266. /**
  118267. * Create a new FogBlock
  118268. * @param name defines the block name
  118269. */
  118270. constructor(name: string);
  118271. /**
  118272. * Gets the current class name
  118273. * @returns the class name
  118274. */
  118275. getClassName(): string;
  118276. /**
  118277. * Gets the world position input component
  118278. */
  118279. readonly worldPosition: NodeMaterialConnectionPoint;
  118280. /**
  118281. * Gets the view input component
  118282. */
  118283. readonly view: NodeMaterialConnectionPoint;
  118284. /**
  118285. * Gets the color input component
  118286. */
  118287. readonly input: NodeMaterialConnectionPoint;
  118288. /**
  118289. * Gets the fog color input component
  118290. */
  118291. readonly fogColor: NodeMaterialConnectionPoint;
  118292. /**
  118293. * Gets the output component
  118294. */
  118295. readonly output: NodeMaterialConnectionPoint;
  118296. autoConfigure(material: NodeMaterial): void;
  118297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118299. protected _buildBlock(state: NodeMaterialBuildState): this;
  118300. }
  118301. }
  118302. declare module BABYLON {
  118303. /**
  118304. * Block used to add light in the fragment shader
  118305. */
  118306. export class LightBlock extends NodeMaterialBlock {
  118307. private _lightId;
  118308. /**
  118309. * Gets or sets the light associated with this block
  118310. */
  118311. light: Nullable<Light>;
  118312. /**
  118313. * Create a new LightBlock
  118314. * @param name defines the block name
  118315. */
  118316. constructor(name: string);
  118317. /**
  118318. * Gets the current class name
  118319. * @returns the class name
  118320. */
  118321. getClassName(): string;
  118322. /**
  118323. * Gets the world position input component
  118324. */
  118325. readonly worldPosition: NodeMaterialConnectionPoint;
  118326. /**
  118327. * Gets the world normal input component
  118328. */
  118329. readonly worldNormal: NodeMaterialConnectionPoint;
  118330. /**
  118331. * Gets the camera (or eye) position component
  118332. */
  118333. readonly cameraPosition: NodeMaterialConnectionPoint;
  118334. /**
  118335. * Gets the diffuse output component
  118336. */
  118337. readonly diffuseOutput: NodeMaterialConnectionPoint;
  118338. /**
  118339. * Gets the specular output component
  118340. */
  118341. readonly specularOutput: NodeMaterialConnectionPoint;
  118342. autoConfigure(material: NodeMaterial): void;
  118343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118344. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118346. private _injectVertexCode;
  118347. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118348. serialize(): any;
  118349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118350. }
  118351. }
  118352. declare module BABYLON {
  118353. /**
  118354. * Block used to multiply 2 values
  118355. */
  118356. export class MultiplyBlock extends NodeMaterialBlock {
  118357. /**
  118358. * Creates a new MultiplyBlock
  118359. * @param name defines the block name
  118360. */
  118361. constructor(name: string);
  118362. /**
  118363. * Gets the current class name
  118364. * @returns the class name
  118365. */
  118366. getClassName(): string;
  118367. /**
  118368. * Gets the left operand input component
  118369. */
  118370. readonly left: NodeMaterialConnectionPoint;
  118371. /**
  118372. * Gets the right operand input component
  118373. */
  118374. readonly right: NodeMaterialConnectionPoint;
  118375. /**
  118376. * Gets the output component
  118377. */
  118378. readonly output: NodeMaterialConnectionPoint;
  118379. protected _buildBlock(state: NodeMaterialBuildState): this;
  118380. }
  118381. }
  118382. declare module BABYLON {
  118383. /**
  118384. * Block used to add 2 vectors
  118385. */
  118386. export class AddBlock extends NodeMaterialBlock {
  118387. /**
  118388. * Creates a new AddBlock
  118389. * @param name defines the block name
  118390. */
  118391. constructor(name: string);
  118392. /**
  118393. * Gets the current class name
  118394. * @returns the class name
  118395. */
  118396. getClassName(): string;
  118397. /**
  118398. * Gets the left operand input component
  118399. */
  118400. readonly left: NodeMaterialConnectionPoint;
  118401. /**
  118402. * Gets the right operand input component
  118403. */
  118404. readonly right: NodeMaterialConnectionPoint;
  118405. /**
  118406. * Gets the output component
  118407. */
  118408. readonly output: NodeMaterialConnectionPoint;
  118409. protected _buildBlock(state: NodeMaterialBuildState): this;
  118410. }
  118411. }
  118412. declare module BABYLON {
  118413. /**
  118414. * Block used to scale a vector by a float
  118415. */
  118416. export class ScaleBlock extends NodeMaterialBlock {
  118417. /**
  118418. * Creates a new ScaleBlock
  118419. * @param name defines the block name
  118420. */
  118421. constructor(name: string);
  118422. /**
  118423. * Gets the current class name
  118424. * @returns the class name
  118425. */
  118426. getClassName(): string;
  118427. /**
  118428. * Gets the input component
  118429. */
  118430. readonly input: NodeMaterialConnectionPoint;
  118431. /**
  118432. * Gets the factor input component
  118433. */
  118434. readonly factor: NodeMaterialConnectionPoint;
  118435. /**
  118436. * Gets the output component
  118437. */
  118438. readonly output: NodeMaterialConnectionPoint;
  118439. protected _buildBlock(state: NodeMaterialBuildState): this;
  118440. }
  118441. }
  118442. declare module BABYLON {
  118443. /**
  118444. * Block used to clamp a float
  118445. */
  118446. export class ClampBlock extends NodeMaterialBlock {
  118447. /** Gets or sets the minimum range */
  118448. minimum: number;
  118449. /** Gets or sets the maximum range */
  118450. maximum: number;
  118451. /**
  118452. * Creates a new ClampBlock
  118453. * @param name defines the block name
  118454. */
  118455. constructor(name: string);
  118456. /**
  118457. * Gets the current class name
  118458. * @returns the class name
  118459. */
  118460. getClassName(): string;
  118461. /**
  118462. * Gets the value input component
  118463. */
  118464. readonly value: NodeMaterialConnectionPoint;
  118465. /**
  118466. * Gets the output component
  118467. */
  118468. readonly output: NodeMaterialConnectionPoint;
  118469. protected _buildBlock(state: NodeMaterialBuildState): this;
  118470. protected _dumpPropertiesCode(): string;
  118471. serialize(): any;
  118472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118473. }
  118474. }
  118475. declare module BABYLON {
  118476. /**
  118477. * Block used to apply a cross product between 2 vectors
  118478. */
  118479. export class CrossBlock extends NodeMaterialBlock {
  118480. /**
  118481. * Creates a new CrossBlock
  118482. * @param name defines the block name
  118483. */
  118484. constructor(name: string);
  118485. /**
  118486. * Gets the current class name
  118487. * @returns the class name
  118488. */
  118489. getClassName(): string;
  118490. /**
  118491. * Gets the left operand input component
  118492. */
  118493. readonly left: NodeMaterialConnectionPoint;
  118494. /**
  118495. * Gets the right operand input component
  118496. */
  118497. readonly right: NodeMaterialConnectionPoint;
  118498. /**
  118499. * Gets the output component
  118500. */
  118501. readonly output: NodeMaterialConnectionPoint;
  118502. protected _buildBlock(state: NodeMaterialBuildState): this;
  118503. }
  118504. }
  118505. declare module BABYLON {
  118506. /**
  118507. * Block used to apply a dot product between 2 vectors
  118508. */
  118509. export class DotBlock extends NodeMaterialBlock {
  118510. /**
  118511. * Creates a new DotBlock
  118512. * @param name defines the block name
  118513. */
  118514. constructor(name: string);
  118515. /**
  118516. * Gets the current class name
  118517. * @returns the class name
  118518. */
  118519. getClassName(): string;
  118520. /**
  118521. * Gets the left operand input component
  118522. */
  118523. readonly left: NodeMaterialConnectionPoint;
  118524. /**
  118525. * Gets the right operand input component
  118526. */
  118527. readonly right: NodeMaterialConnectionPoint;
  118528. /**
  118529. * Gets the output component
  118530. */
  118531. readonly output: NodeMaterialConnectionPoint;
  118532. protected _buildBlock(state: NodeMaterialBuildState): this;
  118533. }
  118534. }
  118535. declare module BABYLON {
  118536. /**
  118537. * Block used to remap a float from a range to a new one
  118538. */
  118539. export class RemapBlock extends NodeMaterialBlock {
  118540. /**
  118541. * Gets or sets the source range
  118542. */
  118543. sourceRange: Vector2;
  118544. /**
  118545. * Gets or sets the target range
  118546. */
  118547. targetRange: Vector2;
  118548. /**
  118549. * Creates a new RemapBlock
  118550. * @param name defines the block name
  118551. */
  118552. constructor(name: string);
  118553. /**
  118554. * Gets the current class name
  118555. * @returns the class name
  118556. */
  118557. getClassName(): string;
  118558. /**
  118559. * Gets the input component
  118560. */
  118561. readonly input: NodeMaterialConnectionPoint;
  118562. /**
  118563. * Gets the output component
  118564. */
  118565. readonly output: NodeMaterialConnectionPoint;
  118566. protected _buildBlock(state: NodeMaterialBuildState): this;
  118567. protected _dumpPropertiesCode(): string;
  118568. serialize(): any;
  118569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118570. }
  118571. }
  118572. declare module BABYLON {
  118573. /**
  118574. * Block used to normalize a vector
  118575. */
  118576. export class NormalizeBlock extends NodeMaterialBlock {
  118577. /**
  118578. * Creates a new NormalizeBlock
  118579. * @param name defines the block name
  118580. */
  118581. constructor(name: string);
  118582. /**
  118583. * Gets the current class name
  118584. * @returns the class name
  118585. */
  118586. getClassName(): string;
  118587. /**
  118588. * Gets the input component
  118589. */
  118590. readonly input: NodeMaterialConnectionPoint;
  118591. /**
  118592. * Gets the output component
  118593. */
  118594. readonly output: NodeMaterialConnectionPoint;
  118595. protected _buildBlock(state: NodeMaterialBuildState): this;
  118596. }
  118597. }
  118598. declare module BABYLON {
  118599. /**
  118600. * Operations supported by the Trigonometry block
  118601. */
  118602. export enum TrigonometryBlockOperations {
  118603. /** Cos */
  118604. Cos = 0,
  118605. /** Sin */
  118606. Sin = 1,
  118607. /** Abs */
  118608. Abs = 2,
  118609. /** Exp */
  118610. Exp = 3,
  118611. /** Exp2 */
  118612. Exp2 = 4,
  118613. /** Round */
  118614. Round = 5,
  118615. /** Floor */
  118616. Floor = 6,
  118617. /** Ceiling */
  118618. Ceiling = 7
  118619. }
  118620. /**
  118621. * Block used to apply trigonometry operation to floats
  118622. */
  118623. export class TrigonometryBlock extends NodeMaterialBlock {
  118624. /**
  118625. * Gets or sets the operation applied by the block
  118626. */
  118627. operation: TrigonometryBlockOperations;
  118628. /**
  118629. * Creates a new TrigonometryBlock
  118630. * @param name defines the block name
  118631. */
  118632. constructor(name: string);
  118633. /**
  118634. * Gets the current class name
  118635. * @returns the class name
  118636. */
  118637. getClassName(): string;
  118638. /**
  118639. * Gets the input component
  118640. */
  118641. readonly input: NodeMaterialConnectionPoint;
  118642. /**
  118643. * Gets the output component
  118644. */
  118645. readonly output: NodeMaterialConnectionPoint;
  118646. protected _buildBlock(state: NodeMaterialBuildState): this;
  118647. }
  118648. }
  118649. declare module BABYLON {
  118650. /**
  118651. * Block used to create a Color3/4 out of individual inputs (one for each component)
  118652. */
  118653. export class ColorMergerBlock extends NodeMaterialBlock {
  118654. /**
  118655. * Create a new ColorMergerBlock
  118656. * @param name defines the block name
  118657. */
  118658. constructor(name: string);
  118659. /**
  118660. * Gets the current class name
  118661. * @returns the class name
  118662. */
  118663. getClassName(): string;
  118664. /**
  118665. * Gets the r component (input)
  118666. */
  118667. readonly r: NodeMaterialConnectionPoint;
  118668. /**
  118669. * Gets the g component (input)
  118670. */
  118671. readonly g: NodeMaterialConnectionPoint;
  118672. /**
  118673. * Gets the b component (input)
  118674. */
  118675. readonly b: NodeMaterialConnectionPoint;
  118676. /**
  118677. * Gets the a component (input)
  118678. */
  118679. readonly a: NodeMaterialConnectionPoint;
  118680. /**
  118681. * Gets the rgba component (output)
  118682. */
  118683. readonly rgba: NodeMaterialConnectionPoint;
  118684. /**
  118685. * Gets the rgb component (output)
  118686. */
  118687. readonly rgb: NodeMaterialConnectionPoint;
  118688. protected _buildBlock(state: NodeMaterialBuildState): this;
  118689. }
  118690. }
  118691. declare module BABYLON {
  118692. /**
  118693. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  118694. */
  118695. export class VectorMergerBlock extends NodeMaterialBlock {
  118696. /**
  118697. * Create a new VectorMergerBlock
  118698. * @param name defines the block name
  118699. */
  118700. constructor(name: string);
  118701. /**
  118702. * Gets the current class name
  118703. * @returns the class name
  118704. */
  118705. getClassName(): string;
  118706. /**
  118707. * Gets the x component (input)
  118708. */
  118709. readonly x: NodeMaterialConnectionPoint;
  118710. /**
  118711. * Gets the y component (input)
  118712. */
  118713. readonly y: NodeMaterialConnectionPoint;
  118714. /**
  118715. * Gets the z component (input)
  118716. */
  118717. readonly z: NodeMaterialConnectionPoint;
  118718. /**
  118719. * Gets the w component (input)
  118720. */
  118721. readonly w: NodeMaterialConnectionPoint;
  118722. /**
  118723. * Gets the xyzw component (output)
  118724. */
  118725. readonly xyzw: NodeMaterialConnectionPoint;
  118726. /**
  118727. * Gets the xyz component (output)
  118728. */
  118729. readonly xyz: NodeMaterialConnectionPoint;
  118730. /**
  118731. * Gets the xy component (output)
  118732. */
  118733. readonly xy: NodeMaterialConnectionPoint;
  118734. protected _buildBlock(state: NodeMaterialBuildState): this;
  118735. }
  118736. }
  118737. declare module BABYLON {
  118738. /**
  118739. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  118740. */
  118741. export class ColorSplitterBlock extends NodeMaterialBlock {
  118742. /**
  118743. * Create a new ColorSplitterBlock
  118744. * @param name defines the block name
  118745. */
  118746. constructor(name: string);
  118747. /**
  118748. * Gets the current class name
  118749. * @returns the class name
  118750. */
  118751. getClassName(): string;
  118752. /**
  118753. * Gets the rgba component (input)
  118754. */
  118755. readonly rgba: NodeMaterialConnectionPoint;
  118756. /**
  118757. * Gets the rgb component (input)
  118758. */
  118759. readonly rgbIn: NodeMaterialConnectionPoint;
  118760. /**
  118761. * Gets the rgb component (output)
  118762. */
  118763. readonly rgbOut: NodeMaterialConnectionPoint;
  118764. /**
  118765. * Gets the r component (output)
  118766. */
  118767. readonly r: NodeMaterialConnectionPoint;
  118768. /**
  118769. * Gets the g component (output)
  118770. */
  118771. readonly g: NodeMaterialConnectionPoint;
  118772. /**
  118773. * Gets the b component (output)
  118774. */
  118775. readonly b: NodeMaterialConnectionPoint;
  118776. /**
  118777. * Gets the a component (output)
  118778. */
  118779. readonly a: NodeMaterialConnectionPoint;
  118780. protected _inputRename(name: string): string;
  118781. protected _outputRename(name: string): string;
  118782. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118783. }
  118784. }
  118785. declare module BABYLON {
  118786. /**
  118787. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  118788. */
  118789. export class VectorSplitterBlock extends NodeMaterialBlock {
  118790. /**
  118791. * Create a new VectorSplitterBlock
  118792. * @param name defines the block name
  118793. */
  118794. constructor(name: string);
  118795. /**
  118796. * Gets the current class name
  118797. * @returns the class name
  118798. */
  118799. getClassName(): string;
  118800. /**
  118801. * Gets the xyzw component (input)
  118802. */
  118803. readonly xyzw: NodeMaterialConnectionPoint;
  118804. /**
  118805. * Gets the xyz component (input)
  118806. */
  118807. readonly xyzIn: NodeMaterialConnectionPoint;
  118808. /**
  118809. * Gets the xy component (input)
  118810. */
  118811. readonly xyIn: NodeMaterialConnectionPoint;
  118812. /**
  118813. * Gets the xyz component (output)
  118814. */
  118815. readonly xyzOut: NodeMaterialConnectionPoint;
  118816. /**
  118817. * Gets the xy component (output)
  118818. */
  118819. readonly xyOut: NodeMaterialConnectionPoint;
  118820. /**
  118821. * Gets the x component (output)
  118822. */
  118823. readonly x: NodeMaterialConnectionPoint;
  118824. /**
  118825. * Gets the y component (output)
  118826. */
  118827. readonly y: NodeMaterialConnectionPoint;
  118828. /**
  118829. * Gets the z component (output)
  118830. */
  118831. readonly z: NodeMaterialConnectionPoint;
  118832. /**
  118833. * Gets the w component (output)
  118834. */
  118835. readonly w: NodeMaterialConnectionPoint;
  118836. protected _inputRename(name: string): string;
  118837. protected _outputRename(name: string): string;
  118838. protected _buildBlock(state: NodeMaterialBuildState): this;
  118839. }
  118840. }
  118841. declare module BABYLON {
  118842. /**
  118843. * Block used to lerp 2 values
  118844. */
  118845. export class LerpBlock extends NodeMaterialBlock {
  118846. /**
  118847. * Creates a new LerpBlock
  118848. * @param name defines the block name
  118849. */
  118850. constructor(name: string);
  118851. /**
  118852. * Gets the current class name
  118853. * @returns the class name
  118854. */
  118855. getClassName(): string;
  118856. /**
  118857. * Gets the left operand input component
  118858. */
  118859. readonly left: NodeMaterialConnectionPoint;
  118860. /**
  118861. * Gets the right operand input component
  118862. */
  118863. readonly right: NodeMaterialConnectionPoint;
  118864. /**
  118865. * Gets the gradient operand input component
  118866. */
  118867. readonly gradient: NodeMaterialConnectionPoint;
  118868. /**
  118869. * Gets the output component
  118870. */
  118871. readonly output: NodeMaterialConnectionPoint;
  118872. protected _buildBlock(state: NodeMaterialBuildState): this;
  118873. }
  118874. }
  118875. declare module BABYLON {
  118876. /**
  118877. * Block used to divide 2 vectors
  118878. */
  118879. export class DivideBlock extends NodeMaterialBlock {
  118880. /**
  118881. * Creates a new DivideBlock
  118882. * @param name defines the block name
  118883. */
  118884. constructor(name: string);
  118885. /**
  118886. * Gets the current class name
  118887. * @returns the class name
  118888. */
  118889. getClassName(): string;
  118890. /**
  118891. * Gets the left operand input component
  118892. */
  118893. readonly left: NodeMaterialConnectionPoint;
  118894. /**
  118895. * Gets the right operand input component
  118896. */
  118897. readonly right: NodeMaterialConnectionPoint;
  118898. /**
  118899. * Gets the output component
  118900. */
  118901. readonly output: NodeMaterialConnectionPoint;
  118902. protected _buildBlock(state: NodeMaterialBuildState): this;
  118903. }
  118904. }
  118905. declare module BABYLON {
  118906. /**
  118907. * Block used to subtract 2 vectors
  118908. */
  118909. export class SubtractBlock extends NodeMaterialBlock {
  118910. /**
  118911. * Creates a new SubtractBlock
  118912. * @param name defines the block name
  118913. */
  118914. constructor(name: string);
  118915. /**
  118916. * Gets the current class name
  118917. * @returns the class name
  118918. */
  118919. getClassName(): string;
  118920. /**
  118921. * Gets the left operand input component
  118922. */
  118923. readonly left: NodeMaterialConnectionPoint;
  118924. /**
  118925. * Gets the right operand input component
  118926. */
  118927. readonly right: NodeMaterialConnectionPoint;
  118928. /**
  118929. * Gets the output component
  118930. */
  118931. readonly output: NodeMaterialConnectionPoint;
  118932. protected _buildBlock(state: NodeMaterialBuildState): this;
  118933. }
  118934. }
  118935. declare module BABYLON {
  118936. /**
  118937. * Block used to step a value
  118938. */
  118939. export class StepBlock extends NodeMaterialBlock {
  118940. /**
  118941. * Creates a new AddBlock
  118942. * @param name defines the block name
  118943. */
  118944. constructor(name: string);
  118945. /**
  118946. * Gets the current class name
  118947. * @returns the class name
  118948. */
  118949. getClassName(): string;
  118950. /**
  118951. * Gets the value operand input component
  118952. */
  118953. readonly value: NodeMaterialConnectionPoint;
  118954. /**
  118955. * Gets the edge operand input component
  118956. */
  118957. readonly edge: NodeMaterialConnectionPoint;
  118958. /**
  118959. * Gets the output component
  118960. */
  118961. readonly output: NodeMaterialConnectionPoint;
  118962. protected _buildBlock(state: NodeMaterialBuildState): this;
  118963. }
  118964. }
  118965. declare module BABYLON {
  118966. /**
  118967. * Block used to get the opposite of a value
  118968. */
  118969. export class OppositeBlock extends NodeMaterialBlock {
  118970. /**
  118971. * Creates a new OppositeBlock
  118972. * @param name defines the block name
  118973. */
  118974. constructor(name: string);
  118975. /**
  118976. * Gets the current class name
  118977. * @returns the class name
  118978. */
  118979. getClassName(): string;
  118980. /**
  118981. * Gets the input component
  118982. */
  118983. readonly input: NodeMaterialConnectionPoint;
  118984. /**
  118985. * Gets the output component
  118986. */
  118987. readonly output: NodeMaterialConnectionPoint;
  118988. protected _buildBlock(state: NodeMaterialBuildState): this;
  118989. }
  118990. }
  118991. declare module BABYLON {
  118992. /**
  118993. * Block used to get the view direction
  118994. */
  118995. export class ViewDirectionBlock extends NodeMaterialBlock {
  118996. /**
  118997. * Creates a new ViewDirectionBlock
  118998. * @param name defines the block name
  118999. */
  119000. constructor(name: string);
  119001. /**
  119002. * Gets the current class name
  119003. * @returns the class name
  119004. */
  119005. getClassName(): string;
  119006. /**
  119007. * Gets the world position component
  119008. */
  119009. readonly worldPosition: NodeMaterialConnectionPoint;
  119010. /**
  119011. * Gets the camera position component
  119012. */
  119013. readonly cameraPosition: NodeMaterialConnectionPoint;
  119014. /**
  119015. * Gets the output component
  119016. */
  119017. readonly output: NodeMaterialConnectionPoint;
  119018. autoConfigure(material: NodeMaterial): void;
  119019. protected _buildBlock(state: NodeMaterialBuildState): this;
  119020. }
  119021. }
  119022. declare module BABYLON {
  119023. /**
  119024. * Block used to compute fresnel value
  119025. */
  119026. export class FresnelBlock extends NodeMaterialBlock {
  119027. /**
  119028. * Create a new FresnelBlock
  119029. * @param name defines the block name
  119030. */
  119031. constructor(name: string);
  119032. /**
  119033. * Gets the current class name
  119034. * @returns the class name
  119035. */
  119036. getClassName(): string;
  119037. /**
  119038. * Gets the world normal input component
  119039. */
  119040. readonly worldNormal: NodeMaterialConnectionPoint;
  119041. /**
  119042. * Gets the view direction input component
  119043. */
  119044. readonly viewDirection: NodeMaterialConnectionPoint;
  119045. /**
  119046. * Gets the bias input component
  119047. */
  119048. readonly bias: NodeMaterialConnectionPoint;
  119049. /**
  119050. * Gets the camera (or eye) position component
  119051. */
  119052. readonly power: NodeMaterialConnectionPoint;
  119053. /**
  119054. * Gets the fresnel output component
  119055. */
  119056. readonly fresnel: NodeMaterialConnectionPoint;
  119057. autoConfigure(material: NodeMaterial): void;
  119058. protected _buildBlock(state: NodeMaterialBuildState): this;
  119059. }
  119060. }
  119061. declare module BABYLON {
  119062. /**
  119063. * Effect Render Options
  119064. */
  119065. export interface IEffectRendererOptions {
  119066. /**
  119067. * Defines the vertices positions.
  119068. */
  119069. positions?: number[];
  119070. /**
  119071. * Defines the indices.
  119072. */
  119073. indices?: number[];
  119074. }
  119075. /**
  119076. * Helper class to render one or more effects
  119077. */
  119078. export class EffectRenderer {
  119079. private engine;
  119080. private static _DefaultOptions;
  119081. private _vertexBuffers;
  119082. private _indexBuffer;
  119083. private _ringBufferIndex;
  119084. private _ringScreenBuffer;
  119085. private _fullscreenViewport;
  119086. private _getNextFrameBuffer;
  119087. /**
  119088. * Creates an effect renderer
  119089. * @param engine the engine to use for rendering
  119090. * @param options defines the options of the effect renderer
  119091. */
  119092. constructor(engine: Engine, options?: IEffectRendererOptions);
  119093. /**
  119094. * Sets the current viewport in normalized coordinates 0-1
  119095. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  119096. */
  119097. setViewport(viewport?: Viewport): void;
  119098. /**
  119099. * Sets the current effect wrapper to use during draw.
  119100. * The effect needs to be ready before calling this api.
  119101. * This also sets the default full screen position attribute.
  119102. * @param effectWrapper Defines the effect to draw with
  119103. */
  119104. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  119105. /**
  119106. * Draws a full screen quad.
  119107. */
  119108. draw(): void;
  119109. /**
  119110. * renders one or more effects to a specified texture
  119111. * @param effectWrappers list of effects to renderer
  119112. * @param outputTexture texture to draw to, if null it will render to the screen
  119113. */
  119114. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  119115. /**
  119116. * Disposes of the effect renderer
  119117. */
  119118. dispose(): void;
  119119. }
  119120. /**
  119121. * Options to create an EffectWrapper
  119122. */
  119123. interface EffectWrapperCreationOptions {
  119124. /**
  119125. * Engine to use to create the effect
  119126. */
  119127. engine: Engine;
  119128. /**
  119129. * Fragment shader for the effect
  119130. */
  119131. fragmentShader: string;
  119132. /**
  119133. * Vertex shader for the effect
  119134. */
  119135. vertexShader?: string;
  119136. /**
  119137. * Attributes to use in the shader
  119138. */
  119139. attributeNames?: Array<string>;
  119140. /**
  119141. * Uniforms to use in the shader
  119142. */
  119143. uniformNames?: Array<string>;
  119144. /**
  119145. * Texture sampler names to use in the shader
  119146. */
  119147. samplerNames?: Array<string>;
  119148. /**
  119149. * The friendly name of the effect displayed in Spector.
  119150. */
  119151. name?: string;
  119152. }
  119153. /**
  119154. * Wraps an effect to be used for rendering
  119155. */
  119156. export class EffectWrapper {
  119157. /**
  119158. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  119159. */
  119160. onApplyObservable: Observable<{}>;
  119161. /**
  119162. * The underlying effect
  119163. */
  119164. effect: Effect;
  119165. /**
  119166. * Creates an effect to be renderer
  119167. * @param creationOptions options to create the effect
  119168. */
  119169. constructor(creationOptions: EffectWrapperCreationOptions);
  119170. /**
  119171. * Disposes of the effect wrapper
  119172. */
  119173. dispose(): void;
  119174. }
  119175. }
  119176. declare module BABYLON {
  119177. /**
  119178. * Helper class to push actions to a pool of workers.
  119179. */
  119180. export class WorkerPool implements IDisposable {
  119181. private _workerInfos;
  119182. private _pendingActions;
  119183. /**
  119184. * Constructor
  119185. * @param workers Array of workers to use for actions
  119186. */
  119187. constructor(workers: Array<Worker>);
  119188. /**
  119189. * Terminates all workers and clears any pending actions.
  119190. */
  119191. dispose(): void;
  119192. /**
  119193. * Pushes an action to the worker pool. If all the workers are active, the action will be
  119194. * pended until a worker has completed its action.
  119195. * @param action The action to perform. Call onComplete when the action is complete.
  119196. */
  119197. push(action: (worker: Worker, onComplete: () => void) => void): void;
  119198. private _execute;
  119199. }
  119200. }
  119201. declare module BABYLON {
  119202. /**
  119203. * Configuration for Draco compression
  119204. */
  119205. export interface IDracoCompressionConfiguration {
  119206. /**
  119207. * Configuration for the decoder.
  119208. */
  119209. decoder: {
  119210. /**
  119211. * The url to the WebAssembly module.
  119212. */
  119213. wasmUrl?: string;
  119214. /**
  119215. * The url to the WebAssembly binary.
  119216. */
  119217. wasmBinaryUrl?: string;
  119218. /**
  119219. * The url to the fallback JavaScript module.
  119220. */
  119221. fallbackUrl?: string;
  119222. };
  119223. }
  119224. /**
  119225. * Draco compression (https://google.github.io/draco/)
  119226. *
  119227. * This class wraps the Draco module.
  119228. *
  119229. * **Encoder**
  119230. *
  119231. * The encoder is not currently implemented.
  119232. *
  119233. * **Decoder**
  119234. *
  119235. * 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.
  119236. *
  119237. * To update the configuration, use the following code:
  119238. * ```javascript
  119239. * DracoCompression.Configuration = {
  119240. * decoder: {
  119241. * wasmUrl: "<url to the WebAssembly library>",
  119242. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  119243. * fallbackUrl: "<url to the fallback JavaScript library>",
  119244. * }
  119245. * };
  119246. * ```
  119247. *
  119248. * 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.
  119249. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  119250. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  119251. *
  119252. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  119253. * ```javascript
  119254. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  119255. * ```
  119256. *
  119257. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  119258. */
  119259. export class DracoCompression implements IDisposable {
  119260. private _workerPoolPromise?;
  119261. private _decoderModulePromise?;
  119262. /**
  119263. * The configuration. Defaults to the following urls:
  119264. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  119265. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  119266. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  119267. */
  119268. static Configuration: IDracoCompressionConfiguration;
  119269. /**
  119270. * Returns true if the decoder configuration is available.
  119271. */
  119272. static readonly DecoderAvailable: boolean;
  119273. /**
  119274. * Default number of workers to create when creating the draco compression object.
  119275. */
  119276. static DefaultNumWorkers: number;
  119277. private static GetDefaultNumWorkers;
  119278. private static _Default;
  119279. /**
  119280. * Default instance for the draco compression object.
  119281. */
  119282. static readonly Default: DracoCompression;
  119283. /**
  119284. * Constructor
  119285. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  119286. */
  119287. constructor(numWorkers?: number);
  119288. /**
  119289. * Stop all async operations and release resources.
  119290. */
  119291. dispose(): void;
  119292. /**
  119293. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  119294. * @returns a promise that resolves when ready
  119295. */
  119296. whenReadyAsync(): Promise<void>;
  119297. /**
  119298. * Decode Draco compressed mesh data to vertex data.
  119299. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  119300. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  119301. * @returns A promise that resolves with the decoded vertex data
  119302. */
  119303. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  119304. [kind: string]: number;
  119305. }): Promise<VertexData>;
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. /**
  119310. * Class for building Constructive Solid Geometry
  119311. */
  119312. export class CSG {
  119313. private polygons;
  119314. /**
  119315. * The world matrix
  119316. */
  119317. matrix: Matrix;
  119318. /**
  119319. * Stores the position
  119320. */
  119321. position: Vector3;
  119322. /**
  119323. * Stores the rotation
  119324. */
  119325. rotation: Vector3;
  119326. /**
  119327. * Stores the rotation quaternion
  119328. */
  119329. rotationQuaternion: Nullable<Quaternion>;
  119330. /**
  119331. * Stores the scaling vector
  119332. */
  119333. scaling: Vector3;
  119334. /**
  119335. * Convert the Mesh to CSG
  119336. * @param mesh The Mesh to convert to CSG
  119337. * @returns A new CSG from the Mesh
  119338. */
  119339. static FromMesh(mesh: Mesh): CSG;
  119340. /**
  119341. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  119342. * @param polygons Polygons used to construct a CSG solid
  119343. */
  119344. private static FromPolygons;
  119345. /**
  119346. * Clones, or makes a deep copy, of the CSG
  119347. * @returns A new CSG
  119348. */
  119349. clone(): CSG;
  119350. /**
  119351. * Unions this CSG with another CSG
  119352. * @param csg The CSG to union against this CSG
  119353. * @returns The unioned CSG
  119354. */
  119355. union(csg: CSG): CSG;
  119356. /**
  119357. * Unions this CSG with another CSG in place
  119358. * @param csg The CSG to union against this CSG
  119359. */
  119360. unionInPlace(csg: CSG): void;
  119361. /**
  119362. * Subtracts this CSG with another CSG
  119363. * @param csg The CSG to subtract against this CSG
  119364. * @returns A new CSG
  119365. */
  119366. subtract(csg: CSG): CSG;
  119367. /**
  119368. * Subtracts this CSG with another CSG in place
  119369. * @param csg The CSG to subtact against this CSG
  119370. */
  119371. subtractInPlace(csg: CSG): void;
  119372. /**
  119373. * Intersect this CSG with another CSG
  119374. * @param csg The CSG to intersect against this CSG
  119375. * @returns A new CSG
  119376. */
  119377. intersect(csg: CSG): CSG;
  119378. /**
  119379. * Intersects this CSG with another CSG in place
  119380. * @param csg The CSG to intersect against this CSG
  119381. */
  119382. intersectInPlace(csg: CSG): void;
  119383. /**
  119384. * Return a new CSG solid with solid and empty space switched. This solid is
  119385. * not modified.
  119386. * @returns A new CSG solid with solid and empty space switched
  119387. */
  119388. inverse(): CSG;
  119389. /**
  119390. * Inverses the CSG in place
  119391. */
  119392. inverseInPlace(): void;
  119393. /**
  119394. * This is used to keep meshes transformations so they can be restored
  119395. * when we build back a Babylon Mesh
  119396. * NB : All CSG operations are performed in world coordinates
  119397. * @param csg The CSG to copy the transform attributes from
  119398. * @returns This CSG
  119399. */
  119400. copyTransformAttributes(csg: CSG): CSG;
  119401. /**
  119402. * Build Raw mesh from CSG
  119403. * Coordinates here are in world space
  119404. * @param name The name of the mesh geometry
  119405. * @param scene The Scene
  119406. * @param keepSubMeshes Specifies if the submeshes should be kept
  119407. * @returns A new Mesh
  119408. */
  119409. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119410. /**
  119411. * Build Mesh from CSG taking material and transforms into account
  119412. * @param name The name of the Mesh
  119413. * @param material The material of the Mesh
  119414. * @param scene The Scene
  119415. * @param keepSubMeshes Specifies if submeshes should be kept
  119416. * @returns The new Mesh
  119417. */
  119418. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119419. }
  119420. }
  119421. declare module BABYLON {
  119422. /**
  119423. * Class used to create a trail following a mesh
  119424. */
  119425. export class TrailMesh extends Mesh {
  119426. private _generator;
  119427. private _autoStart;
  119428. private _running;
  119429. private _diameter;
  119430. private _length;
  119431. private _sectionPolygonPointsCount;
  119432. private _sectionVectors;
  119433. private _sectionNormalVectors;
  119434. private _beforeRenderObserver;
  119435. /**
  119436. * @constructor
  119437. * @param name The value used by scene.getMeshByName() to do a lookup.
  119438. * @param generator The mesh to generate a trail.
  119439. * @param scene The scene to add this mesh to.
  119440. * @param diameter Diameter of trailing mesh. Default is 1.
  119441. * @param length Length of trailing mesh. Default is 60.
  119442. * @param autoStart Automatically start trailing mesh. Default true.
  119443. */
  119444. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  119445. /**
  119446. * "TrailMesh"
  119447. * @returns "TrailMesh"
  119448. */
  119449. getClassName(): string;
  119450. private _createMesh;
  119451. /**
  119452. * Start trailing mesh.
  119453. */
  119454. start(): void;
  119455. /**
  119456. * Stop trailing mesh.
  119457. */
  119458. stop(): void;
  119459. /**
  119460. * Update trailing mesh geometry.
  119461. */
  119462. update(): void;
  119463. /**
  119464. * Returns a new TrailMesh object.
  119465. * @param name is a string, the name given to the new mesh
  119466. * @param newGenerator use new generator object for cloned trail mesh
  119467. * @returns a new mesh
  119468. */
  119469. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  119470. /**
  119471. * Serializes this trail mesh
  119472. * @param serializationObject object to write serialization to
  119473. */
  119474. serialize(serializationObject: any): void;
  119475. /**
  119476. * Parses a serialized trail mesh
  119477. * @param parsedMesh the serialized mesh
  119478. * @param scene the scene to create the trail mesh in
  119479. * @returns the created trail mesh
  119480. */
  119481. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  119482. }
  119483. }
  119484. declare module BABYLON {
  119485. /**
  119486. * Class containing static functions to help procedurally build meshes
  119487. */
  119488. export class TiledBoxBuilder {
  119489. /**
  119490. * Creates a box mesh
  119491. * 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)
  119492. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119496. * @param name defines the name of the mesh
  119497. * @param options defines the options used to create the mesh
  119498. * @param scene defines the hosting scene
  119499. * @returns the box mesh
  119500. */
  119501. static CreateTiledBox(name: string, options: {
  119502. pattern?: number;
  119503. width?: number;
  119504. height?: number;
  119505. depth?: number;
  119506. tileSize?: number;
  119507. tileWidth?: number;
  119508. tileHeight?: number;
  119509. alignHorizontal?: number;
  119510. alignVertical?: number;
  119511. faceUV?: Vector4[];
  119512. faceColors?: Color4[];
  119513. sideOrientation?: number;
  119514. updatable?: boolean;
  119515. }, scene?: Nullable<Scene>): Mesh;
  119516. }
  119517. }
  119518. declare module BABYLON {
  119519. /**
  119520. * Class containing static functions to help procedurally build meshes
  119521. */
  119522. export class TorusKnotBuilder {
  119523. /**
  119524. * Creates a torus knot mesh
  119525. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119526. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119527. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119528. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119532. * @param name defines the name of the mesh
  119533. * @param options defines the options used to create the mesh
  119534. * @param scene defines the hosting scene
  119535. * @returns the torus knot mesh
  119536. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119537. */
  119538. static CreateTorusKnot(name: string, options: {
  119539. radius?: number;
  119540. tube?: number;
  119541. radialSegments?: number;
  119542. tubularSegments?: number;
  119543. p?: number;
  119544. q?: number;
  119545. updatable?: boolean;
  119546. sideOrientation?: number;
  119547. frontUVs?: Vector4;
  119548. backUVs?: Vector4;
  119549. }, scene: any): Mesh;
  119550. }
  119551. }
  119552. declare module BABYLON {
  119553. /**
  119554. * Polygon
  119555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  119556. */
  119557. export class Polygon {
  119558. /**
  119559. * Creates a rectangle
  119560. * @param xmin bottom X coord
  119561. * @param ymin bottom Y coord
  119562. * @param xmax top X coord
  119563. * @param ymax top Y coord
  119564. * @returns points that make the resulting rectation
  119565. */
  119566. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  119567. /**
  119568. * Creates a circle
  119569. * @param radius radius of circle
  119570. * @param cx scale in x
  119571. * @param cy scale in y
  119572. * @param numberOfSides number of sides that make up the circle
  119573. * @returns points that make the resulting circle
  119574. */
  119575. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  119576. /**
  119577. * Creates a polygon from input string
  119578. * @param input Input polygon data
  119579. * @returns the parsed points
  119580. */
  119581. static Parse(input: string): Vector2[];
  119582. /**
  119583. * Starts building a polygon from x and y coordinates
  119584. * @param x x coordinate
  119585. * @param y y coordinate
  119586. * @returns the started path2
  119587. */
  119588. static StartingAt(x: number, y: number): Path2;
  119589. }
  119590. /**
  119591. * Builds a polygon
  119592. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  119593. */
  119594. export class PolygonMeshBuilder {
  119595. private _points;
  119596. private _outlinepoints;
  119597. private _holes;
  119598. private _name;
  119599. private _scene;
  119600. private _epoints;
  119601. private _eholes;
  119602. private _addToepoint;
  119603. /**
  119604. * Babylon reference to the earcut plugin.
  119605. */
  119606. bjsEarcut: any;
  119607. /**
  119608. * Creates a PolygonMeshBuilder
  119609. * @param name name of the builder
  119610. * @param contours Path of the polygon
  119611. * @param scene scene to add to when creating the mesh
  119612. * @param earcutInjection can be used to inject your own earcut reference
  119613. */
  119614. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  119615. /**
  119616. * Adds a whole within the polygon
  119617. * @param hole Array of points defining the hole
  119618. * @returns this
  119619. */
  119620. addHole(hole: Vector2[]): PolygonMeshBuilder;
  119621. /**
  119622. * Creates the polygon
  119623. * @param updatable If the mesh should be updatable
  119624. * @param depth The depth of the mesh created
  119625. * @returns the created mesh
  119626. */
  119627. build(updatable?: boolean, depth?: number): Mesh;
  119628. /**
  119629. * Creates the polygon
  119630. * @param depth The depth of the mesh created
  119631. * @returns the created VertexData
  119632. */
  119633. buildVertexData(depth?: number): VertexData;
  119634. /**
  119635. * Adds a side to the polygon
  119636. * @param positions points that make the polygon
  119637. * @param normals normals of the polygon
  119638. * @param uvs uvs of the polygon
  119639. * @param indices indices of the polygon
  119640. * @param bounds bounds of the polygon
  119641. * @param points points of the polygon
  119642. * @param depth depth of the polygon
  119643. * @param flip flip of the polygon
  119644. */
  119645. private addSide;
  119646. }
  119647. }
  119648. declare module BABYLON {
  119649. /**
  119650. * Class containing static functions to help procedurally build meshes
  119651. */
  119652. export class PolygonBuilder {
  119653. /**
  119654. * Creates a polygon mesh
  119655. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119656. * * 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
  119657. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119660. * * Remember you can only change the shape positions, not their number when updating a polygon
  119661. * @param name defines the name of the mesh
  119662. * @param options defines the options used to create the mesh
  119663. * @param scene defines the hosting scene
  119664. * @param earcutInjection can be used to inject your own earcut reference
  119665. * @returns the polygon mesh
  119666. */
  119667. static CreatePolygon(name: string, options: {
  119668. shape: Vector3[];
  119669. holes?: Vector3[][];
  119670. depth?: number;
  119671. faceUV?: Vector4[];
  119672. faceColors?: Color4[];
  119673. updatable?: boolean;
  119674. sideOrientation?: number;
  119675. frontUVs?: Vector4;
  119676. backUVs?: Vector4;
  119677. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119678. /**
  119679. * Creates an extruded polygon mesh, with depth in the Y direction.
  119680. * * 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)
  119681. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119682. * @param name defines the name of the mesh
  119683. * @param options defines the options used to create the mesh
  119684. * @param scene defines the hosting scene
  119685. * @param earcutInjection can be used to inject your own earcut reference
  119686. * @returns the polygon mesh
  119687. */
  119688. static ExtrudePolygon(name: string, options: {
  119689. shape: Vector3[];
  119690. holes?: Vector3[][];
  119691. depth?: number;
  119692. faceUV?: Vector4[];
  119693. faceColors?: Color4[];
  119694. updatable?: boolean;
  119695. sideOrientation?: number;
  119696. frontUVs?: Vector4;
  119697. backUVs?: Vector4;
  119698. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119699. }
  119700. }
  119701. declare module BABYLON {
  119702. /**
  119703. * Class containing static functions to help procedurally build meshes
  119704. */
  119705. export class LatheBuilder {
  119706. /**
  119707. * Creates lathe mesh.
  119708. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119709. * * 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
  119710. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119711. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119712. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119713. * * 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
  119714. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119715. * * 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
  119716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119720. * @param name defines the name of the mesh
  119721. * @param options defines the options used to create the mesh
  119722. * @param scene defines the hosting scene
  119723. * @returns the lathe mesh
  119724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119725. */
  119726. static CreateLathe(name: string, options: {
  119727. shape: Vector3[];
  119728. radius?: number;
  119729. tessellation?: number;
  119730. clip?: number;
  119731. arc?: number;
  119732. closed?: boolean;
  119733. updatable?: boolean;
  119734. sideOrientation?: number;
  119735. frontUVs?: Vector4;
  119736. backUVs?: Vector4;
  119737. cap?: number;
  119738. invertUV?: boolean;
  119739. }, scene?: Nullable<Scene>): Mesh;
  119740. }
  119741. }
  119742. declare module BABYLON {
  119743. /**
  119744. * Class containing static functions to help procedurally build meshes
  119745. */
  119746. export class TiledPlaneBuilder {
  119747. /**
  119748. * Creates a tiled plane mesh
  119749. * * The parameter `pattern` will, depending on value, do nothing or
  119750. * * * flip (reflect about central vertical) alternate tiles across and up
  119751. * * * flip every tile on alternate rows
  119752. * * * rotate (180 degs) alternate tiles across and up
  119753. * * * rotate every tile on alternate rows
  119754. * * * flip and rotate alternate tiles across and up
  119755. * * * flip and rotate every tile on alternate rows
  119756. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  119757. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  119758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119760. * * 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)
  119761. * * 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)
  119762. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119763. * @param name defines the name of the mesh
  119764. * @param options defines the options used to create the mesh
  119765. * @param scene defines the hosting scene
  119766. * @returns the box mesh
  119767. */
  119768. static CreateTiledPlane(name: string, options: {
  119769. pattern?: number;
  119770. tileSize?: number;
  119771. tileWidth?: number;
  119772. tileHeight?: number;
  119773. size?: number;
  119774. width?: number;
  119775. height?: number;
  119776. alignHorizontal?: number;
  119777. alignVertical?: number;
  119778. sideOrientation?: number;
  119779. frontUVs?: Vector4;
  119780. backUVs?: Vector4;
  119781. updatable?: boolean;
  119782. }, scene?: Nullable<Scene>): Mesh;
  119783. }
  119784. }
  119785. declare module BABYLON {
  119786. /**
  119787. * Class containing static functions to help procedurally build meshes
  119788. */
  119789. export class TubeBuilder {
  119790. /**
  119791. * Creates a tube mesh.
  119792. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119793. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119794. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119795. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119796. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119797. * * 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)
  119798. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119799. * * 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
  119800. * * 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
  119801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119805. * @param name defines the name of the mesh
  119806. * @param options defines the options used to create the mesh
  119807. * @param scene defines the hosting scene
  119808. * @returns the tube mesh
  119809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119810. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119811. */
  119812. static CreateTube(name: string, options: {
  119813. path: Vector3[];
  119814. radius?: number;
  119815. tessellation?: number;
  119816. radiusFunction?: {
  119817. (i: number, distance: number): number;
  119818. };
  119819. cap?: number;
  119820. arc?: number;
  119821. updatable?: boolean;
  119822. sideOrientation?: number;
  119823. frontUVs?: Vector4;
  119824. backUVs?: Vector4;
  119825. instance?: Mesh;
  119826. invertUV?: boolean;
  119827. }, scene?: Nullable<Scene>): Mesh;
  119828. }
  119829. }
  119830. declare module BABYLON {
  119831. /**
  119832. * Class containing static functions to help procedurally build meshes
  119833. */
  119834. export class IcoSphereBuilder {
  119835. /**
  119836. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119837. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119838. * * 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`)
  119839. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119840. * * 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
  119841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119844. * @param name defines the name of the mesh
  119845. * @param options defines the options used to create the mesh
  119846. * @param scene defines the hosting scene
  119847. * @returns the icosahedron mesh
  119848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119849. */
  119850. static CreateIcoSphere(name: string, options: {
  119851. radius?: number;
  119852. radiusX?: number;
  119853. radiusY?: number;
  119854. radiusZ?: number;
  119855. flat?: boolean;
  119856. subdivisions?: number;
  119857. sideOrientation?: number;
  119858. frontUVs?: Vector4;
  119859. backUVs?: Vector4;
  119860. updatable?: boolean;
  119861. }, scene?: Nullable<Scene>): Mesh;
  119862. }
  119863. }
  119864. declare module BABYLON {
  119865. /**
  119866. * Class containing static functions to help procedurally build meshes
  119867. */
  119868. export class DecalBuilder {
  119869. /**
  119870. * Creates a decal mesh.
  119871. * 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
  119872. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119873. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119874. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119875. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119876. * @param name defines the name of the mesh
  119877. * @param sourceMesh defines the mesh where the decal must be applied
  119878. * @param options defines the options used to create the mesh
  119879. * @param scene defines the hosting scene
  119880. * @returns the decal mesh
  119881. * @see https://doc.babylonjs.com/how_to/decals
  119882. */
  119883. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119884. position?: Vector3;
  119885. normal?: Vector3;
  119886. size?: Vector3;
  119887. angle?: number;
  119888. }): Mesh;
  119889. }
  119890. }
  119891. declare module BABYLON {
  119892. /**
  119893. * Class containing static functions to help procedurally build meshes
  119894. */
  119895. export class MeshBuilder {
  119896. /**
  119897. * Creates a box mesh
  119898. * * The parameter `size` sets the size (float) of each box side (default 1)
  119899. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119900. * * 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)
  119901. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119905. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119906. * @param name defines the name of the mesh
  119907. * @param options defines the options used to create the mesh
  119908. * @param scene defines the hosting scene
  119909. * @returns the box mesh
  119910. */
  119911. static CreateBox(name: string, options: {
  119912. size?: number;
  119913. width?: number;
  119914. height?: number;
  119915. depth?: number;
  119916. faceUV?: Vector4[];
  119917. faceColors?: Color4[];
  119918. sideOrientation?: number;
  119919. frontUVs?: Vector4;
  119920. backUVs?: Vector4;
  119921. updatable?: boolean;
  119922. }, scene?: Nullable<Scene>): Mesh;
  119923. /**
  119924. * Creates a tiled box mesh
  119925. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119927. * @param name defines the name of the mesh
  119928. * @param options defines the options used to create the mesh
  119929. * @param scene defines the hosting scene
  119930. * @returns the tiled box mesh
  119931. */
  119932. static CreateTiledBox(name: string, options: {
  119933. pattern?: number;
  119934. size?: number;
  119935. width?: number;
  119936. height?: number;
  119937. depth: number;
  119938. tileSize?: number;
  119939. tileWidth?: number;
  119940. tileHeight?: number;
  119941. faceUV?: Vector4[];
  119942. faceColors?: Color4[];
  119943. alignHorizontal?: number;
  119944. alignVertical?: number;
  119945. sideOrientation?: number;
  119946. updatable?: boolean;
  119947. }, scene?: Nullable<Scene>): Mesh;
  119948. /**
  119949. * Creates a sphere mesh
  119950. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119951. * * 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`)
  119952. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119953. * * 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
  119954. * * 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)
  119955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119958. * @param name defines the name of the mesh
  119959. * @param options defines the options used to create the mesh
  119960. * @param scene defines the hosting scene
  119961. * @returns the sphere mesh
  119962. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119963. */
  119964. static CreateSphere(name: string, options: {
  119965. segments?: number;
  119966. diameter?: number;
  119967. diameterX?: number;
  119968. diameterY?: number;
  119969. diameterZ?: number;
  119970. arc?: number;
  119971. slice?: number;
  119972. sideOrientation?: number;
  119973. frontUVs?: Vector4;
  119974. backUVs?: Vector4;
  119975. updatable?: boolean;
  119976. }, scene?: Nullable<Scene>): Mesh;
  119977. /**
  119978. * Creates a plane polygonal mesh. By default, this is a disc
  119979. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119980. * * 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
  119981. * * 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
  119982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119985. * @param name defines the name of the mesh
  119986. * @param options defines the options used to create the mesh
  119987. * @param scene defines the hosting scene
  119988. * @returns the plane polygonal mesh
  119989. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119990. */
  119991. static CreateDisc(name: string, options: {
  119992. radius?: number;
  119993. tessellation?: number;
  119994. arc?: number;
  119995. updatable?: boolean;
  119996. sideOrientation?: number;
  119997. frontUVs?: Vector4;
  119998. backUVs?: Vector4;
  119999. }, scene?: Nullable<Scene>): Mesh;
  120000. /**
  120001. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  120002. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  120003. * * 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`)
  120004. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  120005. * * 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
  120006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120009. * @param name defines the name of the mesh
  120010. * @param options defines the options used to create the mesh
  120011. * @param scene defines the hosting scene
  120012. * @returns the icosahedron mesh
  120013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  120014. */
  120015. static CreateIcoSphere(name: string, options: {
  120016. radius?: number;
  120017. radiusX?: number;
  120018. radiusY?: number;
  120019. radiusZ?: number;
  120020. flat?: boolean;
  120021. subdivisions?: number;
  120022. sideOrientation?: number;
  120023. frontUVs?: Vector4;
  120024. backUVs?: Vector4;
  120025. updatable?: boolean;
  120026. }, scene?: Nullable<Scene>): Mesh;
  120027. /**
  120028. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120029. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120030. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120031. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120032. * * 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
  120033. * * 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
  120034. * * 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
  120035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120037. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120038. * * 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
  120039. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120040. * * 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
  120041. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120043. * @param name defines the name of the mesh
  120044. * @param options defines the options used to create the mesh
  120045. * @param scene defines the hosting scene
  120046. * @returns the ribbon mesh
  120047. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120049. */
  120050. static CreateRibbon(name: string, options: {
  120051. pathArray: Vector3[][];
  120052. closeArray?: boolean;
  120053. closePath?: boolean;
  120054. offset?: number;
  120055. updatable?: boolean;
  120056. sideOrientation?: number;
  120057. frontUVs?: Vector4;
  120058. backUVs?: Vector4;
  120059. instance?: Mesh;
  120060. invertUV?: boolean;
  120061. uvs?: Vector2[];
  120062. colors?: Color4[];
  120063. }, scene?: Nullable<Scene>): Mesh;
  120064. /**
  120065. * Creates a cylinder or a cone mesh
  120066. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  120067. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  120068. * * 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.
  120069. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  120070. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  120071. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  120072. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  120073. * * 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).
  120074. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  120075. * * 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).
  120076. * * 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
  120077. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  120078. * * 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
  120079. * * 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.
  120080. * * If `enclose` is false, a ring surface is one element.
  120081. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  120082. * * 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
  120083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120086. * @param name defines the name of the mesh
  120087. * @param options defines the options used to create the mesh
  120088. * @param scene defines the hosting scene
  120089. * @returns the cylinder mesh
  120090. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  120091. */
  120092. static CreateCylinder(name: string, options: {
  120093. height?: number;
  120094. diameterTop?: number;
  120095. diameterBottom?: number;
  120096. diameter?: number;
  120097. tessellation?: number;
  120098. subdivisions?: number;
  120099. arc?: number;
  120100. faceColors?: Color4[];
  120101. faceUV?: Vector4[];
  120102. updatable?: boolean;
  120103. hasRings?: boolean;
  120104. enclose?: boolean;
  120105. cap?: number;
  120106. sideOrientation?: number;
  120107. frontUVs?: Vector4;
  120108. backUVs?: Vector4;
  120109. }, scene?: Nullable<Scene>): Mesh;
  120110. /**
  120111. * Creates a torus mesh
  120112. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  120113. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  120114. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  120115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120118. * @param name defines the name of the mesh
  120119. * @param options defines the options used to create the mesh
  120120. * @param scene defines the hosting scene
  120121. * @returns the torus mesh
  120122. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  120123. */
  120124. static CreateTorus(name: string, options: {
  120125. diameter?: number;
  120126. thickness?: number;
  120127. tessellation?: number;
  120128. updatable?: boolean;
  120129. sideOrientation?: number;
  120130. frontUVs?: Vector4;
  120131. backUVs?: Vector4;
  120132. }, scene?: Nullable<Scene>): Mesh;
  120133. /**
  120134. * Creates a torus knot mesh
  120135. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120136. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120137. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120138. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120142. * @param name defines the name of the mesh
  120143. * @param options defines the options used to create the mesh
  120144. * @param scene defines the hosting scene
  120145. * @returns the torus knot mesh
  120146. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120147. */
  120148. static CreateTorusKnot(name: string, options: {
  120149. radius?: number;
  120150. tube?: number;
  120151. radialSegments?: number;
  120152. tubularSegments?: number;
  120153. p?: number;
  120154. q?: number;
  120155. updatable?: boolean;
  120156. sideOrientation?: number;
  120157. frontUVs?: Vector4;
  120158. backUVs?: Vector4;
  120159. }, scene?: Nullable<Scene>): Mesh;
  120160. /**
  120161. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  120162. * * 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
  120163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  120164. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  120165. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  120166. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  120167. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  120168. * * 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
  120169. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  120170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  120172. * @param name defines the name of the new line system
  120173. * @param options defines the options used to create the line system
  120174. * @param scene defines the hosting scene
  120175. * @returns a new line system mesh
  120176. */
  120177. static CreateLineSystem(name: string, options: {
  120178. lines: Vector3[][];
  120179. updatable?: boolean;
  120180. instance?: Nullable<LinesMesh>;
  120181. colors?: Nullable<Color4[][]>;
  120182. useVertexAlpha?: boolean;
  120183. }, scene: Nullable<Scene>): LinesMesh;
  120184. /**
  120185. * Creates a line mesh
  120186. * 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
  120187. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120188. * * The parameter `points` is an array successive Vector3
  120189. * * 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
  120190. * * The optional parameter `colors` is an array of successive Color4, one per line point
  120191. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  120192. * * When updating an instance, remember that only point positions can change, not the number of points
  120193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  120195. * @param name defines the name of the new line system
  120196. * @param options defines the options used to create the line system
  120197. * @param scene defines the hosting scene
  120198. * @returns a new line mesh
  120199. */
  120200. static CreateLines(name: string, options: {
  120201. points: Vector3[];
  120202. updatable?: boolean;
  120203. instance?: Nullable<LinesMesh>;
  120204. colors?: Color4[];
  120205. useVertexAlpha?: boolean;
  120206. }, scene?: Nullable<Scene>): LinesMesh;
  120207. /**
  120208. * Creates a dashed line mesh
  120209. * * 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
  120210. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120211. * * The parameter `points` is an array successive Vector3
  120212. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  120213. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  120214. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  120215. * * 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
  120216. * * When updating an instance, remember that only point positions can change, not the number of points
  120217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120218. * @param name defines the name of the mesh
  120219. * @param options defines the options used to create the mesh
  120220. * @param scene defines the hosting scene
  120221. * @returns the dashed line mesh
  120222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  120223. */
  120224. static CreateDashedLines(name: string, options: {
  120225. points: Vector3[];
  120226. dashSize?: number;
  120227. gapSize?: number;
  120228. dashNb?: number;
  120229. updatable?: boolean;
  120230. instance?: LinesMesh;
  120231. }, scene?: Nullable<Scene>): LinesMesh;
  120232. /**
  120233. * 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.
  120234. * * 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.
  120235. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120236. * * 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.
  120237. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120238. * * 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
  120239. * * 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
  120240. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120245. * @param name defines the name of the mesh
  120246. * @param options defines the options used to create the mesh
  120247. * @param scene defines the hosting scene
  120248. * @returns the extruded shape mesh
  120249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120251. */
  120252. static ExtrudeShape(name: string, options: {
  120253. shape: Vector3[];
  120254. path: Vector3[];
  120255. scale?: number;
  120256. rotation?: number;
  120257. cap?: number;
  120258. updatable?: boolean;
  120259. sideOrientation?: number;
  120260. frontUVs?: Vector4;
  120261. backUVs?: Vector4;
  120262. instance?: Mesh;
  120263. invertUV?: boolean;
  120264. }, scene?: Nullable<Scene>): Mesh;
  120265. /**
  120266. * Creates an custom extruded shape mesh.
  120267. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120268. * * 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.
  120269. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120270. * * 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
  120271. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120272. * * 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
  120273. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120274. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120275. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120276. * * 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
  120277. * * 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
  120278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120283. * @param name defines the name of the mesh
  120284. * @param options defines the options used to create the mesh
  120285. * @param scene defines the hosting scene
  120286. * @returns the custom extruded shape mesh
  120287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120290. */
  120291. static ExtrudeShapeCustom(name: string, options: {
  120292. shape: Vector3[];
  120293. path: Vector3[];
  120294. scaleFunction?: any;
  120295. rotationFunction?: any;
  120296. ribbonCloseArray?: boolean;
  120297. ribbonClosePath?: boolean;
  120298. cap?: number;
  120299. updatable?: boolean;
  120300. sideOrientation?: number;
  120301. frontUVs?: Vector4;
  120302. backUVs?: Vector4;
  120303. instance?: Mesh;
  120304. invertUV?: boolean;
  120305. }, scene?: Nullable<Scene>): Mesh;
  120306. /**
  120307. * Creates lathe mesh.
  120308. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120309. * * 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
  120310. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120311. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120312. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120313. * * 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
  120314. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120315. * * 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
  120316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120320. * @param name defines the name of the mesh
  120321. * @param options defines the options used to create the mesh
  120322. * @param scene defines the hosting scene
  120323. * @returns the lathe mesh
  120324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120325. */
  120326. static CreateLathe(name: string, options: {
  120327. shape: Vector3[];
  120328. radius?: number;
  120329. tessellation?: number;
  120330. clip?: number;
  120331. arc?: number;
  120332. closed?: boolean;
  120333. updatable?: boolean;
  120334. sideOrientation?: number;
  120335. frontUVs?: Vector4;
  120336. backUVs?: Vector4;
  120337. cap?: number;
  120338. invertUV?: boolean;
  120339. }, scene?: Nullable<Scene>): Mesh;
  120340. /**
  120341. * Creates a tiled plane mesh
  120342. * * You can set a limited pattern arrangement with the tiles
  120343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120346. * @param name defines the name of the mesh
  120347. * @param options defines the options used to create the mesh
  120348. * @param scene defines the hosting scene
  120349. * @returns the plane mesh
  120350. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120351. */
  120352. static CreateTiledPlane(name: string, options: {
  120353. pattern?: number;
  120354. tileSize?: number;
  120355. tileWidth?: number;
  120356. tileHeight?: number;
  120357. size?: number;
  120358. width?: number;
  120359. height?: number;
  120360. alignHorizontal?: number;
  120361. alignVertical?: number;
  120362. sideOrientation?: number;
  120363. frontUVs?: Vector4;
  120364. backUVs?: Vector4;
  120365. updatable?: boolean;
  120366. }, scene?: Nullable<Scene>): Mesh;
  120367. /**
  120368. * Creates a plane mesh
  120369. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120370. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120371. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120375. * @param name defines the name of the mesh
  120376. * @param options defines the options used to create the mesh
  120377. * @param scene defines the hosting scene
  120378. * @returns the plane mesh
  120379. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120380. */
  120381. static CreatePlane(name: string, options: {
  120382. size?: number;
  120383. width?: number;
  120384. height?: number;
  120385. sideOrientation?: number;
  120386. frontUVs?: Vector4;
  120387. backUVs?: Vector4;
  120388. updatable?: boolean;
  120389. sourcePlane?: Plane;
  120390. }, scene?: Nullable<Scene>): Mesh;
  120391. /**
  120392. * Creates a ground mesh
  120393. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  120394. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  120395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120396. * @param name defines the name of the mesh
  120397. * @param options defines the options used to create the mesh
  120398. * @param scene defines the hosting scene
  120399. * @returns the ground mesh
  120400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  120401. */
  120402. static CreateGround(name: string, options: {
  120403. width?: number;
  120404. height?: number;
  120405. subdivisions?: number;
  120406. subdivisionsX?: number;
  120407. subdivisionsY?: number;
  120408. updatable?: boolean;
  120409. }, scene?: Nullable<Scene>): Mesh;
  120410. /**
  120411. * Creates a tiled ground mesh
  120412. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  120413. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  120414. * * 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
  120415. * * 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
  120416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120417. * @param name defines the name of the mesh
  120418. * @param options defines the options used to create the mesh
  120419. * @param scene defines the hosting scene
  120420. * @returns the tiled ground mesh
  120421. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  120422. */
  120423. static CreateTiledGround(name: string, options: {
  120424. xmin: number;
  120425. zmin: number;
  120426. xmax: number;
  120427. zmax: number;
  120428. subdivisions?: {
  120429. w: number;
  120430. h: number;
  120431. };
  120432. precision?: {
  120433. w: number;
  120434. h: number;
  120435. };
  120436. updatable?: boolean;
  120437. }, scene?: Nullable<Scene>): Mesh;
  120438. /**
  120439. * Creates a ground mesh from a height map
  120440. * * The parameter `url` sets the URL of the height map image resource.
  120441. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  120442. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  120443. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  120444. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  120445. * * 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.
  120446. * * 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).
  120447. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  120448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120449. * @param name defines the name of the mesh
  120450. * @param url defines the url to the height map
  120451. * @param options defines the options used to create the mesh
  120452. * @param scene defines the hosting scene
  120453. * @returns the ground mesh
  120454. * @see https://doc.babylonjs.com/babylon101/height_map
  120455. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  120456. */
  120457. static CreateGroundFromHeightMap(name: string, url: string, options: {
  120458. width?: number;
  120459. height?: number;
  120460. subdivisions?: number;
  120461. minHeight?: number;
  120462. maxHeight?: number;
  120463. colorFilter?: Color3;
  120464. alphaFilter?: number;
  120465. updatable?: boolean;
  120466. onReady?: (mesh: GroundMesh) => void;
  120467. }, scene?: Nullable<Scene>): GroundMesh;
  120468. /**
  120469. * Creates a polygon mesh
  120470. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120471. * * 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
  120472. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120475. * * Remember you can only change the shape positions, not their number when updating a polygon
  120476. * @param name defines the name of the mesh
  120477. * @param options defines the options used to create the mesh
  120478. * @param scene defines the hosting scene
  120479. * @param earcutInjection can be used to inject your own earcut reference
  120480. * @returns the polygon mesh
  120481. */
  120482. static CreatePolygon(name: string, options: {
  120483. shape: Vector3[];
  120484. holes?: Vector3[][];
  120485. depth?: number;
  120486. faceUV?: Vector4[];
  120487. faceColors?: Color4[];
  120488. updatable?: boolean;
  120489. sideOrientation?: number;
  120490. frontUVs?: Vector4;
  120491. backUVs?: Vector4;
  120492. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120493. /**
  120494. * Creates an extruded polygon mesh, with depth in the Y direction.
  120495. * * 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)
  120496. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120497. * @param name defines the name of the mesh
  120498. * @param options defines the options used to create the mesh
  120499. * @param scene defines the hosting scene
  120500. * @param earcutInjection can be used to inject your own earcut reference
  120501. * @returns the polygon mesh
  120502. */
  120503. static ExtrudePolygon(name: string, options: {
  120504. shape: Vector3[];
  120505. holes?: Vector3[][];
  120506. depth?: number;
  120507. faceUV?: Vector4[];
  120508. faceColors?: Color4[];
  120509. updatable?: boolean;
  120510. sideOrientation?: number;
  120511. frontUVs?: Vector4;
  120512. backUVs?: Vector4;
  120513. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120514. /**
  120515. * Creates a tube mesh.
  120516. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120517. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120518. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120519. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120520. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120521. * * 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)
  120522. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120523. * * 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
  120524. * * 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
  120525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120527. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120529. * @param name defines the name of the mesh
  120530. * @param options defines the options used to create the mesh
  120531. * @param scene defines the hosting scene
  120532. * @returns the tube mesh
  120533. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120534. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120535. */
  120536. static CreateTube(name: string, options: {
  120537. path: Vector3[];
  120538. radius?: number;
  120539. tessellation?: number;
  120540. radiusFunction?: {
  120541. (i: number, distance: number): number;
  120542. };
  120543. cap?: number;
  120544. arc?: number;
  120545. updatable?: boolean;
  120546. sideOrientation?: number;
  120547. frontUVs?: Vector4;
  120548. backUVs?: Vector4;
  120549. instance?: Mesh;
  120550. invertUV?: boolean;
  120551. }, scene?: Nullable<Scene>): Mesh;
  120552. /**
  120553. * Creates a polyhedron mesh
  120554. * * 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
  120555. * * The parameter `size` (positive float, default 1) sets the polygon size
  120556. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120557. * * 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`
  120558. * * 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
  120559. * * 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)`)
  120560. * * 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
  120561. * * 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
  120562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120565. * @param name defines the name of the mesh
  120566. * @param options defines the options used to create the mesh
  120567. * @param scene defines the hosting scene
  120568. * @returns the polyhedron mesh
  120569. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120570. */
  120571. static CreatePolyhedron(name: string, options: {
  120572. type?: number;
  120573. size?: number;
  120574. sizeX?: number;
  120575. sizeY?: number;
  120576. sizeZ?: number;
  120577. custom?: any;
  120578. faceUV?: Vector4[];
  120579. faceColors?: Color4[];
  120580. flat?: boolean;
  120581. updatable?: boolean;
  120582. sideOrientation?: number;
  120583. frontUVs?: Vector4;
  120584. backUVs?: Vector4;
  120585. }, scene?: Nullable<Scene>): Mesh;
  120586. /**
  120587. * Creates a decal mesh.
  120588. * 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
  120589. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120590. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120591. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120592. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120593. * @param name defines the name of the mesh
  120594. * @param sourceMesh defines the mesh where the decal must be applied
  120595. * @param options defines the options used to create the mesh
  120596. * @param scene defines the hosting scene
  120597. * @returns the decal mesh
  120598. * @see https://doc.babylonjs.com/how_to/decals
  120599. */
  120600. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120601. position?: Vector3;
  120602. normal?: Vector3;
  120603. size?: Vector3;
  120604. angle?: number;
  120605. }): Mesh;
  120606. }
  120607. }
  120608. declare module BABYLON {
  120609. /**
  120610. * A simplifier interface for future simplification implementations
  120611. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120612. */
  120613. export interface ISimplifier {
  120614. /**
  120615. * Simplification of a given mesh according to the given settings.
  120616. * Since this requires computation, it is assumed that the function runs async.
  120617. * @param settings The settings of the simplification, including quality and distance
  120618. * @param successCallback A callback that will be called after the mesh was simplified.
  120619. * @param errorCallback in case of an error, this callback will be called. optional.
  120620. */
  120621. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  120622. }
  120623. /**
  120624. * Expected simplification settings.
  120625. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  120626. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120627. */
  120628. export interface ISimplificationSettings {
  120629. /**
  120630. * Gets or sets the expected quality
  120631. */
  120632. quality: number;
  120633. /**
  120634. * Gets or sets the distance when this optimized version should be used
  120635. */
  120636. distance: number;
  120637. /**
  120638. * Gets an already optimized mesh
  120639. */
  120640. optimizeMesh?: boolean;
  120641. }
  120642. /**
  120643. * Class used to specify simplification options
  120644. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120645. */
  120646. export class SimplificationSettings implements ISimplificationSettings {
  120647. /** expected quality */
  120648. quality: number;
  120649. /** distance when this optimized version should be used */
  120650. distance: number;
  120651. /** already optimized mesh */
  120652. optimizeMesh?: boolean | undefined;
  120653. /**
  120654. * Creates a SimplificationSettings
  120655. * @param quality expected quality
  120656. * @param distance distance when this optimized version should be used
  120657. * @param optimizeMesh already optimized mesh
  120658. */
  120659. constructor(
  120660. /** expected quality */
  120661. quality: number,
  120662. /** distance when this optimized version should be used */
  120663. distance: number,
  120664. /** already optimized mesh */
  120665. optimizeMesh?: boolean | undefined);
  120666. }
  120667. /**
  120668. * Interface used to define a simplification task
  120669. */
  120670. export interface ISimplificationTask {
  120671. /**
  120672. * Array of settings
  120673. */
  120674. settings: Array<ISimplificationSettings>;
  120675. /**
  120676. * Simplification type
  120677. */
  120678. simplificationType: SimplificationType;
  120679. /**
  120680. * Mesh to simplify
  120681. */
  120682. mesh: Mesh;
  120683. /**
  120684. * Callback called on success
  120685. */
  120686. successCallback?: () => void;
  120687. /**
  120688. * Defines if parallel processing can be used
  120689. */
  120690. parallelProcessing: boolean;
  120691. }
  120692. /**
  120693. * Queue used to order the simplification tasks
  120694. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120695. */
  120696. export class SimplificationQueue {
  120697. private _simplificationArray;
  120698. /**
  120699. * Gets a boolean indicating that the process is still running
  120700. */
  120701. running: boolean;
  120702. /**
  120703. * Creates a new queue
  120704. */
  120705. constructor();
  120706. /**
  120707. * Adds a new simplification task
  120708. * @param task defines a task to add
  120709. */
  120710. addTask(task: ISimplificationTask): void;
  120711. /**
  120712. * Execute next task
  120713. */
  120714. executeNext(): void;
  120715. /**
  120716. * Execute a simplification task
  120717. * @param task defines the task to run
  120718. */
  120719. runSimplification(task: ISimplificationTask): void;
  120720. private getSimplifier;
  120721. }
  120722. /**
  120723. * The implemented types of simplification
  120724. * At the moment only Quadratic Error Decimation is implemented
  120725. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120726. */
  120727. export enum SimplificationType {
  120728. /** Quadratic error decimation */
  120729. QUADRATIC = 0
  120730. }
  120731. }
  120732. declare module BABYLON {
  120733. interface Scene {
  120734. /** @hidden (Backing field) */
  120735. _simplificationQueue: SimplificationQueue;
  120736. /**
  120737. * Gets or sets the simplification queue attached to the scene
  120738. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120739. */
  120740. simplificationQueue: SimplificationQueue;
  120741. }
  120742. interface Mesh {
  120743. /**
  120744. * Simplify the mesh according to the given array of settings.
  120745. * Function will return immediately and will simplify async
  120746. * @param settings a collection of simplification settings
  120747. * @param parallelProcessing should all levels calculate parallel or one after the other
  120748. * @param simplificationType the type of simplification to run
  120749. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  120750. * @returns the current mesh
  120751. */
  120752. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  120753. }
  120754. /**
  120755. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  120756. * created in a scene
  120757. */
  120758. export class SimplicationQueueSceneComponent implements ISceneComponent {
  120759. /**
  120760. * The component name helpfull to identify the component in the list of scene components.
  120761. */
  120762. readonly name: string;
  120763. /**
  120764. * The scene the component belongs to.
  120765. */
  120766. scene: Scene;
  120767. /**
  120768. * Creates a new instance of the component for the given scene
  120769. * @param scene Defines the scene to register the component in
  120770. */
  120771. constructor(scene: Scene);
  120772. /**
  120773. * Registers the component in a given scene
  120774. */
  120775. register(): void;
  120776. /**
  120777. * Rebuilds the elements related to this component in case of
  120778. * context lost for instance.
  120779. */
  120780. rebuild(): void;
  120781. /**
  120782. * Disposes the component and the associated ressources
  120783. */
  120784. dispose(): void;
  120785. private _beforeCameraUpdate;
  120786. }
  120787. }
  120788. declare module BABYLON {
  120789. /**
  120790. * Navigation plugin interface to add navigation constrained by a navigation mesh
  120791. */
  120792. export interface INavigationEnginePlugin {
  120793. /**
  120794. * plugin name
  120795. */
  120796. name: string;
  120797. /**
  120798. * Creates a navigation mesh
  120799. * @param meshes array of all the geometry used to compute the navigatio mesh
  120800. * @param parameters bunch of parameters used to filter geometry
  120801. */
  120802. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120803. /**
  120804. * Create a navigation mesh debug mesh
  120805. * @param scene is where the mesh will be added
  120806. * @returns debug display mesh
  120807. */
  120808. createDebugNavMesh(scene: Scene): Mesh;
  120809. /**
  120810. * Get a navigation mesh constrained position, closest to the parameter position
  120811. * @param position world position
  120812. * @returns the closest point to position constrained by the navigation mesh
  120813. */
  120814. getClosestPoint(position: Vector3): Vector3;
  120815. /**
  120816. * Get a navigation mesh constrained position, within a particular radius
  120817. * @param position world position
  120818. * @param maxRadius the maximum distance to the constrained world position
  120819. * @returns the closest point to position constrained by the navigation mesh
  120820. */
  120821. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120822. /**
  120823. * Compute the final position from a segment made of destination-position
  120824. * @param position world position
  120825. * @param destination world position
  120826. * @returns the resulting point along the navmesh
  120827. */
  120828. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120829. /**
  120830. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120831. * @param start world position
  120832. * @param end world position
  120833. * @returns array containing world position composing the path
  120834. */
  120835. computePath(start: Vector3, end: Vector3): Vector3[];
  120836. /**
  120837. * If this plugin is supported
  120838. * @returns true if plugin is supported
  120839. */
  120840. isSupported(): boolean;
  120841. /**
  120842. * Create a new Crowd so you can add agents
  120843. * @param maxAgents the maximum agent count in the crowd
  120844. * @param maxAgentRadius the maximum radius an agent can have
  120845. * @param scene to attach the crowd to
  120846. * @returns the crowd you can add agents to
  120847. */
  120848. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120849. /**
  120850. * Release all resources
  120851. */
  120852. dispose(): void;
  120853. }
  120854. /**
  120855. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  120856. */
  120857. export interface ICrowd {
  120858. /**
  120859. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120860. * You can attach anything to that node. The node position is updated in the scene update tick.
  120861. * @param pos world position that will be constrained by the navigation mesh
  120862. * @param parameters agent parameters
  120863. * @param transform hooked to the agent that will be update by the scene
  120864. * @returns agent index
  120865. */
  120866. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120867. /**
  120868. * Returns the agent position in world space
  120869. * @param index agent index returned by addAgent
  120870. * @returns world space position
  120871. */
  120872. getAgentPosition(index: number): Vector3;
  120873. /**
  120874. * Gets the agent velocity in world space
  120875. * @param index agent index returned by addAgent
  120876. * @returns world space velocity
  120877. */
  120878. getAgentVelocity(index: number): Vector3;
  120879. /**
  120880. * remove a particular agent previously created
  120881. * @param index agent index returned by addAgent
  120882. */
  120883. removeAgent(index: number): void;
  120884. /**
  120885. * get the list of all agents attached to this crowd
  120886. * @returns list of agent indices
  120887. */
  120888. getAgents(): number[];
  120889. /**
  120890. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120891. * @param deltaTime in seconds
  120892. */
  120893. update(deltaTime: number): void;
  120894. /**
  120895. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120896. * @param index agent index returned by addAgent
  120897. * @param destination targeted world position
  120898. */
  120899. agentGoto(index: number, destination: Vector3): void;
  120900. /**
  120901. * Release all resources
  120902. */
  120903. dispose(): void;
  120904. }
  120905. /**
  120906. * Configures an agent
  120907. */
  120908. export interface IAgentParameters {
  120909. /**
  120910. * Agent radius. [Limit: >= 0]
  120911. */
  120912. radius: number;
  120913. /**
  120914. * Agent height. [Limit: > 0]
  120915. */
  120916. height: number;
  120917. /**
  120918. * Maximum allowed acceleration. [Limit: >= 0]
  120919. */
  120920. maxAcceleration: number;
  120921. /**
  120922. * Maximum allowed speed. [Limit: >= 0]
  120923. */
  120924. maxSpeed: number;
  120925. /**
  120926. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  120927. */
  120928. collisionQueryRange: number;
  120929. /**
  120930. * The path visibility optimization range. [Limit: > 0]
  120931. */
  120932. pathOptimizationRange: number;
  120933. /**
  120934. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  120935. */
  120936. separationWeight: number;
  120937. }
  120938. /**
  120939. * Configures the navigation mesh creation
  120940. */
  120941. export interface INavMeshParameters {
  120942. /**
  120943. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  120944. */
  120945. cs: number;
  120946. /**
  120947. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  120948. */
  120949. ch: number;
  120950. /**
  120951. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  120952. */
  120953. walkableSlopeAngle: number;
  120954. /**
  120955. * Minimum floor to 'ceiling' height that will still allow the floor area to
  120956. * be considered walkable. [Limit: >= 3] [Units: vx]
  120957. */
  120958. walkableHeight: number;
  120959. /**
  120960. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  120961. */
  120962. walkableClimb: number;
  120963. /**
  120964. * The distance to erode/shrink the walkable area of the heightfield away from
  120965. * obstructions. [Limit: >=0] [Units: vx]
  120966. */
  120967. walkableRadius: number;
  120968. /**
  120969. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  120970. */
  120971. maxEdgeLen: number;
  120972. /**
  120973. * The maximum distance a simplfied contour's border edges should deviate
  120974. * the original raw contour. [Limit: >=0] [Units: vx]
  120975. */
  120976. maxSimplificationError: number;
  120977. /**
  120978. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  120979. */
  120980. minRegionArea: number;
  120981. /**
  120982. * Any regions with a span count smaller than this value will, if possible,
  120983. * be merged with larger regions. [Limit: >=0] [Units: vx]
  120984. */
  120985. mergeRegionArea: number;
  120986. /**
  120987. * The maximum number of vertices allowed for polygons generated during the
  120988. * contour to polygon conversion process. [Limit: >= 3]
  120989. */
  120990. maxVertsPerPoly: number;
  120991. /**
  120992. * Sets the sampling distance to use when generating the detail mesh.
  120993. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120994. */
  120995. detailSampleDist: number;
  120996. /**
  120997. * The maximum distance the detail mesh surface should deviate from heightfield
  120998. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120999. */
  121000. detailSampleMaxError: number;
  121001. }
  121002. }
  121003. declare module BABYLON {
  121004. /**
  121005. * RecastJS navigation plugin
  121006. */
  121007. export class RecastJSPlugin implements INavigationEnginePlugin {
  121008. /**
  121009. * Reference to the Recast library
  121010. */
  121011. bjsRECAST: any;
  121012. /**
  121013. * plugin name
  121014. */
  121015. name: string;
  121016. /**
  121017. * the first navmesh created. We might extend this to support multiple navmeshes
  121018. */
  121019. navMesh: any;
  121020. /**
  121021. * Initializes the recastJS plugin
  121022. * @param recastInjection can be used to inject your own recast reference
  121023. */
  121024. constructor(recastInjection?: any);
  121025. /**
  121026. * Creates a navigation mesh
  121027. * @param meshes array of all the geometry used to compute the navigatio mesh
  121028. * @param parameters bunch of parameters used to filter geometry
  121029. */
  121030. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  121031. /**
  121032. * Create a navigation mesh debug mesh
  121033. * @param scene is where the mesh will be added
  121034. * @returns debug display mesh
  121035. */
  121036. createDebugNavMesh(scene: Scene): Mesh;
  121037. /**
  121038. * Get a navigation mesh constrained position, closest to the parameter position
  121039. * @param position world position
  121040. * @returns the closest point to position constrained by the navigation mesh
  121041. */
  121042. getClosestPoint(position: Vector3): Vector3;
  121043. /**
  121044. * Get a navigation mesh constrained position, within a particular radius
  121045. * @param position world position
  121046. * @param maxRadius the maximum distance to the constrained world position
  121047. * @returns the closest point to position constrained by the navigation mesh
  121048. */
  121049. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  121050. /**
  121051. * Compute the final position from a segment made of destination-position
  121052. * @param position world position
  121053. * @param destination world position
  121054. * @returns the resulting point along the navmesh
  121055. */
  121056. moveAlong(position: Vector3, destination: Vector3): Vector3;
  121057. /**
  121058. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  121059. * @param start world position
  121060. * @param end world position
  121061. * @returns array containing world position composing the path
  121062. */
  121063. computePath(start: Vector3, end: Vector3): Vector3[];
  121064. /**
  121065. * Create a new Crowd so you can add agents
  121066. * @param maxAgents the maximum agent count in the crowd
  121067. * @param maxAgentRadius the maximum radius an agent can have
  121068. * @param scene to attach the crowd to
  121069. * @returns the crowd you can add agents to
  121070. */
  121071. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  121072. /**
  121073. * Disposes
  121074. */
  121075. dispose(): void;
  121076. /**
  121077. * If this plugin is supported
  121078. * @returns true if plugin is supported
  121079. */
  121080. isSupported(): boolean;
  121081. }
  121082. /**
  121083. * Recast detour crowd implementation
  121084. */
  121085. export class RecastJSCrowd implements ICrowd {
  121086. /**
  121087. * Recast/detour plugin
  121088. */
  121089. bjsRECASTPlugin: RecastJSPlugin;
  121090. /**
  121091. * Link to the detour crowd
  121092. */
  121093. recastCrowd: any;
  121094. /**
  121095. * One transform per agent
  121096. */
  121097. transforms: TransformNode[];
  121098. /**
  121099. * All agents created
  121100. */
  121101. agents: number[];
  121102. /**
  121103. * Link to the scene is kept to unregister the crowd from the scene
  121104. */
  121105. private _scene;
  121106. /**
  121107. * Observer for crowd updates
  121108. */
  121109. private _onBeforeAnimationsObserver;
  121110. /**
  121111. * Constructor
  121112. * @param plugin recastJS plugin
  121113. * @param maxAgents the maximum agent count in the crowd
  121114. * @param maxAgentRadius the maximum radius an agent can have
  121115. * @param scene to attach the crowd to
  121116. * @returns the crowd you can add agents to
  121117. */
  121118. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  121119. /**
  121120. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121121. * You can attach anything to that node. The node position is updated in the scene update tick.
  121122. * @param pos world position that will be constrained by the navigation mesh
  121123. * @param parameters agent parameters
  121124. * @param transform hooked to the agent that will be update by the scene
  121125. * @returns agent index
  121126. */
  121127. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121128. /**
  121129. * Returns the agent position in world space
  121130. * @param index agent index returned by addAgent
  121131. * @returns world space position
  121132. */
  121133. getAgentPosition(index: number): Vector3;
  121134. /**
  121135. * Returns the agent velocity in world space
  121136. * @param index agent index returned by addAgent
  121137. * @returns world space velocity
  121138. */
  121139. getAgentVelocity(index: number): Vector3;
  121140. /**
  121141. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121142. * @param index agent index returned by addAgent
  121143. * @param destination targeted world position
  121144. */
  121145. agentGoto(index: number, destination: Vector3): void;
  121146. /**
  121147. * remove a particular agent previously created
  121148. * @param index agent index returned by addAgent
  121149. */
  121150. removeAgent(index: number): void;
  121151. /**
  121152. * get the list of all agents attached to this crowd
  121153. * @returns list of agent indices
  121154. */
  121155. getAgents(): number[];
  121156. /**
  121157. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121158. * @param deltaTime in seconds
  121159. */
  121160. update(deltaTime: number): void;
  121161. /**
  121162. * Release all resources
  121163. */
  121164. dispose(): void;
  121165. }
  121166. }
  121167. declare module BABYLON {
  121168. /**
  121169. * Class used to enable access to IndexedDB
  121170. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  121171. */
  121172. export class Database implements IOfflineProvider {
  121173. private _callbackManifestChecked;
  121174. private _currentSceneUrl;
  121175. private _db;
  121176. private _enableSceneOffline;
  121177. private _enableTexturesOffline;
  121178. private _manifestVersionFound;
  121179. private _mustUpdateRessources;
  121180. private _hasReachedQuota;
  121181. private _isSupported;
  121182. private _idbFactory;
  121183. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  121184. private static IsUASupportingBlobStorage;
  121185. /**
  121186. * Gets a boolean indicating if Database storate is enabled (off by default)
  121187. */
  121188. static IDBStorageEnabled: boolean;
  121189. /**
  121190. * Gets a boolean indicating if scene must be saved in the database
  121191. */
  121192. readonly enableSceneOffline: boolean;
  121193. /**
  121194. * Gets a boolean indicating if textures must be saved in the database
  121195. */
  121196. readonly enableTexturesOffline: boolean;
  121197. /**
  121198. * Creates a new Database
  121199. * @param urlToScene defines the url to load the scene
  121200. * @param callbackManifestChecked defines the callback to use when manifest is checked
  121201. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  121202. */
  121203. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  121204. private static _ParseURL;
  121205. private static _ReturnFullUrlLocation;
  121206. private _checkManifestFile;
  121207. /**
  121208. * Open the database and make it available
  121209. * @param successCallback defines the callback to call on success
  121210. * @param errorCallback defines the callback to call on error
  121211. */
  121212. open(successCallback: () => void, errorCallback: () => void): void;
  121213. /**
  121214. * Loads an image from the database
  121215. * @param url defines the url to load from
  121216. * @param image defines the target DOM image
  121217. */
  121218. loadImage(url: string, image: HTMLImageElement): void;
  121219. private _loadImageFromDBAsync;
  121220. private _saveImageIntoDBAsync;
  121221. private _checkVersionFromDB;
  121222. private _loadVersionFromDBAsync;
  121223. private _saveVersionIntoDBAsync;
  121224. /**
  121225. * Loads a file from database
  121226. * @param url defines the URL to load from
  121227. * @param sceneLoaded defines a callback to call on success
  121228. * @param progressCallBack defines a callback to call when progress changed
  121229. * @param errorCallback defines a callback to call on error
  121230. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  121231. */
  121232. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  121233. private _loadFileAsync;
  121234. private _saveFileAsync;
  121235. /**
  121236. * Validates if xhr data is correct
  121237. * @param xhr defines the request to validate
  121238. * @param dataType defines the expected data type
  121239. * @returns true if data is correct
  121240. */
  121241. private static _ValidateXHRData;
  121242. }
  121243. }
  121244. declare module BABYLON {
  121245. /** @hidden */
  121246. export var gpuUpdateParticlesPixelShader: {
  121247. name: string;
  121248. shader: string;
  121249. };
  121250. }
  121251. declare module BABYLON {
  121252. /** @hidden */
  121253. export var gpuUpdateParticlesVertexShader: {
  121254. name: string;
  121255. shader: string;
  121256. };
  121257. }
  121258. declare module BABYLON {
  121259. /** @hidden */
  121260. export var clipPlaneFragmentDeclaration2: {
  121261. name: string;
  121262. shader: string;
  121263. };
  121264. }
  121265. declare module BABYLON {
  121266. /** @hidden */
  121267. export var gpuRenderParticlesPixelShader: {
  121268. name: string;
  121269. shader: string;
  121270. };
  121271. }
  121272. declare module BABYLON {
  121273. /** @hidden */
  121274. export var clipPlaneVertexDeclaration2: {
  121275. name: string;
  121276. shader: string;
  121277. };
  121278. }
  121279. declare module BABYLON {
  121280. /** @hidden */
  121281. export var gpuRenderParticlesVertexShader: {
  121282. name: string;
  121283. shader: string;
  121284. };
  121285. }
  121286. declare module BABYLON {
  121287. /**
  121288. * This represents a GPU particle system in Babylon
  121289. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  121290. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  121291. */
  121292. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  121293. /**
  121294. * The layer mask we are rendering the particles through.
  121295. */
  121296. layerMask: number;
  121297. private _capacity;
  121298. private _activeCount;
  121299. private _currentActiveCount;
  121300. private _accumulatedCount;
  121301. private _renderEffect;
  121302. private _updateEffect;
  121303. private _buffer0;
  121304. private _buffer1;
  121305. private _spriteBuffer;
  121306. private _updateVAO;
  121307. private _renderVAO;
  121308. private _targetIndex;
  121309. private _sourceBuffer;
  121310. private _targetBuffer;
  121311. private _engine;
  121312. private _currentRenderId;
  121313. private _started;
  121314. private _stopped;
  121315. private _timeDelta;
  121316. private _randomTexture;
  121317. private _randomTexture2;
  121318. private _attributesStrideSize;
  121319. private _updateEffectOptions;
  121320. private _randomTextureSize;
  121321. private _actualFrame;
  121322. private readonly _rawTextureWidth;
  121323. /**
  121324. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  121325. */
  121326. static readonly IsSupported: boolean;
  121327. /**
  121328. * An event triggered when the system is disposed.
  121329. */
  121330. onDisposeObservable: Observable<GPUParticleSystem>;
  121331. /**
  121332. * Gets the maximum number of particles active at the same time.
  121333. * @returns The max number of active particles.
  121334. */
  121335. getCapacity(): number;
  121336. /**
  121337. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  121338. * to override the particles.
  121339. */
  121340. forceDepthWrite: boolean;
  121341. /**
  121342. * Gets or set the number of active particles
  121343. */
  121344. activeParticleCount: number;
  121345. private _preWarmDone;
  121346. /**
  121347. * Is this system ready to be used/rendered
  121348. * @return true if the system is ready
  121349. */
  121350. isReady(): boolean;
  121351. /**
  121352. * Gets if the system has been started. (Note: this will still be true after stop is called)
  121353. * @returns True if it has been started, otherwise false.
  121354. */
  121355. isStarted(): boolean;
  121356. /**
  121357. * Starts the particle system and begins to emit
  121358. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  121359. */
  121360. start(delay?: number): void;
  121361. /**
  121362. * Stops the particle system.
  121363. */
  121364. stop(): void;
  121365. /**
  121366. * Remove all active particles
  121367. */
  121368. reset(): void;
  121369. /**
  121370. * Returns the string "GPUParticleSystem"
  121371. * @returns a string containing the class name
  121372. */
  121373. getClassName(): string;
  121374. private _colorGradientsTexture;
  121375. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  121376. /**
  121377. * Adds a new color gradient
  121378. * @param gradient defines the gradient to use (between 0 and 1)
  121379. * @param color1 defines the color to affect to the specified gradient
  121380. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  121381. * @returns the current particle system
  121382. */
  121383. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  121384. /**
  121385. * Remove a specific color gradient
  121386. * @param gradient defines the gradient to remove
  121387. * @returns the current particle system
  121388. */
  121389. removeColorGradient(gradient: number): GPUParticleSystem;
  121390. private _angularSpeedGradientsTexture;
  121391. private _sizeGradientsTexture;
  121392. private _velocityGradientsTexture;
  121393. private _limitVelocityGradientsTexture;
  121394. private _dragGradientsTexture;
  121395. private _addFactorGradient;
  121396. /**
  121397. * Adds a new size gradient
  121398. * @param gradient defines the gradient to use (between 0 and 1)
  121399. * @param factor defines the size factor to affect to the specified gradient
  121400. * @returns the current particle system
  121401. */
  121402. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  121403. /**
  121404. * Remove a specific size gradient
  121405. * @param gradient defines the gradient to remove
  121406. * @returns the current particle system
  121407. */
  121408. removeSizeGradient(gradient: number): GPUParticleSystem;
  121409. /**
  121410. * Adds a new angular speed gradient
  121411. * @param gradient defines the gradient to use (between 0 and 1)
  121412. * @param factor defines the angular speed to affect to the specified gradient
  121413. * @returns the current particle system
  121414. */
  121415. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  121416. /**
  121417. * Remove a specific angular speed gradient
  121418. * @param gradient defines the gradient to remove
  121419. * @returns the current particle system
  121420. */
  121421. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  121422. /**
  121423. * Adds a new velocity gradient
  121424. * @param gradient defines the gradient to use (between 0 and 1)
  121425. * @param factor defines the velocity to affect to the specified gradient
  121426. * @returns the current particle system
  121427. */
  121428. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121429. /**
  121430. * Remove a specific velocity gradient
  121431. * @param gradient defines the gradient to remove
  121432. * @returns the current particle system
  121433. */
  121434. removeVelocityGradient(gradient: number): GPUParticleSystem;
  121435. /**
  121436. * Adds a new limit velocity gradient
  121437. * @param gradient defines the gradient to use (between 0 and 1)
  121438. * @param factor defines the limit velocity value to affect to the specified gradient
  121439. * @returns the current particle system
  121440. */
  121441. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121442. /**
  121443. * Remove a specific limit velocity gradient
  121444. * @param gradient defines the gradient to remove
  121445. * @returns the current particle system
  121446. */
  121447. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  121448. /**
  121449. * Adds a new drag gradient
  121450. * @param gradient defines the gradient to use (between 0 and 1)
  121451. * @param factor defines the drag value to affect to the specified gradient
  121452. * @returns the current particle system
  121453. */
  121454. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  121455. /**
  121456. * Remove a specific drag gradient
  121457. * @param gradient defines the gradient to remove
  121458. * @returns the current particle system
  121459. */
  121460. removeDragGradient(gradient: number): GPUParticleSystem;
  121461. /**
  121462. * Not supported by GPUParticleSystem
  121463. * @param gradient defines the gradient to use (between 0 and 1)
  121464. * @param factor defines the emit rate value to affect to the specified gradient
  121465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121466. * @returns the current particle system
  121467. */
  121468. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121469. /**
  121470. * Not supported by GPUParticleSystem
  121471. * @param gradient defines the gradient to remove
  121472. * @returns the current particle system
  121473. */
  121474. removeEmitRateGradient(gradient: number): IParticleSystem;
  121475. /**
  121476. * Not supported by GPUParticleSystem
  121477. * @param gradient defines the gradient to use (between 0 and 1)
  121478. * @param factor defines the start size value to affect to the specified gradient
  121479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121480. * @returns the current particle system
  121481. */
  121482. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121483. /**
  121484. * Not supported by GPUParticleSystem
  121485. * @param gradient defines the gradient to remove
  121486. * @returns the current particle system
  121487. */
  121488. removeStartSizeGradient(gradient: number): IParticleSystem;
  121489. /**
  121490. * Not supported by GPUParticleSystem
  121491. * @param gradient defines the gradient to use (between 0 and 1)
  121492. * @param min defines the color remap minimal range
  121493. * @param max defines the color remap maximal range
  121494. * @returns the current particle system
  121495. */
  121496. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121497. /**
  121498. * Not supported by GPUParticleSystem
  121499. * @param gradient defines the gradient to remove
  121500. * @returns the current particle system
  121501. */
  121502. removeColorRemapGradient(): IParticleSystem;
  121503. /**
  121504. * Not supported by GPUParticleSystem
  121505. * @param gradient defines the gradient to use (between 0 and 1)
  121506. * @param min defines the alpha remap minimal range
  121507. * @param max defines the alpha remap maximal range
  121508. * @returns the current particle system
  121509. */
  121510. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121511. /**
  121512. * Not supported by GPUParticleSystem
  121513. * @param gradient defines the gradient to remove
  121514. * @returns the current particle system
  121515. */
  121516. removeAlphaRemapGradient(): IParticleSystem;
  121517. /**
  121518. * Not supported by GPUParticleSystem
  121519. * @param gradient defines the gradient to use (between 0 and 1)
  121520. * @param color defines the color to affect to the specified gradient
  121521. * @returns the current particle system
  121522. */
  121523. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  121524. /**
  121525. * Not supported by GPUParticleSystem
  121526. * @param gradient defines the gradient to remove
  121527. * @returns the current particle system
  121528. */
  121529. removeRampGradient(): IParticleSystem;
  121530. /**
  121531. * Not supported by GPUParticleSystem
  121532. * @returns the list of ramp gradients
  121533. */
  121534. getRampGradients(): Nullable<Array<Color3Gradient>>;
  121535. /**
  121536. * Not supported by GPUParticleSystem
  121537. * Gets or sets a boolean indicating that ramp gradients must be used
  121538. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  121539. */
  121540. useRampGradients: boolean;
  121541. /**
  121542. * Not supported by GPUParticleSystem
  121543. * @param gradient defines the gradient to use (between 0 and 1)
  121544. * @param factor defines the life time factor to affect to the specified gradient
  121545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121546. * @returns the current particle system
  121547. */
  121548. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121549. /**
  121550. * Not supported by GPUParticleSystem
  121551. * @param gradient defines the gradient to remove
  121552. * @returns the current particle system
  121553. */
  121554. removeLifeTimeGradient(gradient: number): IParticleSystem;
  121555. /**
  121556. * Instantiates a GPU particle system.
  121557. * 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.
  121558. * @param name The name of the particle system
  121559. * @param options The options used to create the system
  121560. * @param scene The scene the particle system belongs to
  121561. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  121562. */
  121563. constructor(name: string, options: Partial<{
  121564. capacity: number;
  121565. randomTextureSize: number;
  121566. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  121567. protected _reset(): void;
  121568. private _createUpdateVAO;
  121569. private _createRenderVAO;
  121570. private _initialize;
  121571. /** @hidden */
  121572. _recreateUpdateEffect(): void;
  121573. /** @hidden */
  121574. _recreateRenderEffect(): void;
  121575. /**
  121576. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  121577. * @param preWarm defines if we are in the pre-warmimg phase
  121578. */
  121579. animate(preWarm?: boolean): void;
  121580. private _createFactorGradientTexture;
  121581. private _createSizeGradientTexture;
  121582. private _createAngularSpeedGradientTexture;
  121583. private _createVelocityGradientTexture;
  121584. private _createLimitVelocityGradientTexture;
  121585. private _createDragGradientTexture;
  121586. private _createColorGradientTexture;
  121587. /**
  121588. * Renders the particle system in its current state
  121589. * @param preWarm defines if the system should only update the particles but not render them
  121590. * @returns the current number of particles
  121591. */
  121592. render(preWarm?: boolean): number;
  121593. /**
  121594. * Rebuilds the particle system
  121595. */
  121596. rebuild(): void;
  121597. private _releaseBuffers;
  121598. private _releaseVAOs;
  121599. /**
  121600. * Disposes the particle system and free the associated resources
  121601. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  121602. */
  121603. dispose(disposeTexture?: boolean): void;
  121604. /**
  121605. * Clones the particle system.
  121606. * @param name The name of the cloned object
  121607. * @param newEmitter The new emitter to use
  121608. * @returns the cloned particle system
  121609. */
  121610. clone(name: string, newEmitter: any): GPUParticleSystem;
  121611. /**
  121612. * Serializes the particle system to a JSON object.
  121613. * @returns the JSON object
  121614. */
  121615. serialize(): any;
  121616. /**
  121617. * Parses a JSON object to create a GPU particle system.
  121618. * @param parsedParticleSystem The JSON object to parse
  121619. * @param scene The scene to create the particle system in
  121620. * @param rootUrl The root url to use to load external dependencies like texture
  121621. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  121622. * @returns the parsed GPU particle system
  121623. */
  121624. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  121625. }
  121626. }
  121627. declare module BABYLON {
  121628. /**
  121629. * Represents a set of particle systems working together to create a specific effect
  121630. */
  121631. export class ParticleSystemSet implements IDisposable {
  121632. private _emitterCreationOptions;
  121633. private _emitterNode;
  121634. /**
  121635. * Gets the particle system list
  121636. */
  121637. systems: IParticleSystem[];
  121638. /**
  121639. * Gets the emitter node used with this set
  121640. */
  121641. readonly emitterNode: Nullable<TransformNode>;
  121642. /**
  121643. * Creates a new emitter mesh as a sphere
  121644. * @param options defines the options used to create the sphere
  121645. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  121646. * @param scene defines the hosting scene
  121647. */
  121648. setEmitterAsSphere(options: {
  121649. diameter: number;
  121650. segments: number;
  121651. color: Color3;
  121652. }, renderingGroupId: number, scene: Scene): void;
  121653. /**
  121654. * Starts all particle systems of the set
  121655. * @param emitter defines an optional mesh to use as emitter for the particle systems
  121656. */
  121657. start(emitter?: AbstractMesh): void;
  121658. /**
  121659. * Release all associated resources
  121660. */
  121661. dispose(): void;
  121662. /**
  121663. * Serialize the set into a JSON compatible object
  121664. * @returns a JSON compatible representation of the set
  121665. */
  121666. serialize(): any;
  121667. /**
  121668. * Parse a new ParticleSystemSet from a serialized source
  121669. * @param data defines a JSON compatible representation of the set
  121670. * @param scene defines the hosting scene
  121671. * @param gpu defines if we want GPU particles or CPU particles
  121672. * @returns a new ParticleSystemSet
  121673. */
  121674. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  121675. }
  121676. }
  121677. declare module BABYLON {
  121678. /**
  121679. * This class is made for on one-liner static method to help creating particle system set.
  121680. */
  121681. export class ParticleHelper {
  121682. /**
  121683. * Gets or sets base Assets URL
  121684. */
  121685. static BaseAssetsUrl: string;
  121686. /**
  121687. * Create a default particle system that you can tweak
  121688. * @param emitter defines the emitter to use
  121689. * @param capacity defines the system capacity (default is 500 particles)
  121690. * @param scene defines the hosting scene
  121691. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  121692. * @returns the new Particle system
  121693. */
  121694. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  121695. /**
  121696. * This is the main static method (one-liner) of this helper to create different particle systems
  121697. * @param type This string represents the type to the particle system to create
  121698. * @param scene The scene where the particle system should live
  121699. * @param gpu If the system will use gpu
  121700. * @returns the ParticleSystemSet created
  121701. */
  121702. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  121703. /**
  121704. * Static function used to export a particle system to a ParticleSystemSet variable.
  121705. * Please note that the emitter shape is not exported
  121706. * @param systems defines the particle systems to export
  121707. * @returns the created particle system set
  121708. */
  121709. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  121710. }
  121711. }
  121712. declare module BABYLON {
  121713. interface Engine {
  121714. /**
  121715. * Create an effect to use with particle systems.
  121716. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  121717. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  121718. * @param uniformsNames defines a list of attribute names
  121719. * @param samplers defines an array of string used to represent textures
  121720. * @param defines defines the string containing the defines to use to compile the shaders
  121721. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121722. * @param onCompiled defines a function to call when the effect creation is successful
  121723. * @param onError defines a function to call when the effect creation has failed
  121724. * @returns the new Effect
  121725. */
  121726. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  121727. }
  121728. interface Mesh {
  121729. /**
  121730. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  121731. * @returns an array of IParticleSystem
  121732. */
  121733. getEmittedParticleSystems(): IParticleSystem[];
  121734. /**
  121735. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  121736. * @returns an array of IParticleSystem
  121737. */
  121738. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  121739. }
  121740. /**
  121741. * @hidden
  121742. */
  121743. export var _IDoNeedToBeInTheBuild: number;
  121744. }
  121745. declare module BABYLON {
  121746. interface Scene {
  121747. /** @hidden (Backing field) */
  121748. _physicsEngine: Nullable<IPhysicsEngine>;
  121749. /**
  121750. * Gets the current physics engine
  121751. * @returns a IPhysicsEngine or null if none attached
  121752. */
  121753. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  121754. /**
  121755. * Enables physics to the current scene
  121756. * @param gravity defines the scene's gravity for the physics engine
  121757. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  121758. * @return a boolean indicating if the physics engine was initialized
  121759. */
  121760. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  121761. /**
  121762. * Disables and disposes the physics engine associated with the scene
  121763. */
  121764. disablePhysicsEngine(): void;
  121765. /**
  121766. * Gets a boolean indicating if there is an active physics engine
  121767. * @returns a boolean indicating if there is an active physics engine
  121768. */
  121769. isPhysicsEnabled(): boolean;
  121770. /**
  121771. * Deletes a physics compound impostor
  121772. * @param compound defines the compound to delete
  121773. */
  121774. deleteCompoundImpostor(compound: any): void;
  121775. /**
  121776. * An event triggered when physic simulation is about to be run
  121777. */
  121778. onBeforePhysicsObservable: Observable<Scene>;
  121779. /**
  121780. * An event triggered when physic simulation has been done
  121781. */
  121782. onAfterPhysicsObservable: Observable<Scene>;
  121783. }
  121784. interface AbstractMesh {
  121785. /** @hidden */
  121786. _physicsImpostor: Nullable<PhysicsImpostor>;
  121787. /**
  121788. * Gets or sets impostor used for physic simulation
  121789. * @see http://doc.babylonjs.com/features/physics_engine
  121790. */
  121791. physicsImpostor: Nullable<PhysicsImpostor>;
  121792. /**
  121793. * Gets the current physics impostor
  121794. * @see http://doc.babylonjs.com/features/physics_engine
  121795. * @returns a physics impostor or null
  121796. */
  121797. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  121798. /** Apply a physic impulse to the mesh
  121799. * @param force defines the force to apply
  121800. * @param contactPoint defines where to apply the force
  121801. * @returns the current mesh
  121802. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121803. */
  121804. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  121805. /**
  121806. * Creates a physic joint between two meshes
  121807. * @param otherMesh defines the other mesh to use
  121808. * @param pivot1 defines the pivot to use on this mesh
  121809. * @param pivot2 defines the pivot to use on the other mesh
  121810. * @param options defines additional options (can be plugin dependent)
  121811. * @returns the current mesh
  121812. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  121813. */
  121814. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  121815. /** @hidden */
  121816. _disposePhysicsObserver: Nullable<Observer<Node>>;
  121817. }
  121818. /**
  121819. * Defines the physics engine scene component responsible to manage a physics engine
  121820. */
  121821. export class PhysicsEngineSceneComponent implements ISceneComponent {
  121822. /**
  121823. * The component name helpful to identify the component in the list of scene components.
  121824. */
  121825. readonly name: string;
  121826. /**
  121827. * The scene the component belongs to.
  121828. */
  121829. scene: Scene;
  121830. /**
  121831. * Creates a new instance of the component for the given scene
  121832. * @param scene Defines the scene to register the component in
  121833. */
  121834. constructor(scene: Scene);
  121835. /**
  121836. * Registers the component in a given scene
  121837. */
  121838. register(): void;
  121839. /**
  121840. * Rebuilds the elements related to this component in case of
  121841. * context lost for instance.
  121842. */
  121843. rebuild(): void;
  121844. /**
  121845. * Disposes the component and the associated ressources
  121846. */
  121847. dispose(): void;
  121848. }
  121849. }
  121850. declare module BABYLON {
  121851. /**
  121852. * A helper for physics simulations
  121853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121854. */
  121855. export class PhysicsHelper {
  121856. private _scene;
  121857. private _physicsEngine;
  121858. /**
  121859. * Initializes the Physics helper
  121860. * @param scene Babylon.js scene
  121861. */
  121862. constructor(scene: Scene);
  121863. /**
  121864. * Applies a radial explosion impulse
  121865. * @param origin the origin of the explosion
  121866. * @param radiusOrEventOptions the radius or the options of radial explosion
  121867. * @param strength the explosion strength
  121868. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121869. * @returns A physics radial explosion event, or null
  121870. */
  121871. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121872. /**
  121873. * Applies a radial explosion force
  121874. * @param origin the origin of the explosion
  121875. * @param radiusOrEventOptions the radius or the options of radial explosion
  121876. * @param strength the explosion strength
  121877. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121878. * @returns A physics radial explosion event, or null
  121879. */
  121880. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121881. /**
  121882. * Creates a gravitational field
  121883. * @param origin the origin of the explosion
  121884. * @param radiusOrEventOptions the radius or the options of radial explosion
  121885. * @param strength the explosion strength
  121886. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121887. * @returns A physics gravitational field event, or null
  121888. */
  121889. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  121890. /**
  121891. * Creates a physics updraft event
  121892. * @param origin the origin of the updraft
  121893. * @param radiusOrEventOptions the radius or the options of the updraft
  121894. * @param strength the strength of the updraft
  121895. * @param height the height of the updraft
  121896. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  121897. * @returns A physics updraft event, or null
  121898. */
  121899. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  121900. /**
  121901. * Creates a physics vortex event
  121902. * @param origin the of the vortex
  121903. * @param radiusOrEventOptions the radius or the options of the vortex
  121904. * @param strength the strength of the vortex
  121905. * @param height the height of the vortex
  121906. * @returns a Physics vortex event, or null
  121907. * A physics vortex event or null
  121908. */
  121909. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  121910. }
  121911. /**
  121912. * Represents a physics radial explosion event
  121913. */
  121914. class PhysicsRadialExplosionEvent {
  121915. private _scene;
  121916. private _options;
  121917. private _sphere;
  121918. private _dataFetched;
  121919. /**
  121920. * Initializes a radial explosioin event
  121921. * @param _scene BabylonJS scene
  121922. * @param _options The options for the vortex event
  121923. */
  121924. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  121925. /**
  121926. * Returns the data related to the radial explosion event (sphere).
  121927. * @returns The radial explosion event data
  121928. */
  121929. getData(): PhysicsRadialExplosionEventData;
  121930. /**
  121931. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  121932. * @param impostor A physics imposter
  121933. * @param origin the origin of the explosion
  121934. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  121935. */
  121936. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  121937. /**
  121938. * Triggers affecterd impostors callbacks
  121939. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  121940. */
  121941. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  121942. /**
  121943. * Disposes the sphere.
  121944. * @param force Specifies if the sphere should be disposed by force
  121945. */
  121946. dispose(force?: boolean): void;
  121947. /*** Helpers ***/
  121948. private _prepareSphere;
  121949. private _intersectsWithSphere;
  121950. }
  121951. /**
  121952. * Represents a gravitational field event
  121953. */
  121954. class PhysicsGravitationalFieldEvent {
  121955. private _physicsHelper;
  121956. private _scene;
  121957. private _origin;
  121958. private _options;
  121959. private _tickCallback;
  121960. private _sphere;
  121961. private _dataFetched;
  121962. /**
  121963. * Initializes the physics gravitational field event
  121964. * @param _physicsHelper A physics helper
  121965. * @param _scene BabylonJS scene
  121966. * @param _origin The origin position of the gravitational field event
  121967. * @param _options The options for the vortex event
  121968. */
  121969. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  121970. /**
  121971. * Returns the data related to the gravitational field event (sphere).
  121972. * @returns A gravitational field event
  121973. */
  121974. getData(): PhysicsGravitationalFieldEventData;
  121975. /**
  121976. * Enables the gravitational field.
  121977. */
  121978. enable(): void;
  121979. /**
  121980. * Disables the gravitational field.
  121981. */
  121982. disable(): void;
  121983. /**
  121984. * Disposes the sphere.
  121985. * @param force The force to dispose from the gravitational field event
  121986. */
  121987. dispose(force?: boolean): void;
  121988. private _tick;
  121989. }
  121990. /**
  121991. * Represents a physics updraft event
  121992. */
  121993. class PhysicsUpdraftEvent {
  121994. private _scene;
  121995. private _origin;
  121996. private _options;
  121997. private _physicsEngine;
  121998. private _originTop;
  121999. private _originDirection;
  122000. private _tickCallback;
  122001. private _cylinder;
  122002. private _cylinderPosition;
  122003. private _dataFetched;
  122004. /**
  122005. * Initializes the physics updraft event
  122006. * @param _scene BabylonJS scene
  122007. * @param _origin The origin position of the updraft
  122008. * @param _options The options for the updraft event
  122009. */
  122010. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  122011. /**
  122012. * Returns the data related to the updraft event (cylinder).
  122013. * @returns A physics updraft event
  122014. */
  122015. getData(): PhysicsUpdraftEventData;
  122016. /**
  122017. * Enables the updraft.
  122018. */
  122019. enable(): void;
  122020. /**
  122021. * Disables the updraft.
  122022. */
  122023. disable(): void;
  122024. /**
  122025. * Disposes the cylinder.
  122026. * @param force Specifies if the updraft should be disposed by force
  122027. */
  122028. dispose(force?: boolean): void;
  122029. private getImpostorHitData;
  122030. private _tick;
  122031. /*** Helpers ***/
  122032. private _prepareCylinder;
  122033. private _intersectsWithCylinder;
  122034. }
  122035. /**
  122036. * Represents a physics vortex event
  122037. */
  122038. class PhysicsVortexEvent {
  122039. private _scene;
  122040. private _origin;
  122041. private _options;
  122042. private _physicsEngine;
  122043. private _originTop;
  122044. private _tickCallback;
  122045. private _cylinder;
  122046. private _cylinderPosition;
  122047. private _dataFetched;
  122048. /**
  122049. * Initializes the physics vortex event
  122050. * @param _scene The BabylonJS scene
  122051. * @param _origin The origin position of the vortex
  122052. * @param _options The options for the vortex event
  122053. */
  122054. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  122055. /**
  122056. * Returns the data related to the vortex event (cylinder).
  122057. * @returns The physics vortex event data
  122058. */
  122059. getData(): PhysicsVortexEventData;
  122060. /**
  122061. * Enables the vortex.
  122062. */
  122063. enable(): void;
  122064. /**
  122065. * Disables the cortex.
  122066. */
  122067. disable(): void;
  122068. /**
  122069. * Disposes the sphere.
  122070. * @param force
  122071. */
  122072. dispose(force?: boolean): void;
  122073. private getImpostorHitData;
  122074. private _tick;
  122075. /*** Helpers ***/
  122076. private _prepareCylinder;
  122077. private _intersectsWithCylinder;
  122078. }
  122079. /**
  122080. * Options fot the radial explosion event
  122081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122082. */
  122083. export class PhysicsRadialExplosionEventOptions {
  122084. /**
  122085. * The radius of the sphere for the radial explosion.
  122086. */
  122087. radius: number;
  122088. /**
  122089. * The strenth of the explosion.
  122090. */
  122091. strength: number;
  122092. /**
  122093. * The strenght of the force in correspondence to the distance of the affected object
  122094. */
  122095. falloff: PhysicsRadialImpulseFalloff;
  122096. /**
  122097. * Sphere options for the radial explosion.
  122098. */
  122099. sphere: {
  122100. segments: number;
  122101. diameter: number;
  122102. };
  122103. /**
  122104. * Sphere options for the radial explosion.
  122105. */
  122106. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  122107. }
  122108. /**
  122109. * Options fot the updraft event
  122110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122111. */
  122112. export class PhysicsUpdraftEventOptions {
  122113. /**
  122114. * The radius of the cylinder for the vortex
  122115. */
  122116. radius: number;
  122117. /**
  122118. * The strenth of the updraft.
  122119. */
  122120. strength: number;
  122121. /**
  122122. * The height of the cylinder for the updraft.
  122123. */
  122124. height: number;
  122125. /**
  122126. * The mode for the the updraft.
  122127. */
  122128. updraftMode: PhysicsUpdraftMode;
  122129. }
  122130. /**
  122131. * Options fot the vortex event
  122132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122133. */
  122134. export class PhysicsVortexEventOptions {
  122135. /**
  122136. * The radius of the cylinder for the vortex
  122137. */
  122138. radius: number;
  122139. /**
  122140. * The strenth of the vortex.
  122141. */
  122142. strength: number;
  122143. /**
  122144. * The height of the cylinder for the vortex.
  122145. */
  122146. height: number;
  122147. /**
  122148. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  122149. */
  122150. centripetalForceThreshold: number;
  122151. /**
  122152. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  122153. */
  122154. centripetalForceMultiplier: number;
  122155. /**
  122156. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  122157. */
  122158. centrifugalForceMultiplier: number;
  122159. /**
  122160. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  122161. */
  122162. updraftForceMultiplier: number;
  122163. }
  122164. /**
  122165. * The strenght of the force in correspondence to the distance of the affected object
  122166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122167. */
  122168. export enum PhysicsRadialImpulseFalloff {
  122169. /** Defines that impulse is constant in strength across it's whole radius */
  122170. Constant = 0,
  122171. /** Defines that impulse gets weaker if it's further from the origin */
  122172. Linear = 1
  122173. }
  122174. /**
  122175. * The strength of the force in correspondence to the distance of the affected object
  122176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122177. */
  122178. export enum PhysicsUpdraftMode {
  122179. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  122180. Center = 0,
  122181. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  122182. Perpendicular = 1
  122183. }
  122184. /**
  122185. * Interface for a physics hit data
  122186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122187. */
  122188. export interface PhysicsHitData {
  122189. /**
  122190. * The force applied at the contact point
  122191. */
  122192. force: Vector3;
  122193. /**
  122194. * The contact point
  122195. */
  122196. contactPoint: Vector3;
  122197. /**
  122198. * The distance from the origin to the contact point
  122199. */
  122200. distanceFromOrigin: number;
  122201. }
  122202. /**
  122203. * Interface for radial explosion event data
  122204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122205. */
  122206. export interface PhysicsRadialExplosionEventData {
  122207. /**
  122208. * A sphere used for the radial explosion event
  122209. */
  122210. sphere: Mesh;
  122211. }
  122212. /**
  122213. * Interface for gravitational field event data
  122214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122215. */
  122216. export interface PhysicsGravitationalFieldEventData {
  122217. /**
  122218. * A sphere mesh used for the gravitational field event
  122219. */
  122220. sphere: Mesh;
  122221. }
  122222. /**
  122223. * Interface for updraft event data
  122224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122225. */
  122226. export interface PhysicsUpdraftEventData {
  122227. /**
  122228. * A cylinder used for the updraft event
  122229. */
  122230. cylinder: Mesh;
  122231. }
  122232. /**
  122233. * Interface for vortex event data
  122234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122235. */
  122236. export interface PhysicsVortexEventData {
  122237. /**
  122238. * A cylinder used for the vortex event
  122239. */
  122240. cylinder: Mesh;
  122241. }
  122242. /**
  122243. * Interface for an affected physics impostor
  122244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122245. */
  122246. export interface PhysicsAffectedImpostorWithData {
  122247. /**
  122248. * The impostor affected by the effect
  122249. */
  122250. impostor: PhysicsImpostor;
  122251. /**
  122252. * The data about the hit/horce from the explosion
  122253. */
  122254. hitData: PhysicsHitData;
  122255. }
  122256. }
  122257. declare module BABYLON {
  122258. /** @hidden */
  122259. export var blackAndWhitePixelShader: {
  122260. name: string;
  122261. shader: string;
  122262. };
  122263. }
  122264. declare module BABYLON {
  122265. /**
  122266. * Post process used to render in black and white
  122267. */
  122268. export class BlackAndWhitePostProcess extends PostProcess {
  122269. /**
  122270. * Linear about to convert he result to black and white (default: 1)
  122271. */
  122272. degree: number;
  122273. /**
  122274. * Creates a black and white post process
  122275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122276. * @param name The name of the effect.
  122277. * @param options The required width/height ratio to downsize to before computing the render pass.
  122278. * @param camera The camera to apply the render pass to.
  122279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122280. * @param engine The engine which the post process will be applied. (default: current engine)
  122281. * @param reusable If the post process can be reused on the same frame. (default: false)
  122282. */
  122283. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122284. }
  122285. }
  122286. declare module BABYLON {
  122287. /**
  122288. * This represents a set of one or more post processes in Babylon.
  122289. * A post process can be used to apply a shader to a texture after it is rendered.
  122290. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122291. */
  122292. export class PostProcessRenderEffect {
  122293. private _postProcesses;
  122294. private _getPostProcesses;
  122295. private _singleInstance;
  122296. private _cameras;
  122297. private _indicesForCamera;
  122298. /**
  122299. * Name of the effect
  122300. * @hidden
  122301. */
  122302. _name: string;
  122303. /**
  122304. * Instantiates a post process render effect.
  122305. * A post process can be used to apply a shader to a texture after it is rendered.
  122306. * @param engine The engine the effect is tied to
  122307. * @param name The name of the effect
  122308. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  122309. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  122310. */
  122311. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  122312. /**
  122313. * Checks if all the post processes in the effect are supported.
  122314. */
  122315. readonly isSupported: boolean;
  122316. /**
  122317. * Updates the current state of the effect
  122318. * @hidden
  122319. */
  122320. _update(): void;
  122321. /**
  122322. * Attaches the effect on cameras
  122323. * @param cameras The camera to attach to.
  122324. * @hidden
  122325. */
  122326. _attachCameras(cameras: Camera): void;
  122327. /**
  122328. * Attaches the effect on cameras
  122329. * @param cameras The camera to attach to.
  122330. * @hidden
  122331. */
  122332. _attachCameras(cameras: Camera[]): void;
  122333. /**
  122334. * Detaches the effect on cameras
  122335. * @param cameras The camera to detatch from.
  122336. * @hidden
  122337. */
  122338. _detachCameras(cameras: Camera): void;
  122339. /**
  122340. * Detatches the effect on cameras
  122341. * @param cameras The camera to detatch from.
  122342. * @hidden
  122343. */
  122344. _detachCameras(cameras: Camera[]): void;
  122345. /**
  122346. * Enables the effect on given cameras
  122347. * @param cameras The camera to enable.
  122348. * @hidden
  122349. */
  122350. _enable(cameras: Camera): void;
  122351. /**
  122352. * Enables the effect on given cameras
  122353. * @param cameras The camera to enable.
  122354. * @hidden
  122355. */
  122356. _enable(cameras: Nullable<Camera[]>): void;
  122357. /**
  122358. * Disables the effect on the given cameras
  122359. * @param cameras The camera to disable.
  122360. * @hidden
  122361. */
  122362. _disable(cameras: Camera): void;
  122363. /**
  122364. * Disables the effect on the given cameras
  122365. * @param cameras The camera to disable.
  122366. * @hidden
  122367. */
  122368. _disable(cameras: Nullable<Camera[]>): void;
  122369. /**
  122370. * Gets a list of the post processes contained in the effect.
  122371. * @param camera The camera to get the post processes on.
  122372. * @returns The list of the post processes in the effect.
  122373. */
  122374. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  122375. }
  122376. }
  122377. declare module BABYLON {
  122378. /** @hidden */
  122379. export var extractHighlightsPixelShader: {
  122380. name: string;
  122381. shader: string;
  122382. };
  122383. }
  122384. declare module BABYLON {
  122385. /**
  122386. * 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.
  122387. */
  122388. export class ExtractHighlightsPostProcess extends PostProcess {
  122389. /**
  122390. * The luminance threshold, pixels below this value will be set to black.
  122391. */
  122392. threshold: number;
  122393. /** @hidden */
  122394. _exposure: number;
  122395. /**
  122396. * Post process which has the input texture to be used when performing highlight extraction
  122397. * @hidden
  122398. */
  122399. _inputPostProcess: Nullable<PostProcess>;
  122400. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122401. }
  122402. }
  122403. declare module BABYLON {
  122404. /** @hidden */
  122405. export var bloomMergePixelShader: {
  122406. name: string;
  122407. shader: string;
  122408. };
  122409. }
  122410. declare module BABYLON {
  122411. /**
  122412. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122413. */
  122414. export class BloomMergePostProcess extends PostProcess {
  122415. /** Weight of the bloom to be added to the original input. */
  122416. weight: number;
  122417. /**
  122418. * Creates a new instance of @see BloomMergePostProcess
  122419. * @param name The name of the effect.
  122420. * @param originalFromInput Post process which's input will be used for the merge.
  122421. * @param blurred Blurred highlights post process which's output will be used.
  122422. * @param weight Weight of the bloom to be added to the original input.
  122423. * @param options The required width/height ratio to downsize to before computing the render pass.
  122424. * @param camera The camera to apply the render pass to.
  122425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122426. * @param engine The engine which the post process will be applied. (default: current engine)
  122427. * @param reusable If the post process can be reused on the same frame. (default: false)
  122428. * @param textureType Type of textures used when performing the post process. (default: 0)
  122429. * @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)
  122430. */
  122431. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  122432. /** Weight of the bloom to be added to the original input. */
  122433. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122434. }
  122435. }
  122436. declare module BABYLON {
  122437. /**
  122438. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122439. */
  122440. export class BloomEffect extends PostProcessRenderEffect {
  122441. private bloomScale;
  122442. /**
  122443. * @hidden Internal
  122444. */
  122445. _effects: Array<PostProcess>;
  122446. /**
  122447. * @hidden Internal
  122448. */
  122449. _downscale: ExtractHighlightsPostProcess;
  122450. private _blurX;
  122451. private _blurY;
  122452. private _merge;
  122453. /**
  122454. * The luminance threshold to find bright areas of the image to bloom.
  122455. */
  122456. threshold: number;
  122457. /**
  122458. * The strength of the bloom.
  122459. */
  122460. weight: number;
  122461. /**
  122462. * Specifies the size of the bloom blur kernel, relative to the final output size
  122463. */
  122464. kernel: number;
  122465. /**
  122466. * Creates a new instance of @see BloomEffect
  122467. * @param scene The scene the effect belongs to.
  122468. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122469. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122470. * @param bloomWeight The the strength of bloom.
  122471. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122472. * @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)
  122473. */
  122474. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  122475. /**
  122476. * Disposes each of the internal effects for a given camera.
  122477. * @param camera The camera to dispose the effect on.
  122478. */
  122479. disposeEffects(camera: Camera): void;
  122480. /**
  122481. * @hidden Internal
  122482. */
  122483. _updateEffects(): void;
  122484. /**
  122485. * Internal
  122486. * @returns if all the contained post processes are ready.
  122487. * @hidden
  122488. */
  122489. _isReady(): boolean;
  122490. }
  122491. }
  122492. declare module BABYLON {
  122493. /** @hidden */
  122494. export var chromaticAberrationPixelShader: {
  122495. name: string;
  122496. shader: string;
  122497. };
  122498. }
  122499. declare module BABYLON {
  122500. /**
  122501. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122502. */
  122503. export class ChromaticAberrationPostProcess extends PostProcess {
  122504. /**
  122505. * The amount of seperation of rgb channels (default: 30)
  122506. */
  122507. aberrationAmount: number;
  122508. /**
  122509. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122510. */
  122511. radialIntensity: number;
  122512. /**
  122513. * 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))
  122514. */
  122515. direction: Vector2;
  122516. /**
  122517. * 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))
  122518. */
  122519. centerPosition: Vector2;
  122520. /**
  122521. * Creates a new instance ChromaticAberrationPostProcess
  122522. * @param name The name of the effect.
  122523. * @param screenWidth The width of the screen to apply the effect on.
  122524. * @param screenHeight The height of the screen to apply the effect on.
  122525. * @param options The required width/height ratio to downsize to before computing the render pass.
  122526. * @param camera The camera to apply the render pass to.
  122527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122528. * @param engine The engine which the post process will be applied. (default: current engine)
  122529. * @param reusable If the post process can be reused on the same frame. (default: false)
  122530. * @param textureType Type of textures used when performing the post process. (default: 0)
  122531. * @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)
  122532. */
  122533. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122534. }
  122535. }
  122536. declare module BABYLON {
  122537. /** @hidden */
  122538. export var circleOfConfusionPixelShader: {
  122539. name: string;
  122540. shader: string;
  122541. };
  122542. }
  122543. declare module BABYLON {
  122544. /**
  122545. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122546. */
  122547. export class CircleOfConfusionPostProcess extends PostProcess {
  122548. /**
  122549. * 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.
  122550. */
  122551. lensSize: number;
  122552. /**
  122553. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122554. */
  122555. fStop: number;
  122556. /**
  122557. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122558. */
  122559. focusDistance: number;
  122560. /**
  122561. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122562. */
  122563. focalLength: number;
  122564. private _depthTexture;
  122565. /**
  122566. * Creates a new instance CircleOfConfusionPostProcess
  122567. * @param name The name of the effect.
  122568. * @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.
  122569. * @param options The required width/height ratio to downsize to before computing the render pass.
  122570. * @param camera The camera to apply the render pass to.
  122571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122572. * @param engine The engine which the post process will be applied. (default: current engine)
  122573. * @param reusable If the post process can be reused on the same frame. (default: false)
  122574. * @param textureType Type of textures used when performing the post process. (default: 0)
  122575. * @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)
  122576. */
  122577. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122578. /**
  122579. * 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.
  122580. */
  122581. depthTexture: RenderTargetTexture;
  122582. }
  122583. }
  122584. declare module BABYLON {
  122585. /** @hidden */
  122586. export var colorCorrectionPixelShader: {
  122587. name: string;
  122588. shader: string;
  122589. };
  122590. }
  122591. declare module BABYLON {
  122592. /**
  122593. *
  122594. * This post-process allows the modification of rendered colors by using
  122595. * a 'look-up table' (LUT). This effect is also called Color Grading.
  122596. *
  122597. * The object needs to be provided an url to a texture containing the color
  122598. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  122599. * Use an image editing software to tweak the LUT to match your needs.
  122600. *
  122601. * For an example of a color LUT, see here:
  122602. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  122603. * For explanations on color grading, see here:
  122604. * @see http://udn.epicgames.com/Three/ColorGrading.html
  122605. *
  122606. */
  122607. export class ColorCorrectionPostProcess extends PostProcess {
  122608. private _colorTableTexture;
  122609. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122610. }
  122611. }
  122612. declare module BABYLON {
  122613. /** @hidden */
  122614. export var convolutionPixelShader: {
  122615. name: string;
  122616. shader: string;
  122617. };
  122618. }
  122619. declare module BABYLON {
  122620. /**
  122621. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  122622. * input texture to perform effects such as edge detection or sharpening
  122623. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122624. */
  122625. export class ConvolutionPostProcess extends PostProcess {
  122626. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122627. kernel: number[];
  122628. /**
  122629. * Creates a new instance ConvolutionPostProcess
  122630. * @param name The name of the effect.
  122631. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  122632. * @param options The required width/height ratio to downsize to before computing the render pass.
  122633. * @param camera The camera to apply the render pass to.
  122634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122635. * @param engine The engine which the post process will be applied. (default: current engine)
  122636. * @param reusable If the post process can be reused on the same frame. (default: false)
  122637. * @param textureType Type of textures used when performing the post process. (default: 0)
  122638. */
  122639. constructor(name: string,
  122640. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122641. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122642. /**
  122643. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122644. */
  122645. static EdgeDetect0Kernel: number[];
  122646. /**
  122647. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122648. */
  122649. static EdgeDetect1Kernel: number[];
  122650. /**
  122651. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122652. */
  122653. static EdgeDetect2Kernel: number[];
  122654. /**
  122655. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122656. */
  122657. static SharpenKernel: number[];
  122658. /**
  122659. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122660. */
  122661. static EmbossKernel: number[];
  122662. /**
  122663. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122664. */
  122665. static GaussianKernel: number[];
  122666. }
  122667. }
  122668. declare module BABYLON {
  122669. /**
  122670. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  122671. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  122672. * based on samples that have a large difference in distance than the center pixel.
  122673. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  122674. */
  122675. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  122676. direction: Vector2;
  122677. /**
  122678. * Creates a new instance CircleOfConfusionPostProcess
  122679. * @param name The name of the effect.
  122680. * @param scene The scene the effect belongs to.
  122681. * @param direction The direction the blur should be applied.
  122682. * @param kernel The size of the kernel used to blur.
  122683. * @param options The required width/height ratio to downsize to before computing the render pass.
  122684. * @param camera The camera to apply the render pass to.
  122685. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  122686. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  122687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122688. * @param engine The engine which the post process will be applied. (default: current engine)
  122689. * @param reusable If the post process can be reused on the same frame. (default: false)
  122690. * @param textureType Type of textures used when performing the post process. (default: 0)
  122691. * @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)
  122692. */
  122693. 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);
  122694. }
  122695. }
  122696. declare module BABYLON {
  122697. /** @hidden */
  122698. export var depthOfFieldMergePixelShader: {
  122699. name: string;
  122700. shader: string;
  122701. };
  122702. }
  122703. declare module BABYLON {
  122704. /**
  122705. * Options to be set when merging outputs from the default pipeline.
  122706. */
  122707. export class DepthOfFieldMergePostProcessOptions {
  122708. /**
  122709. * The original image to merge on top of
  122710. */
  122711. originalFromInput: PostProcess;
  122712. /**
  122713. * Parameters to perform the merge of the depth of field effect
  122714. */
  122715. depthOfField?: {
  122716. circleOfConfusion: PostProcess;
  122717. blurSteps: Array<PostProcess>;
  122718. };
  122719. /**
  122720. * Parameters to perform the merge of bloom effect
  122721. */
  122722. bloom?: {
  122723. blurred: PostProcess;
  122724. weight: number;
  122725. };
  122726. }
  122727. /**
  122728. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122729. */
  122730. export class DepthOfFieldMergePostProcess extends PostProcess {
  122731. private blurSteps;
  122732. /**
  122733. * Creates a new instance of DepthOfFieldMergePostProcess
  122734. * @param name The name of the effect.
  122735. * @param originalFromInput Post process which's input will be used for the merge.
  122736. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  122737. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  122738. * @param options The required width/height ratio to downsize to before computing the render pass.
  122739. * @param camera The camera to apply the render pass to.
  122740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122741. * @param engine The engine which the post process will be applied. (default: current engine)
  122742. * @param reusable If the post process can be reused on the same frame. (default: false)
  122743. * @param textureType Type of textures used when performing the post process. (default: 0)
  122744. * @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)
  122745. */
  122746. 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);
  122747. /**
  122748. * Updates the effect with the current post process compile time values and recompiles the shader.
  122749. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122750. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122751. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122752. * @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
  122753. * @param onCompiled Called when the shader has been compiled.
  122754. * @param onError Called if there is an error when compiling a shader.
  122755. */
  122756. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  122757. }
  122758. }
  122759. declare module BABYLON {
  122760. /**
  122761. * Specifies the level of max blur that should be applied when using the depth of field effect
  122762. */
  122763. export enum DepthOfFieldEffectBlurLevel {
  122764. /**
  122765. * Subtle blur
  122766. */
  122767. Low = 0,
  122768. /**
  122769. * Medium blur
  122770. */
  122771. Medium = 1,
  122772. /**
  122773. * Large blur
  122774. */
  122775. High = 2
  122776. }
  122777. /**
  122778. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  122779. */
  122780. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  122781. private _circleOfConfusion;
  122782. /**
  122783. * @hidden Internal, blurs from high to low
  122784. */
  122785. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  122786. private _depthOfFieldBlurY;
  122787. private _dofMerge;
  122788. /**
  122789. * @hidden Internal post processes in depth of field effect
  122790. */
  122791. _effects: Array<PostProcess>;
  122792. /**
  122793. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  122794. */
  122795. focalLength: number;
  122796. /**
  122797. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122798. */
  122799. fStop: number;
  122800. /**
  122801. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122802. */
  122803. focusDistance: number;
  122804. /**
  122805. * 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.
  122806. */
  122807. lensSize: number;
  122808. /**
  122809. * Creates a new instance DepthOfFieldEffect
  122810. * @param scene The scene the effect belongs to.
  122811. * @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.
  122812. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122813. * @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)
  122814. */
  122815. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  122816. /**
  122817. * Get the current class name of the current effet
  122818. * @returns "DepthOfFieldEffect"
  122819. */
  122820. getClassName(): string;
  122821. /**
  122822. * 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.
  122823. */
  122824. depthTexture: RenderTargetTexture;
  122825. /**
  122826. * Disposes each of the internal effects for a given camera.
  122827. * @param camera The camera to dispose the effect on.
  122828. */
  122829. disposeEffects(camera: Camera): void;
  122830. /**
  122831. * @hidden Internal
  122832. */
  122833. _updateEffects(): void;
  122834. /**
  122835. * Internal
  122836. * @returns if all the contained post processes are ready.
  122837. * @hidden
  122838. */
  122839. _isReady(): boolean;
  122840. }
  122841. }
  122842. declare module BABYLON {
  122843. /** @hidden */
  122844. export var displayPassPixelShader: {
  122845. name: string;
  122846. shader: string;
  122847. };
  122848. }
  122849. declare module BABYLON {
  122850. /**
  122851. * DisplayPassPostProcess which produces an output the same as it's input
  122852. */
  122853. export class DisplayPassPostProcess extends PostProcess {
  122854. /**
  122855. * Creates the DisplayPassPostProcess
  122856. * @param name The name of the effect.
  122857. * @param options The required width/height ratio to downsize to before computing the render pass.
  122858. * @param camera The camera to apply the render pass to.
  122859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122860. * @param engine The engine which the post process will be applied. (default: current engine)
  122861. * @param reusable If the post process can be reused on the same frame. (default: false)
  122862. */
  122863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122864. }
  122865. }
  122866. declare module BABYLON {
  122867. /** @hidden */
  122868. export var filterPixelShader: {
  122869. name: string;
  122870. shader: string;
  122871. };
  122872. }
  122873. declare module BABYLON {
  122874. /**
  122875. * Applies a kernel filter to the image
  122876. */
  122877. export class FilterPostProcess extends PostProcess {
  122878. /** The matrix to be applied to the image */
  122879. kernelMatrix: Matrix;
  122880. /**
  122881. *
  122882. * @param name The name of the effect.
  122883. * @param kernelMatrix The matrix to be applied to the image
  122884. * @param options The required width/height ratio to downsize to before computing the render pass.
  122885. * @param camera The camera to apply the render pass to.
  122886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122887. * @param engine The engine which the post process will be applied. (default: current engine)
  122888. * @param reusable If the post process can be reused on the same frame. (default: false)
  122889. */
  122890. constructor(name: string,
  122891. /** The matrix to be applied to the image */
  122892. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122893. }
  122894. }
  122895. declare module BABYLON {
  122896. /** @hidden */
  122897. export var fxaaPixelShader: {
  122898. name: string;
  122899. shader: string;
  122900. };
  122901. }
  122902. declare module BABYLON {
  122903. /** @hidden */
  122904. export var fxaaVertexShader: {
  122905. name: string;
  122906. shader: string;
  122907. };
  122908. }
  122909. declare module BABYLON {
  122910. /**
  122911. * Fxaa post process
  122912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122913. */
  122914. export class FxaaPostProcess extends PostProcess {
  122915. /** @hidden */
  122916. texelWidth: number;
  122917. /** @hidden */
  122918. texelHeight: number;
  122919. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122920. private _getDefines;
  122921. }
  122922. }
  122923. declare module BABYLON {
  122924. /** @hidden */
  122925. export var grainPixelShader: {
  122926. name: string;
  122927. shader: string;
  122928. };
  122929. }
  122930. declare module BABYLON {
  122931. /**
  122932. * The GrainPostProcess adds noise to the image at mid luminance levels
  122933. */
  122934. export class GrainPostProcess extends PostProcess {
  122935. /**
  122936. * The intensity of the grain added (default: 30)
  122937. */
  122938. intensity: number;
  122939. /**
  122940. * If the grain should be randomized on every frame
  122941. */
  122942. animated: boolean;
  122943. /**
  122944. * Creates a new instance of @see GrainPostProcess
  122945. * @param name The name of the effect.
  122946. * @param options The required width/height ratio to downsize to before computing the render pass.
  122947. * @param camera The camera to apply the render pass to.
  122948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122949. * @param engine The engine which the post process will be applied. (default: current engine)
  122950. * @param reusable If the post process can be reused on the same frame. (default: false)
  122951. * @param textureType Type of textures used when performing the post process. (default: 0)
  122952. * @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)
  122953. */
  122954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122955. }
  122956. }
  122957. declare module BABYLON {
  122958. /** @hidden */
  122959. export var highlightsPixelShader: {
  122960. name: string;
  122961. shader: string;
  122962. };
  122963. }
  122964. declare module BABYLON {
  122965. /**
  122966. * Extracts highlights from the image
  122967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122968. */
  122969. export class HighlightsPostProcess extends PostProcess {
  122970. /**
  122971. * Extracts highlights from the image
  122972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122973. * @param name The name of the effect.
  122974. * @param options The required width/height ratio to downsize to before computing the render pass.
  122975. * @param camera The camera to apply the render pass to.
  122976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122977. * @param engine The engine which the post process will be applied. (default: current engine)
  122978. * @param reusable If the post process can be reused on the same frame. (default: false)
  122979. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122980. */
  122981. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122982. }
  122983. }
  122984. declare module BABYLON {
  122985. /** @hidden */
  122986. export var mrtFragmentDeclaration: {
  122987. name: string;
  122988. shader: string;
  122989. };
  122990. }
  122991. declare module BABYLON {
  122992. /** @hidden */
  122993. export var geometryPixelShader: {
  122994. name: string;
  122995. shader: string;
  122996. };
  122997. }
  122998. declare module BABYLON {
  122999. /** @hidden */
  123000. export var geometryVertexShader: {
  123001. name: string;
  123002. shader: string;
  123003. };
  123004. }
  123005. declare module BABYLON {
  123006. /** @hidden */
  123007. interface ISavedTransformationMatrix {
  123008. world: Matrix;
  123009. viewProjection: Matrix;
  123010. }
  123011. /**
  123012. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  123013. */
  123014. export class GeometryBufferRenderer {
  123015. /**
  123016. * Constant used to retrieve the position texture index in the G-Buffer textures array
  123017. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  123018. */
  123019. static readonly POSITION_TEXTURE_TYPE: number;
  123020. /**
  123021. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  123022. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  123023. */
  123024. static readonly VELOCITY_TEXTURE_TYPE: number;
  123025. /**
  123026. * Dictionary used to store the previous transformation matrices of each rendered mesh
  123027. * in order to compute objects velocities when enableVelocity is set to "true"
  123028. * @hidden
  123029. */
  123030. _previousTransformationMatrices: {
  123031. [index: number]: ISavedTransformationMatrix;
  123032. };
  123033. /**
  123034. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  123035. * in order to compute objects velocities when enableVelocity is set to "true"
  123036. * @hidden
  123037. */
  123038. _previousBonesTransformationMatrices: {
  123039. [index: number]: Float32Array;
  123040. };
  123041. /**
  123042. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  123043. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  123044. */
  123045. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  123046. private _scene;
  123047. private _multiRenderTarget;
  123048. private _ratio;
  123049. private _enablePosition;
  123050. private _enableVelocity;
  123051. private _positionIndex;
  123052. private _velocityIndex;
  123053. protected _effect: Effect;
  123054. protected _cachedDefines: string;
  123055. /**
  123056. * Set the render list (meshes to be rendered) used in the G buffer.
  123057. */
  123058. renderList: Mesh[];
  123059. /**
  123060. * Gets wether or not G buffer are supported by the running hardware.
  123061. * This requires draw buffer supports
  123062. */
  123063. readonly isSupported: boolean;
  123064. /**
  123065. * Returns the index of the given texture type in the G-Buffer textures array
  123066. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  123067. * @returns the index of the given texture type in the G-Buffer textures array
  123068. */
  123069. getTextureIndex(textureType: number): number;
  123070. /**
  123071. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  123072. */
  123073. /**
  123074. * Sets whether or not objects positions are enabled for the G buffer.
  123075. */
  123076. enablePosition: boolean;
  123077. /**
  123078. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  123079. */
  123080. /**
  123081. * Sets wether or not objects velocities are enabled for the G buffer.
  123082. */
  123083. enableVelocity: boolean;
  123084. /**
  123085. * Gets the scene associated with the buffer.
  123086. */
  123087. readonly scene: Scene;
  123088. /**
  123089. * Gets the ratio used by the buffer during its creation.
  123090. * How big is the buffer related to the main canvas.
  123091. */
  123092. readonly ratio: number;
  123093. /** @hidden */
  123094. static _SceneComponentInitialization: (scene: Scene) => void;
  123095. /**
  123096. * Creates a new G Buffer for the scene
  123097. * @param scene The scene the buffer belongs to
  123098. * @param ratio How big is the buffer related to the main canvas.
  123099. */
  123100. constructor(scene: Scene, ratio?: number);
  123101. /**
  123102. * Checks wether everything is ready to render a submesh to the G buffer.
  123103. * @param subMesh the submesh to check readiness for
  123104. * @param useInstances is the mesh drawn using instance or not
  123105. * @returns true if ready otherwise false
  123106. */
  123107. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123108. /**
  123109. * Gets the current underlying G Buffer.
  123110. * @returns the buffer
  123111. */
  123112. getGBuffer(): MultiRenderTarget;
  123113. /**
  123114. * Gets the number of samples used to render the buffer (anti aliasing).
  123115. */
  123116. /**
  123117. * Sets the number of samples used to render the buffer (anti aliasing).
  123118. */
  123119. samples: number;
  123120. /**
  123121. * Disposes the renderer and frees up associated resources.
  123122. */
  123123. dispose(): void;
  123124. protected _createRenderTargets(): void;
  123125. private _copyBonesTransformationMatrices;
  123126. }
  123127. }
  123128. declare module BABYLON {
  123129. interface Scene {
  123130. /** @hidden (Backing field) */
  123131. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123132. /**
  123133. * Gets or Sets the current geometry buffer associated to the scene.
  123134. */
  123135. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123136. /**
  123137. * Enables a GeometryBufferRender and associates it with the scene
  123138. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  123139. * @returns the GeometryBufferRenderer
  123140. */
  123141. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  123142. /**
  123143. * Disables the GeometryBufferRender associated with the scene
  123144. */
  123145. disableGeometryBufferRenderer(): void;
  123146. }
  123147. /**
  123148. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  123149. * in several rendering techniques.
  123150. */
  123151. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  123152. /**
  123153. * The component name helpful to identify the component in the list of scene components.
  123154. */
  123155. readonly name: string;
  123156. /**
  123157. * The scene the component belongs to.
  123158. */
  123159. scene: Scene;
  123160. /**
  123161. * Creates a new instance of the component for the given scene
  123162. * @param scene Defines the scene to register the component in
  123163. */
  123164. constructor(scene: Scene);
  123165. /**
  123166. * Registers the component in a given scene
  123167. */
  123168. register(): void;
  123169. /**
  123170. * Rebuilds the elements related to this component in case of
  123171. * context lost for instance.
  123172. */
  123173. rebuild(): void;
  123174. /**
  123175. * Disposes the component and the associated ressources
  123176. */
  123177. dispose(): void;
  123178. private _gatherRenderTargets;
  123179. }
  123180. }
  123181. declare module BABYLON {
  123182. /** @hidden */
  123183. export var motionBlurPixelShader: {
  123184. name: string;
  123185. shader: string;
  123186. };
  123187. }
  123188. declare module BABYLON {
  123189. /**
  123190. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  123191. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  123192. * As an example, all you have to do is to create the post-process:
  123193. * var mb = new BABYLON.MotionBlurPostProcess(
  123194. * 'mb', // The name of the effect.
  123195. * scene, // The scene containing the objects to blur according to their velocity.
  123196. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  123197. * camera // The camera to apply the render pass to.
  123198. * );
  123199. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  123200. */
  123201. export class MotionBlurPostProcess extends PostProcess {
  123202. /**
  123203. * Defines how much the image is blurred by the movement. Default value is equal to 1
  123204. */
  123205. motionStrength: number;
  123206. /**
  123207. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  123208. */
  123209. /**
  123210. * Sets the number of iterations to be used for motion blur quality
  123211. */
  123212. motionBlurSamples: number;
  123213. private _motionBlurSamples;
  123214. private _geometryBufferRenderer;
  123215. /**
  123216. * Creates a new instance MotionBlurPostProcess
  123217. * @param name The name of the effect.
  123218. * @param scene The scene containing the objects to blur according to their velocity.
  123219. * @param options The required width/height ratio to downsize to before computing the render pass.
  123220. * @param camera The camera to apply the render pass to.
  123221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123222. * @param engine The engine which the post process will be applied. (default: current engine)
  123223. * @param reusable If the post process can be reused on the same frame. (default: false)
  123224. * @param textureType Type of textures used when performing the post process. (default: 0)
  123225. * @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)
  123226. */
  123227. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123228. /**
  123229. * Excludes the given skinned mesh from computing bones velocities.
  123230. * 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.
  123231. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  123232. */
  123233. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  123234. /**
  123235. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  123236. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  123237. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  123238. */
  123239. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  123240. /**
  123241. * Disposes the post process.
  123242. * @param camera The camera to dispose the post process on.
  123243. */
  123244. dispose(camera?: Camera): void;
  123245. }
  123246. }
  123247. declare module BABYLON {
  123248. /** @hidden */
  123249. export var refractionPixelShader: {
  123250. name: string;
  123251. shader: string;
  123252. };
  123253. }
  123254. declare module BABYLON {
  123255. /**
  123256. * Post process which applies a refractin texture
  123257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123258. */
  123259. export class RefractionPostProcess extends PostProcess {
  123260. /** the base color of the refraction (used to taint the rendering) */
  123261. color: Color3;
  123262. /** simulated refraction depth */
  123263. depth: number;
  123264. /** the coefficient of the base color (0 to remove base color tainting) */
  123265. colorLevel: number;
  123266. private _refTexture;
  123267. private _ownRefractionTexture;
  123268. /**
  123269. * Gets or sets the refraction texture
  123270. * Please note that you are responsible for disposing the texture if you set it manually
  123271. */
  123272. refractionTexture: Texture;
  123273. /**
  123274. * Initializes the RefractionPostProcess
  123275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123276. * @param name The name of the effect.
  123277. * @param refractionTextureUrl Url of the refraction texture to use
  123278. * @param color the base color of the refraction (used to taint the rendering)
  123279. * @param depth simulated refraction depth
  123280. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  123281. * @param camera The camera to apply the render pass to.
  123282. * @param options The required width/height ratio to downsize to before computing the render pass.
  123283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123284. * @param engine The engine which the post process will be applied. (default: current engine)
  123285. * @param reusable If the post process can be reused on the same frame. (default: false)
  123286. */
  123287. constructor(name: string, refractionTextureUrl: string,
  123288. /** the base color of the refraction (used to taint the rendering) */
  123289. color: Color3,
  123290. /** simulated refraction depth */
  123291. depth: number,
  123292. /** the coefficient of the base color (0 to remove base color tainting) */
  123293. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123294. /**
  123295. * Disposes of the post process
  123296. * @param camera Camera to dispose post process on
  123297. */
  123298. dispose(camera: Camera): void;
  123299. }
  123300. }
  123301. declare module BABYLON {
  123302. /** @hidden */
  123303. export var sharpenPixelShader: {
  123304. name: string;
  123305. shader: string;
  123306. };
  123307. }
  123308. declare module BABYLON {
  123309. /**
  123310. * The SharpenPostProcess applies a sharpen kernel to every pixel
  123311. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123312. */
  123313. export class SharpenPostProcess extends PostProcess {
  123314. /**
  123315. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  123316. */
  123317. colorAmount: number;
  123318. /**
  123319. * How much sharpness should be applied (default: 0.3)
  123320. */
  123321. edgeAmount: number;
  123322. /**
  123323. * Creates a new instance ConvolutionPostProcess
  123324. * @param name The name of the effect.
  123325. * @param options The required width/height ratio to downsize to before computing the render pass.
  123326. * @param camera The camera to apply the render pass to.
  123327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123328. * @param engine The engine which the post process will be applied. (default: current engine)
  123329. * @param reusable If the post process can be reused on the same frame. (default: false)
  123330. * @param textureType Type of textures used when performing the post process. (default: 0)
  123331. * @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)
  123332. */
  123333. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123334. }
  123335. }
  123336. declare module BABYLON {
  123337. /**
  123338. * PostProcessRenderPipeline
  123339. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123340. */
  123341. export class PostProcessRenderPipeline {
  123342. private engine;
  123343. private _renderEffects;
  123344. private _renderEffectsForIsolatedPass;
  123345. /**
  123346. * List of inspectable custom properties (used by the Inspector)
  123347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  123348. */
  123349. inspectableCustomProperties: IInspectable[];
  123350. /**
  123351. * @hidden
  123352. */
  123353. protected _cameras: Camera[];
  123354. /** @hidden */
  123355. _name: string;
  123356. /**
  123357. * Gets pipeline name
  123358. */
  123359. readonly name: string;
  123360. /**
  123361. * Initializes a PostProcessRenderPipeline
  123362. * @param engine engine to add the pipeline to
  123363. * @param name name of the pipeline
  123364. */
  123365. constructor(engine: Engine, name: string);
  123366. /**
  123367. * Gets the class name
  123368. * @returns "PostProcessRenderPipeline"
  123369. */
  123370. getClassName(): string;
  123371. /**
  123372. * If all the render effects in the pipeline are supported
  123373. */
  123374. readonly isSupported: boolean;
  123375. /**
  123376. * Adds an effect to the pipeline
  123377. * @param renderEffect the effect to add
  123378. */
  123379. addEffect(renderEffect: PostProcessRenderEffect): void;
  123380. /** @hidden */
  123381. _rebuild(): void;
  123382. /** @hidden */
  123383. _enableEffect(renderEffectName: string, cameras: Camera): void;
  123384. /** @hidden */
  123385. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  123386. /** @hidden */
  123387. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123388. /** @hidden */
  123389. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123390. /** @hidden */
  123391. _attachCameras(cameras: Camera, unique: boolean): void;
  123392. /** @hidden */
  123393. _attachCameras(cameras: Camera[], unique: boolean): void;
  123394. /** @hidden */
  123395. _detachCameras(cameras: Camera): void;
  123396. /** @hidden */
  123397. _detachCameras(cameras: Nullable<Camera[]>): void;
  123398. /** @hidden */
  123399. _update(): void;
  123400. /** @hidden */
  123401. _reset(): void;
  123402. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  123403. /**
  123404. * Disposes of the pipeline
  123405. */
  123406. dispose(): void;
  123407. }
  123408. }
  123409. declare module BABYLON {
  123410. /**
  123411. * PostProcessRenderPipelineManager class
  123412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123413. */
  123414. export class PostProcessRenderPipelineManager {
  123415. private _renderPipelines;
  123416. /**
  123417. * Initializes a PostProcessRenderPipelineManager
  123418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123419. */
  123420. constructor();
  123421. /**
  123422. * Gets the list of supported render pipelines
  123423. */
  123424. readonly supportedPipelines: PostProcessRenderPipeline[];
  123425. /**
  123426. * Adds a pipeline to the manager
  123427. * @param renderPipeline The pipeline to add
  123428. */
  123429. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  123430. /**
  123431. * Attaches a camera to the pipeline
  123432. * @param renderPipelineName The name of the pipeline to attach to
  123433. * @param cameras the camera to attach
  123434. * @param unique if the camera can be attached multiple times to the pipeline
  123435. */
  123436. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  123437. /**
  123438. * Detaches a camera from the pipeline
  123439. * @param renderPipelineName The name of the pipeline to detach from
  123440. * @param cameras the camera to detach
  123441. */
  123442. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  123443. /**
  123444. * Enables an effect by name on a pipeline
  123445. * @param renderPipelineName the name of the pipeline to enable the effect in
  123446. * @param renderEffectName the name of the effect to enable
  123447. * @param cameras the cameras that the effect should be enabled on
  123448. */
  123449. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123450. /**
  123451. * Disables an effect by name on a pipeline
  123452. * @param renderPipelineName the name of the pipeline to disable the effect in
  123453. * @param renderEffectName the name of the effect to disable
  123454. * @param cameras the cameras that the effect should be disabled on
  123455. */
  123456. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123457. /**
  123458. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  123459. */
  123460. update(): void;
  123461. /** @hidden */
  123462. _rebuild(): void;
  123463. /**
  123464. * Disposes of the manager and pipelines
  123465. */
  123466. dispose(): void;
  123467. }
  123468. }
  123469. declare module BABYLON {
  123470. interface Scene {
  123471. /** @hidden (Backing field) */
  123472. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123473. /**
  123474. * Gets the postprocess render pipeline manager
  123475. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123476. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123477. */
  123478. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123479. }
  123480. /**
  123481. * Defines the Render Pipeline scene component responsible to rendering pipelines
  123482. */
  123483. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  123484. /**
  123485. * The component name helpfull to identify the component in the list of scene components.
  123486. */
  123487. readonly name: string;
  123488. /**
  123489. * The scene the component belongs to.
  123490. */
  123491. scene: Scene;
  123492. /**
  123493. * Creates a new instance of the component for the given scene
  123494. * @param scene Defines the scene to register the component in
  123495. */
  123496. constructor(scene: Scene);
  123497. /**
  123498. * Registers the component in a given scene
  123499. */
  123500. register(): void;
  123501. /**
  123502. * Rebuilds the elements related to this component in case of
  123503. * context lost for instance.
  123504. */
  123505. rebuild(): void;
  123506. /**
  123507. * Disposes the component and the associated ressources
  123508. */
  123509. dispose(): void;
  123510. private _gatherRenderTargets;
  123511. }
  123512. }
  123513. declare module BABYLON {
  123514. /**
  123515. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  123516. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123517. */
  123518. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123519. private _scene;
  123520. private _camerasToBeAttached;
  123521. /**
  123522. * ID of the sharpen post process,
  123523. */
  123524. private readonly SharpenPostProcessId;
  123525. /**
  123526. * @ignore
  123527. * ID of the image processing post process;
  123528. */
  123529. readonly ImageProcessingPostProcessId: string;
  123530. /**
  123531. * @ignore
  123532. * ID of the Fast Approximate Anti-Aliasing post process;
  123533. */
  123534. readonly FxaaPostProcessId: string;
  123535. /**
  123536. * ID of the chromatic aberration post process,
  123537. */
  123538. private readonly ChromaticAberrationPostProcessId;
  123539. /**
  123540. * ID of the grain post process
  123541. */
  123542. private readonly GrainPostProcessId;
  123543. /**
  123544. * Sharpen post process which will apply a sharpen convolution to enhance edges
  123545. */
  123546. sharpen: SharpenPostProcess;
  123547. private _sharpenEffect;
  123548. private bloom;
  123549. /**
  123550. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  123551. */
  123552. depthOfField: DepthOfFieldEffect;
  123553. /**
  123554. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123555. */
  123556. fxaa: FxaaPostProcess;
  123557. /**
  123558. * Image post processing pass used to perform operations such as tone mapping or color grading.
  123559. */
  123560. imageProcessing: ImageProcessingPostProcess;
  123561. /**
  123562. * Chromatic aberration post process which will shift rgb colors in the image
  123563. */
  123564. chromaticAberration: ChromaticAberrationPostProcess;
  123565. private _chromaticAberrationEffect;
  123566. /**
  123567. * Grain post process which add noise to the image
  123568. */
  123569. grain: GrainPostProcess;
  123570. private _grainEffect;
  123571. /**
  123572. * Glow post process which adds a glow to emissive areas of the image
  123573. */
  123574. private _glowLayer;
  123575. /**
  123576. * Animations which can be used to tweak settings over a period of time
  123577. */
  123578. animations: Animation[];
  123579. private _imageProcessingConfigurationObserver;
  123580. private _sharpenEnabled;
  123581. private _bloomEnabled;
  123582. private _depthOfFieldEnabled;
  123583. private _depthOfFieldBlurLevel;
  123584. private _fxaaEnabled;
  123585. private _imageProcessingEnabled;
  123586. private _defaultPipelineTextureType;
  123587. private _bloomScale;
  123588. private _chromaticAberrationEnabled;
  123589. private _grainEnabled;
  123590. private _buildAllowed;
  123591. /**
  123592. * Gets active scene
  123593. */
  123594. readonly scene: Scene;
  123595. /**
  123596. * Enable or disable the sharpen process from the pipeline
  123597. */
  123598. sharpenEnabled: boolean;
  123599. private _resizeObserver;
  123600. private _hardwareScaleLevel;
  123601. private _bloomKernel;
  123602. /**
  123603. * Specifies the size of the bloom blur kernel, relative to the final output size
  123604. */
  123605. bloomKernel: number;
  123606. /**
  123607. * Specifies the weight of the bloom in the final rendering
  123608. */
  123609. private _bloomWeight;
  123610. /**
  123611. * Specifies the luma threshold for the area that will be blurred by the bloom
  123612. */
  123613. private _bloomThreshold;
  123614. private _hdr;
  123615. /**
  123616. * The strength of the bloom.
  123617. */
  123618. bloomWeight: number;
  123619. /**
  123620. * The strength of the bloom.
  123621. */
  123622. bloomThreshold: number;
  123623. /**
  123624. * The scale of the bloom, lower value will provide better performance.
  123625. */
  123626. bloomScale: number;
  123627. /**
  123628. * Enable or disable the bloom from the pipeline
  123629. */
  123630. bloomEnabled: boolean;
  123631. private _rebuildBloom;
  123632. /**
  123633. * If the depth of field is enabled.
  123634. */
  123635. depthOfFieldEnabled: boolean;
  123636. /**
  123637. * Blur level of the depth of field effect. (Higher blur will effect performance)
  123638. */
  123639. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  123640. /**
  123641. * If the anti aliasing is enabled.
  123642. */
  123643. fxaaEnabled: boolean;
  123644. private _samples;
  123645. /**
  123646. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123647. */
  123648. samples: number;
  123649. /**
  123650. * If image processing is enabled.
  123651. */
  123652. imageProcessingEnabled: boolean;
  123653. /**
  123654. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  123655. */
  123656. glowLayerEnabled: boolean;
  123657. /**
  123658. * Gets the glow layer (or null if not defined)
  123659. */
  123660. readonly glowLayer: Nullable<GlowLayer>;
  123661. /**
  123662. * Enable or disable the chromaticAberration process from the pipeline
  123663. */
  123664. chromaticAberrationEnabled: boolean;
  123665. /**
  123666. * Enable or disable the grain process from the pipeline
  123667. */
  123668. grainEnabled: boolean;
  123669. /**
  123670. * @constructor
  123671. * @param name - The rendering pipeline name (default: "")
  123672. * @param hdr - If high dynamic range textures should be used (default: true)
  123673. * @param scene - The scene linked to this pipeline (default: the last created scene)
  123674. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  123675. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  123676. */
  123677. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  123678. /**
  123679. * Get the class name
  123680. * @returns "DefaultRenderingPipeline"
  123681. */
  123682. getClassName(): string;
  123683. /**
  123684. * Force the compilation of the entire pipeline.
  123685. */
  123686. prepare(): void;
  123687. private _hasCleared;
  123688. private _prevPostProcess;
  123689. private _prevPrevPostProcess;
  123690. private _setAutoClearAndTextureSharing;
  123691. private _depthOfFieldSceneObserver;
  123692. private _buildPipeline;
  123693. private _disposePostProcesses;
  123694. /**
  123695. * Adds a camera to the pipeline
  123696. * @param camera the camera to be added
  123697. */
  123698. addCamera(camera: Camera): void;
  123699. /**
  123700. * Removes a camera from the pipeline
  123701. * @param camera the camera to remove
  123702. */
  123703. removeCamera(camera: Camera): void;
  123704. /**
  123705. * Dispose of the pipeline and stop all post processes
  123706. */
  123707. dispose(): void;
  123708. /**
  123709. * Serialize the rendering pipeline (Used when exporting)
  123710. * @returns the serialized object
  123711. */
  123712. serialize(): any;
  123713. /**
  123714. * Parse the serialized pipeline
  123715. * @param source Source pipeline.
  123716. * @param scene The scene to load the pipeline to.
  123717. * @param rootUrl The URL of the serialized pipeline.
  123718. * @returns An instantiated pipeline from the serialized object.
  123719. */
  123720. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  123721. }
  123722. }
  123723. declare module BABYLON {
  123724. /** @hidden */
  123725. export var lensHighlightsPixelShader: {
  123726. name: string;
  123727. shader: string;
  123728. };
  123729. }
  123730. declare module BABYLON {
  123731. /** @hidden */
  123732. export var depthOfFieldPixelShader: {
  123733. name: string;
  123734. shader: string;
  123735. };
  123736. }
  123737. declare module BABYLON {
  123738. /**
  123739. * BABYLON.JS Chromatic Aberration GLSL Shader
  123740. * Author: Olivier Guyot
  123741. * Separates very slightly R, G and B colors on the edges of the screen
  123742. * Inspired by Francois Tarlier & Martins Upitis
  123743. */
  123744. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  123745. /**
  123746. * @ignore
  123747. * The chromatic aberration PostProcess id in the pipeline
  123748. */
  123749. LensChromaticAberrationEffect: string;
  123750. /**
  123751. * @ignore
  123752. * The highlights enhancing PostProcess id in the pipeline
  123753. */
  123754. HighlightsEnhancingEffect: string;
  123755. /**
  123756. * @ignore
  123757. * The depth-of-field PostProcess id in the pipeline
  123758. */
  123759. LensDepthOfFieldEffect: string;
  123760. private _scene;
  123761. private _depthTexture;
  123762. private _grainTexture;
  123763. private _chromaticAberrationPostProcess;
  123764. private _highlightsPostProcess;
  123765. private _depthOfFieldPostProcess;
  123766. private _edgeBlur;
  123767. private _grainAmount;
  123768. private _chromaticAberration;
  123769. private _distortion;
  123770. private _highlightsGain;
  123771. private _highlightsThreshold;
  123772. private _dofDistance;
  123773. private _dofAperture;
  123774. private _dofDarken;
  123775. private _dofPentagon;
  123776. private _blurNoise;
  123777. /**
  123778. * @constructor
  123779. *
  123780. * Effect parameters are as follow:
  123781. * {
  123782. * chromatic_aberration: number; // from 0 to x (1 for realism)
  123783. * edge_blur: number; // from 0 to x (1 for realism)
  123784. * distortion: number; // from 0 to x (1 for realism)
  123785. * grain_amount: number; // from 0 to 1
  123786. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  123787. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  123788. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  123789. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  123790. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  123791. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  123792. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  123793. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  123794. * }
  123795. * Note: if an effect parameter is unset, effect is disabled
  123796. *
  123797. * @param name The rendering pipeline name
  123798. * @param parameters - An object containing all parameters (see above)
  123799. * @param scene The scene linked to this pipeline
  123800. * @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)
  123801. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123802. */
  123803. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  123804. /**
  123805. * Get the class name
  123806. * @returns "LensRenderingPipeline"
  123807. */
  123808. getClassName(): string;
  123809. /**
  123810. * Gets associated scene
  123811. */
  123812. readonly scene: Scene;
  123813. /**
  123814. * Gets or sets the edge blur
  123815. */
  123816. edgeBlur: number;
  123817. /**
  123818. * Gets or sets the grain amount
  123819. */
  123820. grainAmount: number;
  123821. /**
  123822. * Gets or sets the chromatic aberration amount
  123823. */
  123824. chromaticAberration: number;
  123825. /**
  123826. * Gets or sets the depth of field aperture
  123827. */
  123828. dofAperture: number;
  123829. /**
  123830. * Gets or sets the edge distortion
  123831. */
  123832. edgeDistortion: number;
  123833. /**
  123834. * Gets or sets the depth of field distortion
  123835. */
  123836. dofDistortion: number;
  123837. /**
  123838. * Gets or sets the darken out of focus amount
  123839. */
  123840. darkenOutOfFocus: number;
  123841. /**
  123842. * Gets or sets a boolean indicating if blur noise is enabled
  123843. */
  123844. blurNoise: boolean;
  123845. /**
  123846. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  123847. */
  123848. pentagonBokeh: boolean;
  123849. /**
  123850. * Gets or sets the highlight grain amount
  123851. */
  123852. highlightsGain: number;
  123853. /**
  123854. * Gets or sets the highlight threshold
  123855. */
  123856. highlightsThreshold: number;
  123857. /**
  123858. * Sets the amount of blur at the edges
  123859. * @param amount blur amount
  123860. */
  123861. setEdgeBlur(amount: number): void;
  123862. /**
  123863. * Sets edge blur to 0
  123864. */
  123865. disableEdgeBlur(): void;
  123866. /**
  123867. * Sets the amout of grain
  123868. * @param amount Amount of grain
  123869. */
  123870. setGrainAmount(amount: number): void;
  123871. /**
  123872. * Set grain amount to 0
  123873. */
  123874. disableGrain(): void;
  123875. /**
  123876. * Sets the chromatic aberration amount
  123877. * @param amount amount of chromatic aberration
  123878. */
  123879. setChromaticAberration(amount: number): void;
  123880. /**
  123881. * Sets chromatic aberration amount to 0
  123882. */
  123883. disableChromaticAberration(): void;
  123884. /**
  123885. * Sets the EdgeDistortion amount
  123886. * @param amount amount of EdgeDistortion
  123887. */
  123888. setEdgeDistortion(amount: number): void;
  123889. /**
  123890. * Sets edge distortion to 0
  123891. */
  123892. disableEdgeDistortion(): void;
  123893. /**
  123894. * Sets the FocusDistance amount
  123895. * @param amount amount of FocusDistance
  123896. */
  123897. setFocusDistance(amount: number): void;
  123898. /**
  123899. * Disables depth of field
  123900. */
  123901. disableDepthOfField(): void;
  123902. /**
  123903. * Sets the Aperture amount
  123904. * @param amount amount of Aperture
  123905. */
  123906. setAperture(amount: number): void;
  123907. /**
  123908. * Sets the DarkenOutOfFocus amount
  123909. * @param amount amount of DarkenOutOfFocus
  123910. */
  123911. setDarkenOutOfFocus(amount: number): void;
  123912. private _pentagonBokehIsEnabled;
  123913. /**
  123914. * Creates a pentagon bokeh effect
  123915. */
  123916. enablePentagonBokeh(): void;
  123917. /**
  123918. * Disables the pentagon bokeh effect
  123919. */
  123920. disablePentagonBokeh(): void;
  123921. /**
  123922. * Enables noise blur
  123923. */
  123924. enableNoiseBlur(): void;
  123925. /**
  123926. * Disables noise blur
  123927. */
  123928. disableNoiseBlur(): void;
  123929. /**
  123930. * Sets the HighlightsGain amount
  123931. * @param amount amount of HighlightsGain
  123932. */
  123933. setHighlightsGain(amount: number): void;
  123934. /**
  123935. * Sets the HighlightsThreshold amount
  123936. * @param amount amount of HighlightsThreshold
  123937. */
  123938. setHighlightsThreshold(amount: number): void;
  123939. /**
  123940. * Disables highlights
  123941. */
  123942. disableHighlights(): void;
  123943. /**
  123944. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  123945. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  123946. */
  123947. dispose(disableDepthRender?: boolean): void;
  123948. private _createChromaticAberrationPostProcess;
  123949. private _createHighlightsPostProcess;
  123950. private _createDepthOfFieldPostProcess;
  123951. private _createGrainTexture;
  123952. }
  123953. }
  123954. declare module BABYLON {
  123955. /** @hidden */
  123956. export var ssao2PixelShader: {
  123957. name: string;
  123958. shader: string;
  123959. };
  123960. }
  123961. declare module BABYLON {
  123962. /** @hidden */
  123963. export var ssaoCombinePixelShader: {
  123964. name: string;
  123965. shader: string;
  123966. };
  123967. }
  123968. declare module BABYLON {
  123969. /**
  123970. * Render pipeline to produce ssao effect
  123971. */
  123972. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  123973. /**
  123974. * @ignore
  123975. * The PassPostProcess id in the pipeline that contains the original scene color
  123976. */
  123977. SSAOOriginalSceneColorEffect: string;
  123978. /**
  123979. * @ignore
  123980. * The SSAO PostProcess id in the pipeline
  123981. */
  123982. SSAORenderEffect: string;
  123983. /**
  123984. * @ignore
  123985. * The horizontal blur PostProcess id in the pipeline
  123986. */
  123987. SSAOBlurHRenderEffect: string;
  123988. /**
  123989. * @ignore
  123990. * The vertical blur PostProcess id in the pipeline
  123991. */
  123992. SSAOBlurVRenderEffect: string;
  123993. /**
  123994. * @ignore
  123995. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123996. */
  123997. SSAOCombineRenderEffect: string;
  123998. /**
  123999. * The output strength of the SSAO post-process. Default value is 1.0.
  124000. */
  124001. totalStrength: number;
  124002. /**
  124003. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  124004. */
  124005. maxZ: number;
  124006. /**
  124007. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  124008. */
  124009. minZAspect: number;
  124010. private _samples;
  124011. /**
  124012. * Number of samples used for the SSAO calculations. Default value is 8
  124013. */
  124014. samples: number;
  124015. private _textureSamples;
  124016. /**
  124017. * Number of samples to use for antialiasing
  124018. */
  124019. textureSamples: number;
  124020. /**
  124021. * Ratio object used for SSAO ratio and blur ratio
  124022. */
  124023. private _ratio;
  124024. /**
  124025. * Dynamically generated sphere sampler.
  124026. */
  124027. private _sampleSphere;
  124028. /**
  124029. * Blur filter offsets
  124030. */
  124031. private _samplerOffsets;
  124032. private _expensiveBlur;
  124033. /**
  124034. * If bilateral blur should be used
  124035. */
  124036. expensiveBlur: boolean;
  124037. /**
  124038. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  124039. */
  124040. radius: number;
  124041. /**
  124042. * The base color of the SSAO post-process
  124043. * The final result is "base + ssao" between [0, 1]
  124044. */
  124045. base: number;
  124046. /**
  124047. * Support test.
  124048. */
  124049. static readonly IsSupported: boolean;
  124050. private _scene;
  124051. private _depthTexture;
  124052. private _normalTexture;
  124053. private _randomTexture;
  124054. private _originalColorPostProcess;
  124055. private _ssaoPostProcess;
  124056. private _blurHPostProcess;
  124057. private _blurVPostProcess;
  124058. private _ssaoCombinePostProcess;
  124059. private _firstUpdate;
  124060. /**
  124061. * Gets active scene
  124062. */
  124063. readonly scene: Scene;
  124064. /**
  124065. * @constructor
  124066. * @param name The rendering pipeline name
  124067. * @param scene The scene linked to this pipeline
  124068. * @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 }
  124069. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124070. */
  124071. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  124072. /**
  124073. * Get the class name
  124074. * @returns "SSAO2RenderingPipeline"
  124075. */
  124076. getClassName(): string;
  124077. /**
  124078. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  124079. */
  124080. dispose(disableGeometryBufferRenderer?: boolean): void;
  124081. private _createBlurPostProcess;
  124082. /** @hidden */
  124083. _rebuild(): void;
  124084. private _bits;
  124085. private _radicalInverse_VdC;
  124086. private _hammersley;
  124087. private _hemisphereSample_uniform;
  124088. private _generateHemisphere;
  124089. private _createSSAOPostProcess;
  124090. private _createSSAOCombinePostProcess;
  124091. private _createRandomTexture;
  124092. /**
  124093. * Serialize the rendering pipeline (Used when exporting)
  124094. * @returns the serialized object
  124095. */
  124096. serialize(): any;
  124097. /**
  124098. * Parse the serialized pipeline
  124099. * @param source Source pipeline.
  124100. * @param scene The scene to load the pipeline to.
  124101. * @param rootUrl The URL of the serialized pipeline.
  124102. * @returns An instantiated pipeline from the serialized object.
  124103. */
  124104. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  124105. }
  124106. }
  124107. declare module BABYLON {
  124108. /** @hidden */
  124109. export var ssaoPixelShader: {
  124110. name: string;
  124111. shader: string;
  124112. };
  124113. }
  124114. declare module BABYLON {
  124115. /**
  124116. * Render pipeline to produce ssao effect
  124117. */
  124118. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  124119. /**
  124120. * @ignore
  124121. * The PassPostProcess id in the pipeline that contains the original scene color
  124122. */
  124123. SSAOOriginalSceneColorEffect: string;
  124124. /**
  124125. * @ignore
  124126. * The SSAO PostProcess id in the pipeline
  124127. */
  124128. SSAORenderEffect: string;
  124129. /**
  124130. * @ignore
  124131. * The horizontal blur PostProcess id in the pipeline
  124132. */
  124133. SSAOBlurHRenderEffect: string;
  124134. /**
  124135. * @ignore
  124136. * The vertical blur PostProcess id in the pipeline
  124137. */
  124138. SSAOBlurVRenderEffect: string;
  124139. /**
  124140. * @ignore
  124141. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  124142. */
  124143. SSAOCombineRenderEffect: string;
  124144. /**
  124145. * The output strength of the SSAO post-process. Default value is 1.0.
  124146. */
  124147. totalStrength: number;
  124148. /**
  124149. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  124150. */
  124151. radius: number;
  124152. /**
  124153. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  124154. * Must not be equal to fallOff and superior to fallOff.
  124155. * Default value is 0.0075
  124156. */
  124157. area: number;
  124158. /**
  124159. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  124160. * Must not be equal to area and inferior to area.
  124161. * Default value is 0.000001
  124162. */
  124163. fallOff: number;
  124164. /**
  124165. * The base color of the SSAO post-process
  124166. * The final result is "base + ssao" between [0, 1]
  124167. */
  124168. base: number;
  124169. private _scene;
  124170. private _depthTexture;
  124171. private _randomTexture;
  124172. private _originalColorPostProcess;
  124173. private _ssaoPostProcess;
  124174. private _blurHPostProcess;
  124175. private _blurVPostProcess;
  124176. private _ssaoCombinePostProcess;
  124177. private _firstUpdate;
  124178. /**
  124179. * Gets active scene
  124180. */
  124181. readonly scene: Scene;
  124182. /**
  124183. * @constructor
  124184. * @param name - The rendering pipeline name
  124185. * @param scene - The scene linked to this pipeline
  124186. * @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 }
  124187. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  124188. */
  124189. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  124190. /**
  124191. * Get the class name
  124192. * @returns "SSAORenderingPipeline"
  124193. */
  124194. getClassName(): string;
  124195. /**
  124196. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  124197. */
  124198. dispose(disableDepthRender?: boolean): void;
  124199. private _createBlurPostProcess;
  124200. /** @hidden */
  124201. _rebuild(): void;
  124202. private _createSSAOPostProcess;
  124203. private _createSSAOCombinePostProcess;
  124204. private _createRandomTexture;
  124205. }
  124206. }
  124207. declare module BABYLON {
  124208. /** @hidden */
  124209. export var standardPixelShader: {
  124210. name: string;
  124211. shader: string;
  124212. };
  124213. }
  124214. declare module BABYLON {
  124215. /**
  124216. * Standard rendering pipeline
  124217. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  124218. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  124219. */
  124220. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124221. /**
  124222. * Public members
  124223. */
  124224. /**
  124225. * Post-process which contains the original scene color before the pipeline applies all the effects
  124226. */
  124227. originalPostProcess: Nullable<PostProcess>;
  124228. /**
  124229. * Post-process used to down scale an image x4
  124230. */
  124231. downSampleX4PostProcess: Nullable<PostProcess>;
  124232. /**
  124233. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  124234. */
  124235. brightPassPostProcess: Nullable<PostProcess>;
  124236. /**
  124237. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  124238. */
  124239. blurHPostProcesses: PostProcess[];
  124240. /**
  124241. * Post-process array storing all the vertical blur post-processes used by the pipeline
  124242. */
  124243. blurVPostProcesses: PostProcess[];
  124244. /**
  124245. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  124246. */
  124247. textureAdderPostProcess: Nullable<PostProcess>;
  124248. /**
  124249. * Post-process used to create volumetric lighting effect
  124250. */
  124251. volumetricLightPostProcess: Nullable<PostProcess>;
  124252. /**
  124253. * Post-process used to smooth the previous volumetric light post-process on the X axis
  124254. */
  124255. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  124256. /**
  124257. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  124258. */
  124259. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  124260. /**
  124261. * Post-process used to merge the volumetric light effect and the real scene color
  124262. */
  124263. volumetricLightMergePostProces: Nullable<PostProcess>;
  124264. /**
  124265. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  124266. */
  124267. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  124268. /**
  124269. * Base post-process used to calculate the average luminance of the final image for HDR
  124270. */
  124271. luminancePostProcess: Nullable<PostProcess>;
  124272. /**
  124273. * Post-processes used to create down sample post-processes in order to get
  124274. * the average luminance of the final image for HDR
  124275. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  124276. */
  124277. luminanceDownSamplePostProcesses: PostProcess[];
  124278. /**
  124279. * Post-process used to create a HDR effect (light adaptation)
  124280. */
  124281. hdrPostProcess: Nullable<PostProcess>;
  124282. /**
  124283. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  124284. */
  124285. textureAdderFinalPostProcess: Nullable<PostProcess>;
  124286. /**
  124287. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  124288. */
  124289. lensFlareFinalPostProcess: Nullable<PostProcess>;
  124290. /**
  124291. * Post-process used to merge the final HDR post-process and the real scene color
  124292. */
  124293. hdrFinalPostProcess: Nullable<PostProcess>;
  124294. /**
  124295. * Post-process used to create a lens flare effect
  124296. */
  124297. lensFlarePostProcess: Nullable<PostProcess>;
  124298. /**
  124299. * Post-process that merges the result of the lens flare post-process and the real scene color
  124300. */
  124301. lensFlareComposePostProcess: Nullable<PostProcess>;
  124302. /**
  124303. * Post-process used to create a motion blur effect
  124304. */
  124305. motionBlurPostProcess: Nullable<PostProcess>;
  124306. /**
  124307. * Post-process used to create a depth of field effect
  124308. */
  124309. depthOfFieldPostProcess: Nullable<PostProcess>;
  124310. /**
  124311. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124312. */
  124313. fxaaPostProcess: Nullable<FxaaPostProcess>;
  124314. /**
  124315. * Represents the brightness threshold in order to configure the illuminated surfaces
  124316. */
  124317. brightThreshold: number;
  124318. /**
  124319. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  124320. */
  124321. blurWidth: number;
  124322. /**
  124323. * Sets if the blur for highlighted surfaces must be only horizontal
  124324. */
  124325. horizontalBlur: boolean;
  124326. /**
  124327. * Gets the overall exposure used by the pipeline
  124328. */
  124329. /**
  124330. * Sets the overall exposure used by the pipeline
  124331. */
  124332. exposure: number;
  124333. /**
  124334. * Texture used typically to simulate "dirty" on camera lens
  124335. */
  124336. lensTexture: Nullable<Texture>;
  124337. /**
  124338. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  124339. */
  124340. volumetricLightCoefficient: number;
  124341. /**
  124342. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  124343. */
  124344. volumetricLightPower: number;
  124345. /**
  124346. * Used the set the blur intensity to smooth the volumetric lights
  124347. */
  124348. volumetricLightBlurScale: number;
  124349. /**
  124350. * Light (spot or directional) used to generate the volumetric lights rays
  124351. * The source light must have a shadow generate so the pipeline can get its
  124352. * depth map
  124353. */
  124354. sourceLight: Nullable<SpotLight | DirectionalLight>;
  124355. /**
  124356. * For eye adaptation, represents the minimum luminance the eye can see
  124357. */
  124358. hdrMinimumLuminance: number;
  124359. /**
  124360. * For eye adaptation, represents the decrease luminance speed
  124361. */
  124362. hdrDecreaseRate: number;
  124363. /**
  124364. * For eye adaptation, represents the increase luminance speed
  124365. */
  124366. hdrIncreaseRate: number;
  124367. /**
  124368. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124369. */
  124370. /**
  124371. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124372. */
  124373. hdrAutoExposure: boolean;
  124374. /**
  124375. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  124376. */
  124377. lensColorTexture: Nullable<Texture>;
  124378. /**
  124379. * The overall strengh for the lens flare effect
  124380. */
  124381. lensFlareStrength: number;
  124382. /**
  124383. * Dispersion coefficient for lens flare ghosts
  124384. */
  124385. lensFlareGhostDispersal: number;
  124386. /**
  124387. * Main lens flare halo width
  124388. */
  124389. lensFlareHaloWidth: number;
  124390. /**
  124391. * Based on the lens distortion effect, defines how much the lens flare result
  124392. * is distorted
  124393. */
  124394. lensFlareDistortionStrength: number;
  124395. /**
  124396. * Configures the blur intensity used for for lens flare (halo)
  124397. */
  124398. lensFlareBlurWidth: number;
  124399. /**
  124400. * Lens star texture must be used to simulate rays on the flares and is available
  124401. * in the documentation
  124402. */
  124403. lensStarTexture: Nullable<Texture>;
  124404. /**
  124405. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  124406. * flare effect by taking account of the dirt texture
  124407. */
  124408. lensFlareDirtTexture: Nullable<Texture>;
  124409. /**
  124410. * Represents the focal length for the depth of field effect
  124411. */
  124412. depthOfFieldDistance: number;
  124413. /**
  124414. * Represents the blur intensity for the blurred part of the depth of field effect
  124415. */
  124416. depthOfFieldBlurWidth: number;
  124417. /**
  124418. * Gets how much the image is blurred by the movement while using the motion blur post-process
  124419. */
  124420. /**
  124421. * Sets how much the image is blurred by the movement while using the motion blur post-process
  124422. */
  124423. motionStrength: number;
  124424. /**
  124425. * Gets wether or not the motion blur post-process is object based or screen based.
  124426. */
  124427. /**
  124428. * Sets wether or not the motion blur post-process should be object based or screen based
  124429. */
  124430. objectBasedMotionBlur: boolean;
  124431. /**
  124432. * List of animations for the pipeline (IAnimatable implementation)
  124433. */
  124434. animations: Animation[];
  124435. /**
  124436. * Private members
  124437. */
  124438. private _scene;
  124439. private _currentDepthOfFieldSource;
  124440. private _basePostProcess;
  124441. private _fixedExposure;
  124442. private _currentExposure;
  124443. private _hdrAutoExposure;
  124444. private _hdrCurrentLuminance;
  124445. private _motionStrength;
  124446. private _isObjectBasedMotionBlur;
  124447. private _floatTextureType;
  124448. private _camerasToBeAttached;
  124449. private _ratio;
  124450. private _bloomEnabled;
  124451. private _depthOfFieldEnabled;
  124452. private _vlsEnabled;
  124453. private _lensFlareEnabled;
  124454. private _hdrEnabled;
  124455. private _motionBlurEnabled;
  124456. private _fxaaEnabled;
  124457. private _motionBlurSamples;
  124458. private _volumetricLightStepsCount;
  124459. private _samples;
  124460. /**
  124461. * @ignore
  124462. * Specifies if the bloom pipeline is enabled
  124463. */
  124464. BloomEnabled: boolean;
  124465. /**
  124466. * @ignore
  124467. * Specifies if the depth of field pipeline is enabed
  124468. */
  124469. DepthOfFieldEnabled: boolean;
  124470. /**
  124471. * @ignore
  124472. * Specifies if the lens flare pipeline is enabed
  124473. */
  124474. LensFlareEnabled: boolean;
  124475. /**
  124476. * @ignore
  124477. * Specifies if the HDR pipeline is enabled
  124478. */
  124479. HDREnabled: boolean;
  124480. /**
  124481. * @ignore
  124482. * Specifies if the volumetric lights scattering effect is enabled
  124483. */
  124484. VLSEnabled: boolean;
  124485. /**
  124486. * @ignore
  124487. * Specifies if the motion blur effect is enabled
  124488. */
  124489. MotionBlurEnabled: boolean;
  124490. /**
  124491. * Specifies if anti-aliasing is enabled
  124492. */
  124493. fxaaEnabled: boolean;
  124494. /**
  124495. * Specifies the number of steps used to calculate the volumetric lights
  124496. * Typically in interval [50, 200]
  124497. */
  124498. volumetricLightStepsCount: number;
  124499. /**
  124500. * Specifies the number of samples used for the motion blur effect
  124501. * Typically in interval [16, 64]
  124502. */
  124503. motionBlurSamples: number;
  124504. /**
  124505. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124506. */
  124507. samples: number;
  124508. /**
  124509. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  124510. * @constructor
  124511. * @param name The rendering pipeline name
  124512. * @param scene The scene linked to this pipeline
  124513. * @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)
  124514. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  124515. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124516. */
  124517. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  124518. private _buildPipeline;
  124519. private _createDownSampleX4PostProcess;
  124520. private _createBrightPassPostProcess;
  124521. private _createBlurPostProcesses;
  124522. private _createTextureAdderPostProcess;
  124523. private _createVolumetricLightPostProcess;
  124524. private _createLuminancePostProcesses;
  124525. private _createHdrPostProcess;
  124526. private _createLensFlarePostProcess;
  124527. private _createDepthOfFieldPostProcess;
  124528. private _createMotionBlurPostProcess;
  124529. private _getDepthTexture;
  124530. private _disposePostProcesses;
  124531. /**
  124532. * Dispose of the pipeline and stop all post processes
  124533. */
  124534. dispose(): void;
  124535. /**
  124536. * Serialize the rendering pipeline (Used when exporting)
  124537. * @returns the serialized object
  124538. */
  124539. serialize(): any;
  124540. /**
  124541. * Parse the serialized pipeline
  124542. * @param source Source pipeline.
  124543. * @param scene The scene to load the pipeline to.
  124544. * @param rootUrl The URL of the serialized pipeline.
  124545. * @returns An instantiated pipeline from the serialized object.
  124546. */
  124547. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  124548. /**
  124549. * Luminance steps
  124550. */
  124551. static LuminanceSteps: number;
  124552. }
  124553. }
  124554. declare module BABYLON {
  124555. /** @hidden */
  124556. export var tonemapPixelShader: {
  124557. name: string;
  124558. shader: string;
  124559. };
  124560. }
  124561. declare module BABYLON {
  124562. /** Defines operator used for tonemapping */
  124563. export enum TonemappingOperator {
  124564. /** Hable */
  124565. Hable = 0,
  124566. /** Reinhard */
  124567. Reinhard = 1,
  124568. /** HejiDawson */
  124569. HejiDawson = 2,
  124570. /** Photographic */
  124571. Photographic = 3
  124572. }
  124573. /**
  124574. * Defines a post process to apply tone mapping
  124575. */
  124576. export class TonemapPostProcess extends PostProcess {
  124577. private _operator;
  124578. /** Defines the required exposure adjustement */
  124579. exposureAdjustment: number;
  124580. /**
  124581. * Creates a new TonemapPostProcess
  124582. * @param name defines the name of the postprocess
  124583. * @param _operator defines the operator to use
  124584. * @param exposureAdjustment defines the required exposure adjustement
  124585. * @param camera defines the camera to use (can be null)
  124586. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  124587. * @param engine defines the hosting engine (can be ignore if camera is set)
  124588. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  124589. */
  124590. constructor(name: string, _operator: TonemappingOperator,
  124591. /** Defines the required exposure adjustement */
  124592. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  124593. }
  124594. }
  124595. declare module BABYLON {
  124596. /** @hidden */
  124597. export var depthVertexShader: {
  124598. name: string;
  124599. shader: string;
  124600. };
  124601. }
  124602. declare module BABYLON {
  124603. /** @hidden */
  124604. export var volumetricLightScatteringPixelShader: {
  124605. name: string;
  124606. shader: string;
  124607. };
  124608. }
  124609. declare module BABYLON {
  124610. /** @hidden */
  124611. export var volumetricLightScatteringPassVertexShader: {
  124612. name: string;
  124613. shader: string;
  124614. };
  124615. }
  124616. declare module BABYLON {
  124617. /** @hidden */
  124618. export var volumetricLightScatteringPassPixelShader: {
  124619. name: string;
  124620. shader: string;
  124621. };
  124622. }
  124623. declare module BABYLON {
  124624. /**
  124625. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  124626. */
  124627. export class VolumetricLightScatteringPostProcess extends PostProcess {
  124628. private _volumetricLightScatteringPass;
  124629. private _volumetricLightScatteringRTT;
  124630. private _viewPort;
  124631. private _screenCoordinates;
  124632. private _cachedDefines;
  124633. /**
  124634. * If not undefined, the mesh position is computed from the attached node position
  124635. */
  124636. attachedNode: {
  124637. position: Vector3;
  124638. };
  124639. /**
  124640. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  124641. */
  124642. customMeshPosition: Vector3;
  124643. /**
  124644. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  124645. */
  124646. useCustomMeshPosition: boolean;
  124647. /**
  124648. * If the post-process should inverse the light scattering direction
  124649. */
  124650. invert: boolean;
  124651. /**
  124652. * The internal mesh used by the post-process
  124653. */
  124654. mesh: Mesh;
  124655. /**
  124656. * @hidden
  124657. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  124658. */
  124659. useDiffuseColor: boolean;
  124660. /**
  124661. * Array containing the excluded meshes not rendered in the internal pass
  124662. */
  124663. excludedMeshes: AbstractMesh[];
  124664. /**
  124665. * Controls the overall intensity of the post-process
  124666. */
  124667. exposure: number;
  124668. /**
  124669. * Dissipates each sample's contribution in range [0, 1]
  124670. */
  124671. decay: number;
  124672. /**
  124673. * Controls the overall intensity of each sample
  124674. */
  124675. weight: number;
  124676. /**
  124677. * Controls the density of each sample
  124678. */
  124679. density: number;
  124680. /**
  124681. * @constructor
  124682. * @param name The post-process name
  124683. * @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)
  124684. * @param camera The camera that the post-process will be attached to
  124685. * @param mesh The mesh used to create the light scattering
  124686. * @param samples The post-process quality, default 100
  124687. * @param samplingModeThe post-process filtering mode
  124688. * @param engine The babylon engine
  124689. * @param reusable If the post-process is reusable
  124690. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  124691. */
  124692. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  124693. /**
  124694. * Returns the string "VolumetricLightScatteringPostProcess"
  124695. * @returns "VolumetricLightScatteringPostProcess"
  124696. */
  124697. getClassName(): string;
  124698. private _isReady;
  124699. /**
  124700. * Sets the new light position for light scattering effect
  124701. * @param position The new custom light position
  124702. */
  124703. setCustomMeshPosition(position: Vector3): void;
  124704. /**
  124705. * Returns the light position for light scattering effect
  124706. * @return Vector3 The custom light position
  124707. */
  124708. getCustomMeshPosition(): Vector3;
  124709. /**
  124710. * Disposes the internal assets and detaches the post-process from the camera
  124711. */
  124712. dispose(camera: Camera): void;
  124713. /**
  124714. * Returns the render target texture used by the post-process
  124715. * @return the render target texture used by the post-process
  124716. */
  124717. getPass(): RenderTargetTexture;
  124718. private _meshExcluded;
  124719. private _createPass;
  124720. private _updateMeshScreenCoordinates;
  124721. /**
  124722. * Creates a default mesh for the Volumeric Light Scattering post-process
  124723. * @param name The mesh name
  124724. * @param scene The scene where to create the mesh
  124725. * @return the default mesh
  124726. */
  124727. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  124728. }
  124729. }
  124730. declare module BABYLON {
  124731. interface Scene {
  124732. /** @hidden (Backing field) */
  124733. _boundingBoxRenderer: BoundingBoxRenderer;
  124734. /** @hidden (Backing field) */
  124735. _forceShowBoundingBoxes: boolean;
  124736. /**
  124737. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  124738. */
  124739. forceShowBoundingBoxes: boolean;
  124740. /**
  124741. * Gets the bounding box renderer associated with the scene
  124742. * @returns a BoundingBoxRenderer
  124743. */
  124744. getBoundingBoxRenderer(): BoundingBoxRenderer;
  124745. }
  124746. interface AbstractMesh {
  124747. /** @hidden (Backing field) */
  124748. _showBoundingBox: boolean;
  124749. /**
  124750. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  124751. */
  124752. showBoundingBox: boolean;
  124753. }
  124754. /**
  124755. * Component responsible of rendering the bounding box of the meshes in a scene.
  124756. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124757. */
  124758. export class BoundingBoxRenderer implements ISceneComponent {
  124759. /**
  124760. * The component name helpfull to identify the component in the list of scene components.
  124761. */
  124762. readonly name: string;
  124763. /**
  124764. * The scene the component belongs to.
  124765. */
  124766. scene: Scene;
  124767. /**
  124768. * Color of the bounding box lines placed in front of an object
  124769. */
  124770. frontColor: Color3;
  124771. /**
  124772. * Color of the bounding box lines placed behind an object
  124773. */
  124774. backColor: Color3;
  124775. /**
  124776. * Defines if the renderer should show the back lines or not
  124777. */
  124778. showBackLines: boolean;
  124779. /**
  124780. * @hidden
  124781. */
  124782. renderList: SmartArray<BoundingBox>;
  124783. private _colorShader;
  124784. private _vertexBuffers;
  124785. private _indexBuffer;
  124786. private _fillIndexBuffer;
  124787. private _fillIndexData;
  124788. /**
  124789. * Instantiates a new bounding box renderer in a scene.
  124790. * @param scene the scene the renderer renders in
  124791. */
  124792. constructor(scene: Scene);
  124793. /**
  124794. * Registers the component in a given scene
  124795. */
  124796. register(): void;
  124797. private _evaluateSubMesh;
  124798. private _activeMesh;
  124799. private _prepareRessources;
  124800. private _createIndexBuffer;
  124801. /**
  124802. * Rebuilds the elements related to this component in case of
  124803. * context lost for instance.
  124804. */
  124805. rebuild(): void;
  124806. /**
  124807. * @hidden
  124808. */
  124809. reset(): void;
  124810. /**
  124811. * Render the bounding boxes of a specific rendering group
  124812. * @param renderingGroupId defines the rendering group to render
  124813. */
  124814. render(renderingGroupId: number): void;
  124815. /**
  124816. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124817. * @param mesh Define the mesh to render the occlusion bounding box for
  124818. */
  124819. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  124820. /**
  124821. * Dispose and release the resources attached to this renderer.
  124822. */
  124823. dispose(): void;
  124824. }
  124825. }
  124826. declare module BABYLON {
  124827. /** @hidden */
  124828. export var depthPixelShader: {
  124829. name: string;
  124830. shader: string;
  124831. };
  124832. }
  124833. declare module BABYLON {
  124834. /**
  124835. * This represents a depth renderer in Babylon.
  124836. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  124837. */
  124838. export class DepthRenderer {
  124839. private _scene;
  124840. private _depthMap;
  124841. private _effect;
  124842. private readonly _storeNonLinearDepth;
  124843. private readonly _clearColor;
  124844. /** Get if the depth renderer is using packed depth or not */
  124845. readonly isPacked: boolean;
  124846. private _cachedDefines;
  124847. private _camera;
  124848. /**
  124849. * Specifiess that the depth renderer will only be used within
  124850. * the camera it is created for.
  124851. * This can help forcing its rendering during the camera processing.
  124852. */
  124853. useOnlyInActiveCamera: boolean;
  124854. /** @hidden */
  124855. static _SceneComponentInitialization: (scene: Scene) => void;
  124856. /**
  124857. * Instantiates a depth renderer
  124858. * @param scene The scene the renderer belongs to
  124859. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  124860. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  124861. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124862. */
  124863. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  124864. /**
  124865. * Creates the depth rendering effect and checks if the effect is ready.
  124866. * @param subMesh The submesh to be used to render the depth map of
  124867. * @param useInstances If multiple world instances should be used
  124868. * @returns if the depth renderer is ready to render the depth map
  124869. */
  124870. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124871. /**
  124872. * Gets the texture which the depth map will be written to.
  124873. * @returns The depth map texture
  124874. */
  124875. getDepthMap(): RenderTargetTexture;
  124876. /**
  124877. * Disposes of the depth renderer.
  124878. */
  124879. dispose(): void;
  124880. }
  124881. }
  124882. declare module BABYLON {
  124883. interface Scene {
  124884. /** @hidden (Backing field) */
  124885. _depthRenderer: {
  124886. [id: string]: DepthRenderer;
  124887. };
  124888. /**
  124889. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  124890. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  124891. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124892. * @returns the created depth renderer
  124893. */
  124894. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  124895. /**
  124896. * Disables a depth renderer for a given camera
  124897. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  124898. */
  124899. disableDepthRenderer(camera?: Nullable<Camera>): void;
  124900. }
  124901. /**
  124902. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  124903. * in several rendering techniques.
  124904. */
  124905. export class DepthRendererSceneComponent implements ISceneComponent {
  124906. /**
  124907. * The component name helpfull to identify the component in the list of scene components.
  124908. */
  124909. readonly name: string;
  124910. /**
  124911. * The scene the component belongs to.
  124912. */
  124913. scene: Scene;
  124914. /**
  124915. * Creates a new instance of the component for the given scene
  124916. * @param scene Defines the scene to register the component in
  124917. */
  124918. constructor(scene: Scene);
  124919. /**
  124920. * Registers the component in a given scene
  124921. */
  124922. register(): void;
  124923. /**
  124924. * Rebuilds the elements related to this component in case of
  124925. * context lost for instance.
  124926. */
  124927. rebuild(): void;
  124928. /**
  124929. * Disposes the component and the associated ressources
  124930. */
  124931. dispose(): void;
  124932. private _gatherRenderTargets;
  124933. private _gatherActiveCameraRenderTargets;
  124934. }
  124935. }
  124936. declare module BABYLON {
  124937. /** @hidden */
  124938. export var outlinePixelShader: {
  124939. name: string;
  124940. shader: string;
  124941. };
  124942. }
  124943. declare module BABYLON {
  124944. /** @hidden */
  124945. export var outlineVertexShader: {
  124946. name: string;
  124947. shader: string;
  124948. };
  124949. }
  124950. declare module BABYLON {
  124951. interface Scene {
  124952. /** @hidden */
  124953. _outlineRenderer: OutlineRenderer;
  124954. /**
  124955. * Gets the outline renderer associated with the scene
  124956. * @returns a OutlineRenderer
  124957. */
  124958. getOutlineRenderer(): OutlineRenderer;
  124959. }
  124960. interface AbstractMesh {
  124961. /** @hidden (Backing field) */
  124962. _renderOutline: boolean;
  124963. /**
  124964. * Gets or sets a boolean indicating if the outline must be rendered as well
  124965. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  124966. */
  124967. renderOutline: boolean;
  124968. /** @hidden (Backing field) */
  124969. _renderOverlay: boolean;
  124970. /**
  124971. * Gets or sets a boolean indicating if the overlay must be rendered as well
  124972. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  124973. */
  124974. renderOverlay: boolean;
  124975. }
  124976. /**
  124977. * This class is responsible to draw bothe outline/overlay of meshes.
  124978. * It should not be used directly but through the available method on mesh.
  124979. */
  124980. export class OutlineRenderer implements ISceneComponent {
  124981. /**
  124982. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  124983. */
  124984. private static _StencilReference;
  124985. /**
  124986. * The name of the component. Each component must have a unique name.
  124987. */
  124988. name: string;
  124989. /**
  124990. * The scene the component belongs to.
  124991. */
  124992. scene: Scene;
  124993. /**
  124994. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  124995. */
  124996. zOffset: number;
  124997. private _engine;
  124998. private _effect;
  124999. private _cachedDefines;
  125000. private _savedDepthWrite;
  125001. /**
  125002. * Instantiates a new outline renderer. (There could be only one per scene).
  125003. * @param scene Defines the scene it belongs to
  125004. */
  125005. constructor(scene: Scene);
  125006. /**
  125007. * Register the component to one instance of a scene.
  125008. */
  125009. register(): void;
  125010. /**
  125011. * Rebuilds the elements related to this component in case of
  125012. * context lost for instance.
  125013. */
  125014. rebuild(): void;
  125015. /**
  125016. * Disposes the component and the associated ressources.
  125017. */
  125018. dispose(): void;
  125019. /**
  125020. * Renders the outline in the canvas.
  125021. * @param subMesh Defines the sumesh to render
  125022. * @param batch Defines the batch of meshes in case of instances
  125023. * @param useOverlay Defines if the rendering is for the overlay or the outline
  125024. */
  125025. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  125026. /**
  125027. * Returns whether or not the outline renderer is ready for a given submesh.
  125028. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  125029. * @param subMesh Defines the submesh to check readyness for
  125030. * @param useInstances Defines wheter wee are trying to render instances or not
  125031. * @returns true if ready otherwise false
  125032. */
  125033. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125034. private _beforeRenderingMesh;
  125035. private _afterRenderingMesh;
  125036. }
  125037. }
  125038. declare module BABYLON {
  125039. /**
  125040. * Class used to manage multiple sprites of different sizes on the same spritesheet
  125041. * @see http://doc.babylonjs.com/babylon101/sprites
  125042. */
  125043. export class SpritePackedManager extends SpriteManager {
  125044. /** defines the packed manager's name */
  125045. name: string;
  125046. /**
  125047. * Creates a new sprite manager from a packed sprite sheet
  125048. * @param name defines the manager's name
  125049. * @param imgUrl defines the sprite sheet url
  125050. * @param capacity defines the maximum allowed number of sprites
  125051. * @param scene defines the hosting scene
  125052. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  125053. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125054. * @param samplingMode defines the smapling mode to use with spritesheet
  125055. * @param fromPacked set to true; do not alter
  125056. */
  125057. constructor(
  125058. /** defines the packed manager's name */
  125059. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  125060. }
  125061. }
  125062. declare module BABYLON {
  125063. /**
  125064. * Defines the list of states available for a task inside a AssetsManager
  125065. */
  125066. export enum AssetTaskState {
  125067. /**
  125068. * Initialization
  125069. */
  125070. INIT = 0,
  125071. /**
  125072. * Running
  125073. */
  125074. RUNNING = 1,
  125075. /**
  125076. * Done
  125077. */
  125078. DONE = 2,
  125079. /**
  125080. * Error
  125081. */
  125082. ERROR = 3
  125083. }
  125084. /**
  125085. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  125086. */
  125087. export abstract class AbstractAssetTask {
  125088. /**
  125089. * Task name
  125090. */ name: string;
  125091. /**
  125092. * Callback called when the task is successful
  125093. */
  125094. onSuccess: (task: any) => void;
  125095. /**
  125096. * Callback called when the task is not successful
  125097. */
  125098. onError: (task: any, message?: string, exception?: any) => void;
  125099. /**
  125100. * Creates a new AssetsManager
  125101. * @param name defines the name of the task
  125102. */
  125103. constructor(
  125104. /**
  125105. * Task name
  125106. */ name: string);
  125107. private _isCompleted;
  125108. private _taskState;
  125109. private _errorObject;
  125110. /**
  125111. * Get if the task is completed
  125112. */
  125113. readonly isCompleted: boolean;
  125114. /**
  125115. * Gets the current state of the task
  125116. */
  125117. readonly taskState: AssetTaskState;
  125118. /**
  125119. * Gets the current error object (if task is in error)
  125120. */
  125121. readonly errorObject: {
  125122. message?: string;
  125123. exception?: any;
  125124. };
  125125. /**
  125126. * Internal only
  125127. * @hidden
  125128. */
  125129. _setErrorObject(message?: string, exception?: any): void;
  125130. /**
  125131. * Execute the current task
  125132. * @param scene defines the scene where you want your assets to be loaded
  125133. * @param onSuccess is a callback called when the task is successfully executed
  125134. * @param onError is a callback called if an error occurs
  125135. */
  125136. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125137. /**
  125138. * Execute the current task
  125139. * @param scene defines the scene where you want your assets to be loaded
  125140. * @param onSuccess is a callback called when the task is successfully executed
  125141. * @param onError is a callback called if an error occurs
  125142. */
  125143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125144. /**
  125145. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  125146. * This can be used with failed tasks that have the reason for failure fixed.
  125147. */
  125148. reset(): void;
  125149. private onErrorCallback;
  125150. private onDoneCallback;
  125151. }
  125152. /**
  125153. * Define the interface used by progress events raised during assets loading
  125154. */
  125155. export interface IAssetsProgressEvent {
  125156. /**
  125157. * Defines the number of remaining tasks to process
  125158. */
  125159. remainingCount: number;
  125160. /**
  125161. * Defines the total number of tasks
  125162. */
  125163. totalCount: number;
  125164. /**
  125165. * Defines the task that was just processed
  125166. */
  125167. task: AbstractAssetTask;
  125168. }
  125169. /**
  125170. * Class used to share progress information about assets loading
  125171. */
  125172. export class AssetsProgressEvent implements IAssetsProgressEvent {
  125173. /**
  125174. * Defines the number of remaining tasks to process
  125175. */
  125176. remainingCount: number;
  125177. /**
  125178. * Defines the total number of tasks
  125179. */
  125180. totalCount: number;
  125181. /**
  125182. * Defines the task that was just processed
  125183. */
  125184. task: AbstractAssetTask;
  125185. /**
  125186. * Creates a AssetsProgressEvent
  125187. * @param remainingCount defines the number of remaining tasks to process
  125188. * @param totalCount defines the total number of tasks
  125189. * @param task defines the task that was just processed
  125190. */
  125191. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  125192. }
  125193. /**
  125194. * Define a task used by AssetsManager to load meshes
  125195. */
  125196. export class MeshAssetTask extends AbstractAssetTask {
  125197. /**
  125198. * Defines the name of the task
  125199. */
  125200. name: string;
  125201. /**
  125202. * Defines the list of mesh's names you want to load
  125203. */
  125204. meshesNames: any;
  125205. /**
  125206. * Defines the root url to use as a base to load your meshes and associated resources
  125207. */
  125208. rootUrl: string;
  125209. /**
  125210. * Defines the filename of the scene to load from
  125211. */
  125212. sceneFilename: string;
  125213. /**
  125214. * Gets the list of loaded meshes
  125215. */
  125216. loadedMeshes: Array<AbstractMesh>;
  125217. /**
  125218. * Gets the list of loaded particle systems
  125219. */
  125220. loadedParticleSystems: Array<IParticleSystem>;
  125221. /**
  125222. * Gets the list of loaded skeletons
  125223. */
  125224. loadedSkeletons: Array<Skeleton>;
  125225. /**
  125226. * Gets the list of loaded animation groups
  125227. */
  125228. loadedAnimationGroups: Array<AnimationGroup>;
  125229. /**
  125230. * Callback called when the task is successful
  125231. */
  125232. onSuccess: (task: MeshAssetTask) => void;
  125233. /**
  125234. * Callback called when the task is successful
  125235. */
  125236. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  125237. /**
  125238. * Creates a new MeshAssetTask
  125239. * @param name defines the name of the task
  125240. * @param meshesNames defines the list of mesh's names you want to load
  125241. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  125242. * @param sceneFilename defines the filename of the scene to load from
  125243. */
  125244. constructor(
  125245. /**
  125246. * Defines the name of the task
  125247. */
  125248. name: string,
  125249. /**
  125250. * Defines the list of mesh's names you want to load
  125251. */
  125252. meshesNames: any,
  125253. /**
  125254. * Defines the root url to use as a base to load your meshes and associated resources
  125255. */
  125256. rootUrl: string,
  125257. /**
  125258. * Defines the filename of the scene to load from
  125259. */
  125260. sceneFilename: string);
  125261. /**
  125262. * Execute the current task
  125263. * @param scene defines the scene where you want your assets to be loaded
  125264. * @param onSuccess is a callback called when the task is successfully executed
  125265. * @param onError is a callback called if an error occurs
  125266. */
  125267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125268. }
  125269. /**
  125270. * Define a task used by AssetsManager to load text content
  125271. */
  125272. export class TextFileAssetTask extends AbstractAssetTask {
  125273. /**
  125274. * Defines the name of the task
  125275. */
  125276. name: string;
  125277. /**
  125278. * Defines the location of the file to load
  125279. */
  125280. url: string;
  125281. /**
  125282. * Gets the loaded text string
  125283. */
  125284. text: string;
  125285. /**
  125286. * Callback called when the task is successful
  125287. */
  125288. onSuccess: (task: TextFileAssetTask) => void;
  125289. /**
  125290. * Callback called when the task is successful
  125291. */
  125292. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  125293. /**
  125294. * Creates a new TextFileAssetTask object
  125295. * @param name defines the name of the task
  125296. * @param url defines the location of the file to load
  125297. */
  125298. constructor(
  125299. /**
  125300. * Defines the name of the task
  125301. */
  125302. name: string,
  125303. /**
  125304. * Defines the location of the file to load
  125305. */
  125306. url: string);
  125307. /**
  125308. * Execute the current task
  125309. * @param scene defines the scene where you want your assets to be loaded
  125310. * @param onSuccess is a callback called when the task is successfully executed
  125311. * @param onError is a callback called if an error occurs
  125312. */
  125313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125314. }
  125315. /**
  125316. * Define a task used by AssetsManager to load binary data
  125317. */
  125318. export class BinaryFileAssetTask extends AbstractAssetTask {
  125319. /**
  125320. * Defines the name of the task
  125321. */
  125322. name: string;
  125323. /**
  125324. * Defines the location of the file to load
  125325. */
  125326. url: string;
  125327. /**
  125328. * Gets the lodaded data (as an array buffer)
  125329. */
  125330. data: ArrayBuffer;
  125331. /**
  125332. * Callback called when the task is successful
  125333. */
  125334. onSuccess: (task: BinaryFileAssetTask) => void;
  125335. /**
  125336. * Callback called when the task is successful
  125337. */
  125338. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  125339. /**
  125340. * Creates a new BinaryFileAssetTask object
  125341. * @param name defines the name of the new task
  125342. * @param url defines the location of the file to load
  125343. */
  125344. constructor(
  125345. /**
  125346. * Defines the name of the task
  125347. */
  125348. name: string,
  125349. /**
  125350. * Defines the location of the file to load
  125351. */
  125352. url: string);
  125353. /**
  125354. * Execute the current task
  125355. * @param scene defines the scene where you want your assets to be loaded
  125356. * @param onSuccess is a callback called when the task is successfully executed
  125357. * @param onError is a callback called if an error occurs
  125358. */
  125359. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125360. }
  125361. /**
  125362. * Define a task used by AssetsManager to load images
  125363. */
  125364. export class ImageAssetTask extends AbstractAssetTask {
  125365. /**
  125366. * Defines the name of the task
  125367. */
  125368. name: string;
  125369. /**
  125370. * Defines the location of the image to load
  125371. */
  125372. url: string;
  125373. /**
  125374. * Gets the loaded images
  125375. */
  125376. image: HTMLImageElement;
  125377. /**
  125378. * Callback called when the task is successful
  125379. */
  125380. onSuccess: (task: ImageAssetTask) => void;
  125381. /**
  125382. * Callback called when the task is successful
  125383. */
  125384. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  125385. /**
  125386. * Creates a new ImageAssetTask
  125387. * @param name defines the name of the task
  125388. * @param url defines the location of the image to load
  125389. */
  125390. constructor(
  125391. /**
  125392. * Defines the name of the task
  125393. */
  125394. name: string,
  125395. /**
  125396. * Defines the location of the image to load
  125397. */
  125398. url: string);
  125399. /**
  125400. * Execute the current task
  125401. * @param scene defines the scene where you want your assets to be loaded
  125402. * @param onSuccess is a callback called when the task is successfully executed
  125403. * @param onError is a callback called if an error occurs
  125404. */
  125405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125406. }
  125407. /**
  125408. * Defines the interface used by texture loading tasks
  125409. */
  125410. export interface ITextureAssetTask<TEX extends BaseTexture> {
  125411. /**
  125412. * Gets the loaded texture
  125413. */
  125414. texture: TEX;
  125415. }
  125416. /**
  125417. * Define a task used by AssetsManager to load 2D textures
  125418. */
  125419. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  125420. /**
  125421. * Defines the name of the task
  125422. */
  125423. name: string;
  125424. /**
  125425. * Defines the location of the file to load
  125426. */
  125427. url: string;
  125428. /**
  125429. * Defines if mipmap should not be generated (default is false)
  125430. */
  125431. noMipmap?: boolean | undefined;
  125432. /**
  125433. * Defines if texture must be inverted on Y axis (default is false)
  125434. */
  125435. invertY?: boolean | undefined;
  125436. /**
  125437. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125438. */
  125439. samplingMode: number;
  125440. /**
  125441. * Gets the loaded texture
  125442. */
  125443. texture: Texture;
  125444. /**
  125445. * Callback called when the task is successful
  125446. */
  125447. onSuccess: (task: TextureAssetTask) => void;
  125448. /**
  125449. * Callback called when the task is successful
  125450. */
  125451. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  125452. /**
  125453. * Creates a new TextureAssetTask object
  125454. * @param name defines the name of the task
  125455. * @param url defines the location of the file to load
  125456. * @param noMipmap defines if mipmap should not be generated (default is false)
  125457. * @param invertY defines if texture must be inverted on Y axis (default is false)
  125458. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125459. */
  125460. constructor(
  125461. /**
  125462. * Defines the name of the task
  125463. */
  125464. name: string,
  125465. /**
  125466. * Defines the location of the file to load
  125467. */
  125468. url: string,
  125469. /**
  125470. * Defines if mipmap should not be generated (default is false)
  125471. */
  125472. noMipmap?: boolean | undefined,
  125473. /**
  125474. * Defines if texture must be inverted on Y axis (default is false)
  125475. */
  125476. invertY?: boolean | undefined,
  125477. /**
  125478. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125479. */
  125480. samplingMode?: number);
  125481. /**
  125482. * Execute the current task
  125483. * @param scene defines the scene where you want your assets to be loaded
  125484. * @param onSuccess is a callback called when the task is successfully executed
  125485. * @param onError is a callback called if an error occurs
  125486. */
  125487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125488. }
  125489. /**
  125490. * Define a task used by AssetsManager to load cube textures
  125491. */
  125492. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  125493. /**
  125494. * Defines the name of the task
  125495. */
  125496. name: string;
  125497. /**
  125498. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125499. */
  125500. url: string;
  125501. /**
  125502. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125503. */
  125504. extensions?: string[] | undefined;
  125505. /**
  125506. * Defines if mipmaps should not be generated (default is false)
  125507. */
  125508. noMipmap?: boolean | undefined;
  125509. /**
  125510. * Defines the explicit list of files (undefined by default)
  125511. */
  125512. files?: string[] | undefined;
  125513. /**
  125514. * Gets the loaded texture
  125515. */
  125516. texture: CubeTexture;
  125517. /**
  125518. * Callback called when the task is successful
  125519. */
  125520. onSuccess: (task: CubeTextureAssetTask) => void;
  125521. /**
  125522. * Callback called when the task is successful
  125523. */
  125524. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  125525. /**
  125526. * Creates a new CubeTextureAssetTask
  125527. * @param name defines the name of the task
  125528. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125529. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125530. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125531. * @param files defines the explicit list of files (undefined by default)
  125532. */
  125533. constructor(
  125534. /**
  125535. * Defines the name of the task
  125536. */
  125537. name: string,
  125538. /**
  125539. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125540. */
  125541. url: string,
  125542. /**
  125543. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125544. */
  125545. extensions?: string[] | undefined,
  125546. /**
  125547. * Defines if mipmaps should not be generated (default is false)
  125548. */
  125549. noMipmap?: boolean | undefined,
  125550. /**
  125551. * Defines the explicit list of files (undefined by default)
  125552. */
  125553. files?: string[] | undefined);
  125554. /**
  125555. * Execute the current task
  125556. * @param scene defines the scene where you want your assets to be loaded
  125557. * @param onSuccess is a callback called when the task is successfully executed
  125558. * @param onError is a callback called if an error occurs
  125559. */
  125560. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125561. }
  125562. /**
  125563. * Define a task used by AssetsManager to load HDR cube textures
  125564. */
  125565. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  125566. /**
  125567. * Defines the name of the task
  125568. */
  125569. name: string;
  125570. /**
  125571. * Defines the location of the file to load
  125572. */
  125573. url: string;
  125574. /**
  125575. * Defines the desired size (the more it increases the longer the generation will be)
  125576. */
  125577. size: number;
  125578. /**
  125579. * Defines if mipmaps should not be generated (default is false)
  125580. */
  125581. noMipmap: boolean;
  125582. /**
  125583. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125584. */
  125585. generateHarmonics: boolean;
  125586. /**
  125587. * 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)
  125588. */
  125589. gammaSpace: boolean;
  125590. /**
  125591. * Internal Use Only
  125592. */
  125593. reserved: boolean;
  125594. /**
  125595. * Gets the loaded texture
  125596. */
  125597. texture: HDRCubeTexture;
  125598. /**
  125599. * Callback called when the task is successful
  125600. */
  125601. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  125602. /**
  125603. * Callback called when the task is successful
  125604. */
  125605. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  125606. /**
  125607. * Creates a new HDRCubeTextureAssetTask object
  125608. * @param name defines the name of the task
  125609. * @param url defines the location of the file to load
  125610. * @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.
  125611. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125612. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125613. * @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)
  125614. * @param reserved Internal use only
  125615. */
  125616. constructor(
  125617. /**
  125618. * Defines the name of the task
  125619. */
  125620. name: string,
  125621. /**
  125622. * Defines the location of the file to load
  125623. */
  125624. url: string,
  125625. /**
  125626. * Defines the desired size (the more it increases the longer the generation will be)
  125627. */
  125628. size: number,
  125629. /**
  125630. * Defines if mipmaps should not be generated (default is false)
  125631. */
  125632. noMipmap?: boolean,
  125633. /**
  125634. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125635. */
  125636. generateHarmonics?: boolean,
  125637. /**
  125638. * 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)
  125639. */
  125640. gammaSpace?: boolean,
  125641. /**
  125642. * Internal Use Only
  125643. */
  125644. reserved?: boolean);
  125645. /**
  125646. * Execute the current task
  125647. * @param scene defines the scene where you want your assets to be loaded
  125648. * @param onSuccess is a callback called when the task is successfully executed
  125649. * @param onError is a callback called if an error occurs
  125650. */
  125651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125652. }
  125653. /**
  125654. * Define a task used by AssetsManager to load Equirectangular cube textures
  125655. */
  125656. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  125657. /**
  125658. * Defines the name of the task
  125659. */
  125660. name: string;
  125661. /**
  125662. * Defines the location of the file to load
  125663. */
  125664. url: string;
  125665. /**
  125666. * Defines the desired size (the more it increases the longer the generation will be)
  125667. */
  125668. size: number;
  125669. /**
  125670. * Defines if mipmaps should not be generated (default is false)
  125671. */
  125672. noMipmap: boolean;
  125673. /**
  125674. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125675. * but the standard material would require them in Gamma space) (default is true)
  125676. */
  125677. gammaSpace: boolean;
  125678. /**
  125679. * Gets the loaded texture
  125680. */
  125681. texture: EquiRectangularCubeTexture;
  125682. /**
  125683. * Callback called when the task is successful
  125684. */
  125685. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  125686. /**
  125687. * Callback called when the task is successful
  125688. */
  125689. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  125690. /**
  125691. * Creates a new EquiRectangularCubeTextureAssetTask object
  125692. * @param name defines the name of the task
  125693. * @param url defines the location of the file to load
  125694. * @param size defines the desired size (the more it increases the longer the generation will be)
  125695. * If the size is omitted this implies you are using a preprocessed cubemap.
  125696. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125697. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  125698. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  125699. * (default is true)
  125700. */
  125701. constructor(
  125702. /**
  125703. * Defines the name of the task
  125704. */
  125705. name: string,
  125706. /**
  125707. * Defines the location of the file to load
  125708. */
  125709. url: string,
  125710. /**
  125711. * Defines the desired size (the more it increases the longer the generation will be)
  125712. */
  125713. size: number,
  125714. /**
  125715. * Defines if mipmaps should not be generated (default is false)
  125716. */
  125717. noMipmap?: boolean,
  125718. /**
  125719. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125720. * but the standard material would require them in Gamma space) (default is true)
  125721. */
  125722. gammaSpace?: boolean);
  125723. /**
  125724. * Execute the current task
  125725. * @param scene defines the scene where you want your assets to be loaded
  125726. * @param onSuccess is a callback called when the task is successfully executed
  125727. * @param onError is a callback called if an error occurs
  125728. */
  125729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125730. }
  125731. /**
  125732. * This class can be used to easily import assets into a scene
  125733. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  125734. */
  125735. export class AssetsManager {
  125736. private _scene;
  125737. private _isLoading;
  125738. protected _tasks: AbstractAssetTask[];
  125739. protected _waitingTasksCount: number;
  125740. protected _totalTasksCount: number;
  125741. /**
  125742. * Callback called when all tasks are processed
  125743. */
  125744. onFinish: (tasks: AbstractAssetTask[]) => void;
  125745. /**
  125746. * Callback called when a task is successful
  125747. */
  125748. onTaskSuccess: (task: AbstractAssetTask) => void;
  125749. /**
  125750. * Callback called when a task had an error
  125751. */
  125752. onTaskError: (task: AbstractAssetTask) => void;
  125753. /**
  125754. * Callback called when a task is done (whatever the result is)
  125755. */
  125756. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  125757. /**
  125758. * Observable called when all tasks are processed
  125759. */
  125760. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  125761. /**
  125762. * Observable called when a task had an error
  125763. */
  125764. onTaskErrorObservable: Observable<AbstractAssetTask>;
  125765. /**
  125766. * Observable called when all tasks were executed
  125767. */
  125768. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  125769. /**
  125770. * Observable called when a task is done (whatever the result is)
  125771. */
  125772. onProgressObservable: Observable<IAssetsProgressEvent>;
  125773. /**
  125774. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  125775. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125776. */
  125777. useDefaultLoadingScreen: boolean;
  125778. /**
  125779. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  125780. * when all assets have been downloaded.
  125781. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  125782. */
  125783. autoHideLoadingUI: boolean;
  125784. /**
  125785. * Creates a new AssetsManager
  125786. * @param scene defines the scene to work on
  125787. */
  125788. constructor(scene: Scene);
  125789. /**
  125790. * Add a MeshAssetTask to the list of active tasks
  125791. * @param taskName defines the name of the new task
  125792. * @param meshesNames defines the name of meshes to load
  125793. * @param rootUrl defines the root url to use to locate files
  125794. * @param sceneFilename defines the filename of the scene file
  125795. * @returns a new MeshAssetTask object
  125796. */
  125797. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  125798. /**
  125799. * Add a TextFileAssetTask to the list of active tasks
  125800. * @param taskName defines the name of the new task
  125801. * @param url defines the url of the file to load
  125802. * @returns a new TextFileAssetTask object
  125803. */
  125804. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  125805. /**
  125806. * Add a BinaryFileAssetTask to the list of active tasks
  125807. * @param taskName defines the name of the new task
  125808. * @param url defines the url of the file to load
  125809. * @returns a new BinaryFileAssetTask object
  125810. */
  125811. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  125812. /**
  125813. * Add a ImageAssetTask to the list of active tasks
  125814. * @param taskName defines the name of the new task
  125815. * @param url defines the url of the file to load
  125816. * @returns a new ImageAssetTask object
  125817. */
  125818. addImageTask(taskName: string, url: string): ImageAssetTask;
  125819. /**
  125820. * Add a TextureAssetTask to the list of active tasks
  125821. * @param taskName defines the name of the new task
  125822. * @param url defines the url of the file to load
  125823. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125824. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  125825. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125826. * @returns a new TextureAssetTask object
  125827. */
  125828. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  125829. /**
  125830. * Add a CubeTextureAssetTask to the list of active tasks
  125831. * @param taskName defines the name of the new task
  125832. * @param url defines the url of the file to load
  125833. * @param extensions defines the extension to use to load the cube map (can be null)
  125834. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125835. * @param files defines the list of files to load (can be null)
  125836. * @returns a new CubeTextureAssetTask object
  125837. */
  125838. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  125839. /**
  125840. *
  125841. * Add a HDRCubeTextureAssetTask to the list of active tasks
  125842. * @param taskName defines the name of the new task
  125843. * @param url defines the url of the file to load
  125844. * @param size defines the size you want for the cubemap (can be null)
  125845. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125846. * @param generateHarmonics defines if you want to automatically generate (true by default)
  125847. * @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)
  125848. * @param reserved Internal use only
  125849. * @returns a new HDRCubeTextureAssetTask object
  125850. */
  125851. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  125852. /**
  125853. *
  125854. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  125855. * @param taskName defines the name of the new task
  125856. * @param url defines the url of the file to load
  125857. * @param size defines the size you want for the cubemap (can be null)
  125858. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125859. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125860. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125861. * @returns a new EquiRectangularCubeTextureAssetTask object
  125862. */
  125863. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  125864. /**
  125865. * Remove a task from the assets manager.
  125866. * @param task the task to remove
  125867. */
  125868. removeTask(task: AbstractAssetTask): void;
  125869. private _decreaseWaitingTasksCount;
  125870. private _runTask;
  125871. /**
  125872. * Reset the AssetsManager and remove all tasks
  125873. * @return the current instance of the AssetsManager
  125874. */
  125875. reset(): AssetsManager;
  125876. /**
  125877. * Start the loading process
  125878. * @return the current instance of the AssetsManager
  125879. */
  125880. load(): AssetsManager;
  125881. /**
  125882. * Start the loading process as an async operation
  125883. * @return a promise returning the list of failed tasks
  125884. */
  125885. loadAsync(): Promise<void>;
  125886. }
  125887. }
  125888. declare module BABYLON {
  125889. /**
  125890. * Wrapper class for promise with external resolve and reject.
  125891. */
  125892. export class Deferred<T> {
  125893. /**
  125894. * The promise associated with this deferred object.
  125895. */
  125896. readonly promise: Promise<T>;
  125897. private _resolve;
  125898. private _reject;
  125899. /**
  125900. * The resolve method of the promise associated with this deferred object.
  125901. */
  125902. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  125903. /**
  125904. * The reject method of the promise associated with this deferred object.
  125905. */
  125906. readonly reject: (reason?: any) => void;
  125907. /**
  125908. * Constructor for this deferred object.
  125909. */
  125910. constructor();
  125911. }
  125912. }
  125913. declare module BABYLON {
  125914. /**
  125915. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  125916. */
  125917. export class MeshExploder {
  125918. private _centerMesh;
  125919. private _meshes;
  125920. private _meshesOrigins;
  125921. private _toCenterVectors;
  125922. private _scaledDirection;
  125923. private _newPosition;
  125924. private _centerPosition;
  125925. /**
  125926. * Explodes meshes from a center mesh.
  125927. * @param meshes The meshes to explode.
  125928. * @param centerMesh The mesh to be center of explosion.
  125929. */
  125930. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  125931. private _setCenterMesh;
  125932. /**
  125933. * Get class name
  125934. * @returns "MeshExploder"
  125935. */
  125936. getClassName(): string;
  125937. /**
  125938. * "Exploded meshes"
  125939. * @returns Array of meshes with the centerMesh at index 0.
  125940. */
  125941. getMeshes(): Array<Mesh>;
  125942. /**
  125943. * Explodes meshes giving a specific direction
  125944. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  125945. */
  125946. explode(direction?: number): void;
  125947. }
  125948. }
  125949. declare module BABYLON {
  125950. /**
  125951. * Class used to help managing file picking and drag'n'drop
  125952. */
  125953. export class FilesInput {
  125954. /**
  125955. * List of files ready to be loaded
  125956. */
  125957. static readonly FilesToLoad: {
  125958. [key: string]: File;
  125959. };
  125960. /**
  125961. * Callback called when a file is processed
  125962. */
  125963. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  125964. private _engine;
  125965. private _currentScene;
  125966. private _sceneLoadedCallback;
  125967. private _progressCallback;
  125968. private _additionalRenderLoopLogicCallback;
  125969. private _textureLoadingCallback;
  125970. private _startingProcessingFilesCallback;
  125971. private _onReloadCallback;
  125972. private _errorCallback;
  125973. private _elementToMonitor;
  125974. private _sceneFileToLoad;
  125975. private _filesToLoad;
  125976. /**
  125977. * Creates a new FilesInput
  125978. * @param engine defines the rendering engine
  125979. * @param scene defines the hosting scene
  125980. * @param sceneLoadedCallback callback called when scene is loaded
  125981. * @param progressCallback callback called to track progress
  125982. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  125983. * @param textureLoadingCallback callback called when a texture is loading
  125984. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  125985. * @param onReloadCallback callback called when a reload is requested
  125986. * @param errorCallback callback call if an error occurs
  125987. */
  125988. 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);
  125989. private _dragEnterHandler;
  125990. private _dragOverHandler;
  125991. private _dropHandler;
  125992. /**
  125993. * Calls this function to listen to drag'n'drop events on a specific DOM element
  125994. * @param elementToMonitor defines the DOM element to track
  125995. */
  125996. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  125997. /**
  125998. * Release all associated resources
  125999. */
  126000. dispose(): void;
  126001. private renderFunction;
  126002. private drag;
  126003. private drop;
  126004. private _traverseFolder;
  126005. private _processFiles;
  126006. /**
  126007. * Load files from a drop event
  126008. * @param event defines the drop event to use as source
  126009. */
  126010. loadFiles(event: any): void;
  126011. private _processReload;
  126012. /**
  126013. * Reload the current scene from the loaded files
  126014. */
  126015. reload(): void;
  126016. }
  126017. }
  126018. declare module BABYLON {
  126019. /**
  126020. * Defines the root class used to create scene optimization to use with SceneOptimizer
  126021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126022. */
  126023. export class SceneOptimization {
  126024. /**
  126025. * Defines the priority of this optimization (0 by default which means first in the list)
  126026. */
  126027. priority: number;
  126028. /**
  126029. * Gets a string describing the action executed by the current optimization
  126030. * @returns description string
  126031. */
  126032. getDescription(): string;
  126033. /**
  126034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126035. * @param scene defines the current scene where to apply this optimization
  126036. * @param optimizer defines the current optimizer
  126037. * @returns true if everything that can be done was applied
  126038. */
  126039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126040. /**
  126041. * Creates the SceneOptimization object
  126042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126043. * @param desc defines the description associated with the optimization
  126044. */
  126045. constructor(
  126046. /**
  126047. * Defines the priority of this optimization (0 by default which means first in the list)
  126048. */
  126049. priority?: number);
  126050. }
  126051. /**
  126052. * Defines an optimization used to reduce the size of render target textures
  126053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126054. */
  126055. export class TextureOptimization extends SceneOptimization {
  126056. /**
  126057. * Defines the priority of this optimization (0 by default which means first in the list)
  126058. */
  126059. priority: number;
  126060. /**
  126061. * 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
  126062. */
  126063. maximumSize: number;
  126064. /**
  126065. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126066. */
  126067. step: number;
  126068. /**
  126069. * Gets a string describing the action executed by the current optimization
  126070. * @returns description string
  126071. */
  126072. getDescription(): string;
  126073. /**
  126074. * Creates the TextureOptimization object
  126075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126076. * @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
  126077. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126078. */
  126079. constructor(
  126080. /**
  126081. * Defines the priority of this optimization (0 by default which means first in the list)
  126082. */
  126083. priority?: number,
  126084. /**
  126085. * 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
  126086. */
  126087. maximumSize?: number,
  126088. /**
  126089. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126090. */
  126091. step?: number);
  126092. /**
  126093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126094. * @param scene defines the current scene where to apply this optimization
  126095. * @param optimizer defines the current optimizer
  126096. * @returns true if everything that can be done was applied
  126097. */
  126098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126099. }
  126100. /**
  126101. * Defines an optimization used to increase or decrease the rendering resolution
  126102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126103. */
  126104. export class HardwareScalingOptimization extends SceneOptimization {
  126105. /**
  126106. * Defines the priority of this optimization (0 by default which means first in the list)
  126107. */
  126108. priority: number;
  126109. /**
  126110. * Defines the maximum scale to use (2 by default)
  126111. */
  126112. maximumScale: number;
  126113. /**
  126114. * Defines the step to use between two passes (0.5 by default)
  126115. */
  126116. step: number;
  126117. private _currentScale;
  126118. private _directionOffset;
  126119. /**
  126120. * Gets a string describing the action executed by the current optimization
  126121. * @return description string
  126122. */
  126123. getDescription(): string;
  126124. /**
  126125. * Creates the HardwareScalingOptimization object
  126126. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126127. * @param maximumScale defines the maximum scale to use (2 by default)
  126128. * @param step defines the step to use between two passes (0.5 by default)
  126129. */
  126130. constructor(
  126131. /**
  126132. * Defines the priority of this optimization (0 by default which means first in the list)
  126133. */
  126134. priority?: number,
  126135. /**
  126136. * Defines the maximum scale to use (2 by default)
  126137. */
  126138. maximumScale?: number,
  126139. /**
  126140. * Defines the step to use between two passes (0.5 by default)
  126141. */
  126142. step?: number);
  126143. /**
  126144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126145. * @param scene defines the current scene where to apply this optimization
  126146. * @param optimizer defines the current optimizer
  126147. * @returns true if everything that can be done was applied
  126148. */
  126149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126150. }
  126151. /**
  126152. * Defines an optimization used to remove shadows
  126153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126154. */
  126155. export class ShadowsOptimization extends SceneOptimization {
  126156. /**
  126157. * Gets a string describing the action executed by the current optimization
  126158. * @return description string
  126159. */
  126160. getDescription(): string;
  126161. /**
  126162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126163. * @param scene defines the current scene where to apply this optimization
  126164. * @param optimizer defines the current optimizer
  126165. * @returns true if everything that can be done was applied
  126166. */
  126167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126168. }
  126169. /**
  126170. * Defines an optimization used to turn post-processes off
  126171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126172. */
  126173. export class PostProcessesOptimization extends SceneOptimization {
  126174. /**
  126175. * Gets a string describing the action executed by the current optimization
  126176. * @return description string
  126177. */
  126178. getDescription(): string;
  126179. /**
  126180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126181. * @param scene defines the current scene where to apply this optimization
  126182. * @param optimizer defines the current optimizer
  126183. * @returns true if everything that can be done was applied
  126184. */
  126185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126186. }
  126187. /**
  126188. * Defines an optimization used to turn lens flares off
  126189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126190. */
  126191. export class LensFlaresOptimization extends SceneOptimization {
  126192. /**
  126193. * Gets a string describing the action executed by the current optimization
  126194. * @return description string
  126195. */
  126196. getDescription(): string;
  126197. /**
  126198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126199. * @param scene defines the current scene where to apply this optimization
  126200. * @param optimizer defines the current optimizer
  126201. * @returns true if everything that can be done was applied
  126202. */
  126203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126204. }
  126205. /**
  126206. * Defines an optimization based on user defined callback.
  126207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126208. */
  126209. export class CustomOptimization extends SceneOptimization {
  126210. /**
  126211. * Callback called to apply the custom optimization.
  126212. */
  126213. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  126214. /**
  126215. * Callback called to get custom description
  126216. */
  126217. onGetDescription: () => string;
  126218. /**
  126219. * Gets a string describing the action executed by the current optimization
  126220. * @returns description string
  126221. */
  126222. getDescription(): string;
  126223. /**
  126224. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126225. * @param scene defines the current scene where to apply this optimization
  126226. * @param optimizer defines the current optimizer
  126227. * @returns true if everything that can be done was applied
  126228. */
  126229. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126230. }
  126231. /**
  126232. * Defines an optimization used to turn particles off
  126233. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126234. */
  126235. export class ParticlesOptimization extends SceneOptimization {
  126236. /**
  126237. * Gets a string describing the action executed by the current optimization
  126238. * @return description string
  126239. */
  126240. getDescription(): string;
  126241. /**
  126242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126243. * @param scene defines the current scene where to apply this optimization
  126244. * @param optimizer defines the current optimizer
  126245. * @returns true if everything that can be done was applied
  126246. */
  126247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126248. }
  126249. /**
  126250. * Defines an optimization used to turn render targets off
  126251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126252. */
  126253. export class RenderTargetsOptimization extends SceneOptimization {
  126254. /**
  126255. * Gets a string describing the action executed by the current optimization
  126256. * @return description string
  126257. */
  126258. getDescription(): string;
  126259. /**
  126260. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126261. * @param scene defines the current scene where to apply this optimization
  126262. * @param optimizer defines the current optimizer
  126263. * @returns true if everything that can be done was applied
  126264. */
  126265. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126266. }
  126267. /**
  126268. * Defines an optimization used to merge meshes with compatible materials
  126269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126270. */
  126271. export class MergeMeshesOptimization extends SceneOptimization {
  126272. private static _UpdateSelectionTree;
  126273. /**
  126274. * Gets or sets a boolean which defines if optimization octree has to be updated
  126275. */
  126276. /**
  126277. * Gets or sets a boolean which defines if optimization octree has to be updated
  126278. */
  126279. static UpdateSelectionTree: boolean;
  126280. /**
  126281. * Gets a string describing the action executed by the current optimization
  126282. * @return description string
  126283. */
  126284. getDescription(): string;
  126285. private _canBeMerged;
  126286. /**
  126287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126288. * @param scene defines the current scene where to apply this optimization
  126289. * @param optimizer defines the current optimizer
  126290. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  126291. * @returns true if everything that can be done was applied
  126292. */
  126293. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  126294. }
  126295. /**
  126296. * Defines a list of options used by SceneOptimizer
  126297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126298. */
  126299. export class SceneOptimizerOptions {
  126300. /**
  126301. * Defines the target frame rate to reach (60 by default)
  126302. */
  126303. targetFrameRate: number;
  126304. /**
  126305. * Defines the interval between two checkes (2000ms by default)
  126306. */
  126307. trackerDuration: number;
  126308. /**
  126309. * Gets the list of optimizations to apply
  126310. */
  126311. optimizations: SceneOptimization[];
  126312. /**
  126313. * Creates a new list of options used by SceneOptimizer
  126314. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  126315. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  126316. */
  126317. constructor(
  126318. /**
  126319. * Defines the target frame rate to reach (60 by default)
  126320. */
  126321. targetFrameRate?: number,
  126322. /**
  126323. * Defines the interval between two checkes (2000ms by default)
  126324. */
  126325. trackerDuration?: number);
  126326. /**
  126327. * Add a new optimization
  126328. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  126329. * @returns the current SceneOptimizerOptions
  126330. */
  126331. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  126332. /**
  126333. * Add a new custom optimization
  126334. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  126335. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  126336. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126337. * @returns the current SceneOptimizerOptions
  126338. */
  126339. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  126340. /**
  126341. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  126342. * @param targetFrameRate defines the target frame rate (60 by default)
  126343. * @returns a SceneOptimizerOptions object
  126344. */
  126345. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126346. /**
  126347. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  126348. * @param targetFrameRate defines the target frame rate (60 by default)
  126349. * @returns a SceneOptimizerOptions object
  126350. */
  126351. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126352. /**
  126353. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  126354. * @param targetFrameRate defines the target frame rate (60 by default)
  126355. * @returns a SceneOptimizerOptions object
  126356. */
  126357. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126358. }
  126359. /**
  126360. * Class used to run optimizations in order to reach a target frame rate
  126361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126362. */
  126363. export class SceneOptimizer implements IDisposable {
  126364. private _isRunning;
  126365. private _options;
  126366. private _scene;
  126367. private _currentPriorityLevel;
  126368. private _targetFrameRate;
  126369. private _trackerDuration;
  126370. private _currentFrameRate;
  126371. private _sceneDisposeObserver;
  126372. private _improvementMode;
  126373. /**
  126374. * Defines an observable called when the optimizer reaches the target frame rate
  126375. */
  126376. onSuccessObservable: Observable<SceneOptimizer>;
  126377. /**
  126378. * Defines an observable called when the optimizer enables an optimization
  126379. */
  126380. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  126381. /**
  126382. * Defines an observable called when the optimizer is not able to reach the target frame rate
  126383. */
  126384. onFailureObservable: Observable<SceneOptimizer>;
  126385. /**
  126386. * Gets a boolean indicating if the optimizer is in improvement mode
  126387. */
  126388. readonly isInImprovementMode: boolean;
  126389. /**
  126390. * Gets the current priority level (0 at start)
  126391. */
  126392. readonly currentPriorityLevel: number;
  126393. /**
  126394. * Gets the current frame rate checked by the SceneOptimizer
  126395. */
  126396. readonly currentFrameRate: number;
  126397. /**
  126398. * Gets or sets the current target frame rate (60 by default)
  126399. */
  126400. /**
  126401. * Gets or sets the current target frame rate (60 by default)
  126402. */
  126403. targetFrameRate: number;
  126404. /**
  126405. * Gets or sets the current interval between two checks (every 2000ms by default)
  126406. */
  126407. /**
  126408. * Gets or sets the current interval between two checks (every 2000ms by default)
  126409. */
  126410. trackerDuration: number;
  126411. /**
  126412. * Gets the list of active optimizations
  126413. */
  126414. readonly optimizations: SceneOptimization[];
  126415. /**
  126416. * Creates a new SceneOptimizer
  126417. * @param scene defines the scene to work on
  126418. * @param options defines the options to use with the SceneOptimizer
  126419. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  126420. * @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)
  126421. */
  126422. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  126423. /**
  126424. * Stops the current optimizer
  126425. */
  126426. stop(): void;
  126427. /**
  126428. * Reset the optimizer to initial step (current priority level = 0)
  126429. */
  126430. reset(): void;
  126431. /**
  126432. * Start the optimizer. By default it will try to reach a specific framerate
  126433. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  126434. */
  126435. start(): void;
  126436. private _checkCurrentState;
  126437. /**
  126438. * Release all resources
  126439. */
  126440. dispose(): void;
  126441. /**
  126442. * Helper function to create a SceneOptimizer with one single line of code
  126443. * @param scene defines the scene to work on
  126444. * @param options defines the options to use with the SceneOptimizer
  126445. * @param onSuccess defines a callback to call on success
  126446. * @param onFailure defines a callback to call on failure
  126447. * @returns the new SceneOptimizer object
  126448. */
  126449. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  126450. }
  126451. }
  126452. declare module BABYLON {
  126453. /**
  126454. * Class used to serialize a scene into a string
  126455. */
  126456. export class SceneSerializer {
  126457. /**
  126458. * Clear cache used by a previous serialization
  126459. */
  126460. static ClearCache(): void;
  126461. /**
  126462. * Serialize a scene into a JSON compatible object
  126463. * @param scene defines the scene to serialize
  126464. * @returns a JSON compatible object
  126465. */
  126466. static Serialize(scene: Scene): any;
  126467. /**
  126468. * Serialize a mesh into a JSON compatible object
  126469. * @param toSerialize defines the mesh to serialize
  126470. * @param withParents defines if parents must be serialized as well
  126471. * @param withChildren defines if children must be serialized as well
  126472. * @returns a JSON compatible object
  126473. */
  126474. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  126475. }
  126476. }
  126477. declare module BABYLON {
  126478. /**
  126479. * Class used to host texture specific utilities
  126480. */
  126481. export class TextureTools {
  126482. /**
  126483. * Uses the GPU to create a copy texture rescaled at a given size
  126484. * @param texture Texture to copy from
  126485. * @param width defines the desired width
  126486. * @param height defines the desired height
  126487. * @param useBilinearMode defines if bilinear mode has to be used
  126488. * @return the generated texture
  126489. */
  126490. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  126491. }
  126492. }
  126493. declare module BABYLON {
  126494. /**
  126495. * This represents the different options available for the video capture.
  126496. */
  126497. export interface VideoRecorderOptions {
  126498. /** Defines the mime type of the video. */
  126499. mimeType: string;
  126500. /** Defines the FPS the video should be recorded at. */
  126501. fps: number;
  126502. /** Defines the chunk size for the recording data. */
  126503. recordChunckSize: number;
  126504. /** The audio tracks to attach to the recording. */
  126505. audioTracks?: MediaStreamTrack[];
  126506. }
  126507. /**
  126508. * This can help with recording videos from BabylonJS.
  126509. * This is based on the available WebRTC functionalities of the browser.
  126510. *
  126511. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  126512. */
  126513. export class VideoRecorder {
  126514. private static readonly _defaultOptions;
  126515. /**
  126516. * Returns whether or not the VideoRecorder is available in your browser.
  126517. * @param engine Defines the Babylon Engine.
  126518. * @returns true if supported otherwise false.
  126519. */
  126520. static IsSupported(engine: Engine): boolean;
  126521. private readonly _options;
  126522. private _canvas;
  126523. private _mediaRecorder;
  126524. private _recordedChunks;
  126525. private _fileName;
  126526. private _resolve;
  126527. private _reject;
  126528. /**
  126529. * True when a recording is already in progress.
  126530. */
  126531. readonly isRecording: boolean;
  126532. /**
  126533. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  126534. * @param engine Defines the BabylonJS Engine you wish to record.
  126535. * @param options Defines options that can be used to customize the capture.
  126536. */
  126537. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  126538. /**
  126539. * Stops the current recording before the default capture timeout passed in the startRecording function.
  126540. */
  126541. stopRecording(): void;
  126542. /**
  126543. * Starts recording the canvas for a max duration specified in parameters.
  126544. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  126545. * If null no automatic download will start and you can rely on the promise to get the data back.
  126546. * @param maxDuration Defines the maximum recording time in seconds.
  126547. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  126548. * @return A promise callback at the end of the recording with the video data in Blob.
  126549. */
  126550. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  126551. /**
  126552. * Releases internal resources used during the recording.
  126553. */
  126554. dispose(): void;
  126555. private _handleDataAvailable;
  126556. private _handleError;
  126557. private _handleStop;
  126558. }
  126559. }
  126560. declare module BABYLON {
  126561. /**
  126562. * Class containing a set of static utilities functions for screenshots
  126563. */
  126564. export class ScreenshotTools {
  126565. /**
  126566. * Captures a screenshot of the current rendering
  126567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126568. * @param engine defines the rendering engine
  126569. * @param camera defines the source camera
  126570. * @param size This parameter can be set to a single number or to an object with the
  126571. * following (optional) properties: precision, width, height. If a single number is passed,
  126572. * it will be used for both width and height. If an object is passed, the screenshot size
  126573. * will be derived from the parameters. The precision property is a multiplier allowing
  126574. * rendering at a higher or lower resolution
  126575. * @param successCallback defines the callback receives a single parameter which contains the
  126576. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126577. * src parameter of an <img> to display it
  126578. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126579. * Check your browser for supported MIME types
  126580. */
  126581. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  126582. /**
  126583. * Captures a screenshot of the current rendering
  126584. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126585. * @param engine defines the rendering engine
  126586. * @param camera defines the source camera
  126587. * @param size This parameter can be set to a single number or to an object with the
  126588. * following (optional) properties: precision, width, height. If a single number is passed,
  126589. * it will be used for both width and height. If an object is passed, the screenshot size
  126590. * will be derived from the parameters. The precision property is a multiplier allowing
  126591. * rendering at a higher or lower resolution
  126592. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126593. * Check your browser for supported MIME types
  126594. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126595. * to the src parameter of an <img> to display it
  126596. */
  126597. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  126598. /**
  126599. * Generates an image screenshot from the specified camera.
  126600. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126601. * @param engine The engine to use for rendering
  126602. * @param camera The camera to use for rendering
  126603. * @param size This parameter can be set to a single number or to an object with the
  126604. * following (optional) properties: precision, width, height. If a single number is passed,
  126605. * it will be used for both width and height. If an object is passed, the screenshot size
  126606. * will be derived from the parameters. The precision property is a multiplier allowing
  126607. * rendering at a higher or lower resolution
  126608. * @param successCallback The callback receives a single parameter which contains the
  126609. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126610. * src parameter of an <img> to display it
  126611. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126612. * Check your browser for supported MIME types
  126613. * @param samples Texture samples (default: 1)
  126614. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126615. * @param fileName A name for for the downloaded file.
  126616. */
  126617. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  126618. /**
  126619. * Generates an image screenshot from the specified camera.
  126620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126621. * @param engine The engine to use for rendering
  126622. * @param camera The camera to use for rendering
  126623. * @param size This parameter can be set to a single number or to an object with the
  126624. * following (optional) properties: precision, width, height. If a single number is passed,
  126625. * it will be used for both width and height. If an object is passed, the screenshot size
  126626. * will be derived from the parameters. The precision property is a multiplier allowing
  126627. * rendering at a higher or lower resolution
  126628. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126629. * Check your browser for supported MIME types
  126630. * @param samples Texture samples (default: 1)
  126631. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126632. * @param fileName A name for for the downloaded file.
  126633. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126634. * to the src parameter of an <img> to display it
  126635. */
  126636. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  126637. /**
  126638. * Gets height and width for screenshot size
  126639. * @private
  126640. */
  126641. private static _getScreenshotSize;
  126642. }
  126643. }
  126644. declare module BABYLON {
  126645. /**
  126646. * A cursor which tracks a point on a path
  126647. */
  126648. export class PathCursor {
  126649. private path;
  126650. /**
  126651. * Stores path cursor callbacks for when an onchange event is triggered
  126652. */
  126653. private _onchange;
  126654. /**
  126655. * The value of the path cursor
  126656. */
  126657. value: number;
  126658. /**
  126659. * The animation array of the path cursor
  126660. */
  126661. animations: Animation[];
  126662. /**
  126663. * Initializes the path cursor
  126664. * @param path The path to track
  126665. */
  126666. constructor(path: Path2);
  126667. /**
  126668. * Gets the cursor point on the path
  126669. * @returns A point on the path cursor at the cursor location
  126670. */
  126671. getPoint(): Vector3;
  126672. /**
  126673. * Moves the cursor ahead by the step amount
  126674. * @param step The amount to move the cursor forward
  126675. * @returns This path cursor
  126676. */
  126677. moveAhead(step?: number): PathCursor;
  126678. /**
  126679. * Moves the cursor behind by the step amount
  126680. * @param step The amount to move the cursor back
  126681. * @returns This path cursor
  126682. */
  126683. moveBack(step?: number): PathCursor;
  126684. /**
  126685. * Moves the cursor by the step amount
  126686. * If the step amount is greater than one, an exception is thrown
  126687. * @param step The amount to move the cursor
  126688. * @returns This path cursor
  126689. */
  126690. move(step: number): PathCursor;
  126691. /**
  126692. * Ensures that the value is limited between zero and one
  126693. * @returns This path cursor
  126694. */
  126695. private ensureLimits;
  126696. /**
  126697. * Runs onchange callbacks on change (used by the animation engine)
  126698. * @returns This path cursor
  126699. */
  126700. private raiseOnChange;
  126701. /**
  126702. * Executes a function on change
  126703. * @param f A path cursor onchange callback
  126704. * @returns This path cursor
  126705. */
  126706. onchange(f: (cursor: PathCursor) => void): PathCursor;
  126707. }
  126708. }
  126709. declare module BABYLON {
  126710. /** @hidden */
  126711. export var blurPixelShader: {
  126712. name: string;
  126713. shader: string;
  126714. };
  126715. }
  126716. declare module BABYLON {
  126717. /** @hidden */
  126718. export var pointCloudVertexDeclaration: {
  126719. name: string;
  126720. shader: string;
  126721. };
  126722. }
  126723. // Mixins
  126724. interface Window {
  126725. mozIndexedDB: IDBFactory;
  126726. webkitIndexedDB: IDBFactory;
  126727. msIndexedDB: IDBFactory;
  126728. webkitURL: typeof URL;
  126729. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  126730. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  126731. WebGLRenderingContext: WebGLRenderingContext;
  126732. MSGesture: MSGesture;
  126733. CANNON: any;
  126734. AudioContext: AudioContext;
  126735. webkitAudioContext: AudioContext;
  126736. PointerEvent: any;
  126737. Math: Math;
  126738. Uint8Array: Uint8ArrayConstructor;
  126739. Float32Array: Float32ArrayConstructor;
  126740. mozURL: typeof URL;
  126741. msURL: typeof URL;
  126742. VRFrameData: any; // WebVR, from specs 1.1
  126743. DracoDecoderModule: any;
  126744. setImmediate(handler: (...args: any[]) => void): number;
  126745. }
  126746. interface HTMLCanvasElement {
  126747. requestPointerLock(): void;
  126748. msRequestPointerLock?(): void;
  126749. mozRequestPointerLock?(): void;
  126750. webkitRequestPointerLock?(): void;
  126751. /** Track wether a record is in progress */
  126752. isRecording: boolean;
  126753. /** Capture Stream method defined by some browsers */
  126754. captureStream(fps?: number): MediaStream;
  126755. }
  126756. interface CanvasRenderingContext2D {
  126757. msImageSmoothingEnabled: boolean;
  126758. }
  126759. interface MouseEvent {
  126760. mozMovementX: number;
  126761. mozMovementY: number;
  126762. webkitMovementX: number;
  126763. webkitMovementY: number;
  126764. msMovementX: number;
  126765. msMovementY: number;
  126766. }
  126767. interface Navigator {
  126768. mozGetVRDevices: (any: any) => any;
  126769. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126770. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126771. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126772. webkitGetGamepads(): Gamepad[];
  126773. msGetGamepads(): Gamepad[];
  126774. webkitGamepads(): Gamepad[];
  126775. }
  126776. interface HTMLVideoElement {
  126777. mozSrcObject: any;
  126778. }
  126779. interface Math {
  126780. fround(x: number): number;
  126781. imul(a: number, b: number): number;
  126782. }
  126783. interface WebGLRenderingContext {
  126784. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  126785. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  126786. vertexAttribDivisor(index: number, divisor: number): void;
  126787. createVertexArray(): any;
  126788. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  126789. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  126790. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  126791. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  126792. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  126793. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  126794. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  126795. // Queries
  126796. createQuery(): WebGLQuery;
  126797. deleteQuery(query: WebGLQuery): void;
  126798. beginQuery(target: number, query: WebGLQuery): void;
  126799. endQuery(target: number): void;
  126800. getQueryParameter(query: WebGLQuery, pname: number): any;
  126801. getQuery(target: number, pname: number): any;
  126802. MAX_SAMPLES: number;
  126803. RGBA8: number;
  126804. READ_FRAMEBUFFER: number;
  126805. DRAW_FRAMEBUFFER: number;
  126806. UNIFORM_BUFFER: number;
  126807. HALF_FLOAT_OES: number;
  126808. RGBA16F: number;
  126809. RGBA32F: number;
  126810. R32F: number;
  126811. RG32F: number;
  126812. RGB32F: number;
  126813. R16F: number;
  126814. RG16F: number;
  126815. RGB16F: number;
  126816. RED: number;
  126817. RG: number;
  126818. R8: number;
  126819. RG8: number;
  126820. UNSIGNED_INT_24_8: number;
  126821. DEPTH24_STENCIL8: number;
  126822. /* Multiple Render Targets */
  126823. drawBuffers(buffers: number[]): void;
  126824. readBuffer(src: number): void;
  126825. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  126826. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  126827. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  126828. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  126829. // Occlusion Query
  126830. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  126831. ANY_SAMPLES_PASSED: number;
  126832. QUERY_RESULT_AVAILABLE: number;
  126833. QUERY_RESULT: number;
  126834. }
  126835. interface WebGLProgram {
  126836. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  126837. }
  126838. interface EXT_disjoint_timer_query {
  126839. QUERY_COUNTER_BITS_EXT: number;
  126840. TIME_ELAPSED_EXT: number;
  126841. TIMESTAMP_EXT: number;
  126842. GPU_DISJOINT_EXT: number;
  126843. QUERY_RESULT_EXT: number;
  126844. QUERY_RESULT_AVAILABLE_EXT: number;
  126845. queryCounterEXT(query: WebGLQuery, target: number): void;
  126846. createQueryEXT(): WebGLQuery;
  126847. beginQueryEXT(target: number, query: WebGLQuery): void;
  126848. endQueryEXT(target: number): void;
  126849. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  126850. deleteQueryEXT(query: WebGLQuery): void;
  126851. }
  126852. interface WebGLUniformLocation {
  126853. _currentState: any;
  126854. }
  126855. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  126856. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  126857. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  126858. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126859. interface WebGLRenderingContext {
  126860. readonly RASTERIZER_DISCARD: number;
  126861. readonly DEPTH_COMPONENT24: number;
  126862. readonly TEXTURE_3D: number;
  126863. readonly TEXTURE_2D_ARRAY: number;
  126864. readonly TEXTURE_COMPARE_FUNC: number;
  126865. readonly TEXTURE_COMPARE_MODE: number;
  126866. readonly COMPARE_REF_TO_TEXTURE: number;
  126867. readonly TEXTURE_WRAP_R: number;
  126868. readonly HALF_FLOAT: number;
  126869. readonly RGB8: number;
  126870. readonly RED_INTEGER: number;
  126871. readonly RG_INTEGER: number;
  126872. readonly RGB_INTEGER: number;
  126873. readonly RGBA_INTEGER: number;
  126874. readonly R8_SNORM: number;
  126875. readonly RG8_SNORM: number;
  126876. readonly RGB8_SNORM: number;
  126877. readonly RGBA8_SNORM: number;
  126878. readonly R8I: number;
  126879. readonly RG8I: number;
  126880. readonly RGB8I: number;
  126881. readonly RGBA8I: number;
  126882. readonly R8UI: number;
  126883. readonly RG8UI: number;
  126884. readonly RGB8UI: number;
  126885. readonly RGBA8UI: number;
  126886. readonly R16I: number;
  126887. readonly RG16I: number;
  126888. readonly RGB16I: number;
  126889. readonly RGBA16I: number;
  126890. readonly R16UI: number;
  126891. readonly RG16UI: number;
  126892. readonly RGB16UI: number;
  126893. readonly RGBA16UI: number;
  126894. readonly R32I: number;
  126895. readonly RG32I: number;
  126896. readonly RGB32I: number;
  126897. readonly RGBA32I: number;
  126898. readonly R32UI: number;
  126899. readonly RG32UI: number;
  126900. readonly RGB32UI: number;
  126901. readonly RGBA32UI: number;
  126902. readonly RGB10_A2UI: number;
  126903. readonly R11F_G11F_B10F: number;
  126904. readonly RGB9_E5: number;
  126905. readonly RGB10_A2: number;
  126906. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  126907. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  126908. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  126909. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126910. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  126911. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  126912. 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;
  126913. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  126914. readonly TRANSFORM_FEEDBACK: number;
  126915. readonly INTERLEAVED_ATTRIBS: number;
  126916. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  126917. createTransformFeedback(): WebGLTransformFeedback;
  126918. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  126919. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  126920. beginTransformFeedback(primitiveMode: number): void;
  126921. endTransformFeedback(): void;
  126922. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  126923. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126924. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126925. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126926. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  126927. }
  126928. interface ImageBitmap {
  126929. readonly width: number;
  126930. readonly height: number;
  126931. close(): void;
  126932. }
  126933. interface WebGLQuery extends WebGLObject {
  126934. }
  126935. declare var WebGLQuery: {
  126936. prototype: WebGLQuery;
  126937. new(): WebGLQuery;
  126938. };
  126939. interface WebGLSampler extends WebGLObject {
  126940. }
  126941. declare var WebGLSampler: {
  126942. prototype: WebGLSampler;
  126943. new(): WebGLSampler;
  126944. };
  126945. interface WebGLSync extends WebGLObject {
  126946. }
  126947. declare var WebGLSync: {
  126948. prototype: WebGLSync;
  126949. new(): WebGLSync;
  126950. };
  126951. interface WebGLTransformFeedback extends WebGLObject {
  126952. }
  126953. declare var WebGLTransformFeedback: {
  126954. prototype: WebGLTransformFeedback;
  126955. new(): WebGLTransformFeedback;
  126956. };
  126957. interface WebGLVertexArrayObject extends WebGLObject {
  126958. }
  126959. declare var WebGLVertexArrayObject: {
  126960. prototype: WebGLVertexArrayObject;
  126961. new(): WebGLVertexArrayObject;
  126962. };
  126963. // Type definitions for WebVR API
  126964. // Project: https://w3c.github.io/webvr/
  126965. // Definitions by: six a <https://github.com/lostfictions>
  126966. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126967. interface VRDisplay extends EventTarget {
  126968. /**
  126969. * Dictionary of capabilities describing the VRDisplay.
  126970. */
  126971. readonly capabilities: VRDisplayCapabilities;
  126972. /**
  126973. * z-depth defining the far plane of the eye view frustum
  126974. * enables mapping of values in the render target depth
  126975. * attachment to scene coordinates. Initially set to 10000.0.
  126976. */
  126977. depthFar: number;
  126978. /**
  126979. * z-depth defining the near plane of the eye view frustum
  126980. * enables mapping of values in the render target depth
  126981. * attachment to scene coordinates. Initially set to 0.01.
  126982. */
  126983. depthNear: number;
  126984. /**
  126985. * An identifier for this distinct VRDisplay. Used as an
  126986. * association point in the Gamepad API.
  126987. */
  126988. readonly displayId: number;
  126989. /**
  126990. * A display name, a user-readable name identifying it.
  126991. */
  126992. readonly displayName: string;
  126993. readonly isConnected: boolean;
  126994. readonly isPresenting: boolean;
  126995. /**
  126996. * If this VRDisplay supports room-scale experiences, the optional
  126997. * stage attribute contains details on the room-scale parameters.
  126998. */
  126999. readonly stageParameters: VRStageParameters | null;
  127000. /**
  127001. * Passing the value returned by `requestAnimationFrame` to
  127002. * `cancelAnimationFrame` will unregister the callback.
  127003. * @param handle Define the hanle of the request to cancel
  127004. */
  127005. cancelAnimationFrame(handle: number): void;
  127006. /**
  127007. * Stops presenting to the VRDisplay.
  127008. * @returns a promise to know when it stopped
  127009. */
  127010. exitPresent(): Promise<void>;
  127011. /**
  127012. * Return the current VREyeParameters for the given eye.
  127013. * @param whichEye Define the eye we want the parameter for
  127014. * @returns the eye parameters
  127015. */
  127016. getEyeParameters(whichEye: string): VREyeParameters;
  127017. /**
  127018. * Populates the passed VRFrameData with the information required to render
  127019. * the current frame.
  127020. * @param frameData Define the data structure to populate
  127021. * @returns true if ok otherwise false
  127022. */
  127023. getFrameData(frameData: VRFrameData): boolean;
  127024. /**
  127025. * Get the layers currently being presented.
  127026. * @returns the list of VR layers
  127027. */
  127028. getLayers(): VRLayer[];
  127029. /**
  127030. * Return a VRPose containing the future predicted pose of the VRDisplay
  127031. * when the current frame will be presented. The value returned will not
  127032. * change until JavaScript has returned control to the browser.
  127033. *
  127034. * The VRPose will contain the position, orientation, velocity,
  127035. * and acceleration of each of these properties.
  127036. * @returns the pose object
  127037. */
  127038. getPose(): VRPose;
  127039. /**
  127040. * Return the current instantaneous pose of the VRDisplay, with no
  127041. * prediction applied.
  127042. * @returns the current instantaneous pose
  127043. */
  127044. getImmediatePose(): VRPose;
  127045. /**
  127046. * The callback passed to `requestAnimationFrame` will be called
  127047. * any time a new frame should be rendered. When the VRDisplay is
  127048. * presenting the callback will be called at the native refresh
  127049. * rate of the HMD. When not presenting this function acts
  127050. * identically to how window.requestAnimationFrame acts. Content should
  127051. * make no assumptions of frame rate or vsync behavior as the HMD runs
  127052. * asynchronously from other displays and at differing refresh rates.
  127053. * @param callback Define the eaction to run next frame
  127054. * @returns the request handle it
  127055. */
  127056. requestAnimationFrame(callback: FrameRequestCallback): number;
  127057. /**
  127058. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  127059. * Repeat calls while already presenting will update the VRLayers being displayed.
  127060. * @param layers Define the list of layer to present
  127061. * @returns a promise to know when the request has been fulfilled
  127062. */
  127063. requestPresent(layers: VRLayer[]): Promise<void>;
  127064. /**
  127065. * Reset the pose for this display, treating its current position and
  127066. * orientation as the "origin/zero" values. VRPose.position,
  127067. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  127068. * updated when calling resetPose(). This should be called in only
  127069. * sitting-space experiences.
  127070. */
  127071. resetPose(): void;
  127072. /**
  127073. * The VRLayer provided to the VRDisplay will be captured and presented
  127074. * in the HMD. Calling this function has the same effect on the source
  127075. * canvas as any other operation that uses its source image, and canvases
  127076. * created without preserveDrawingBuffer set to true will be cleared.
  127077. * @param pose Define the pose to submit
  127078. */
  127079. submitFrame(pose?: VRPose): void;
  127080. }
  127081. declare var VRDisplay: {
  127082. prototype: VRDisplay;
  127083. new(): VRDisplay;
  127084. };
  127085. interface VRLayer {
  127086. leftBounds?: number[] | Float32Array | null;
  127087. rightBounds?: number[] | Float32Array | null;
  127088. source?: HTMLCanvasElement | null;
  127089. }
  127090. interface VRDisplayCapabilities {
  127091. readonly canPresent: boolean;
  127092. readonly hasExternalDisplay: boolean;
  127093. readonly hasOrientation: boolean;
  127094. readonly hasPosition: boolean;
  127095. readonly maxLayers: number;
  127096. }
  127097. interface VREyeParameters {
  127098. /** @deprecated */
  127099. readonly fieldOfView: VRFieldOfView;
  127100. readonly offset: Float32Array;
  127101. readonly renderHeight: number;
  127102. readonly renderWidth: number;
  127103. }
  127104. interface VRFieldOfView {
  127105. readonly downDegrees: number;
  127106. readonly leftDegrees: number;
  127107. readonly rightDegrees: number;
  127108. readonly upDegrees: number;
  127109. }
  127110. interface VRFrameData {
  127111. readonly leftProjectionMatrix: Float32Array;
  127112. readonly leftViewMatrix: Float32Array;
  127113. readonly pose: VRPose;
  127114. readonly rightProjectionMatrix: Float32Array;
  127115. readonly rightViewMatrix: Float32Array;
  127116. readonly timestamp: number;
  127117. }
  127118. interface VRPose {
  127119. readonly angularAcceleration: Float32Array | null;
  127120. readonly angularVelocity: Float32Array | null;
  127121. readonly linearAcceleration: Float32Array | null;
  127122. readonly linearVelocity: Float32Array | null;
  127123. readonly orientation: Float32Array | null;
  127124. readonly position: Float32Array | null;
  127125. readonly timestamp: number;
  127126. }
  127127. interface VRStageParameters {
  127128. sittingToStandingTransform?: Float32Array;
  127129. sizeX?: number;
  127130. sizeY?: number;
  127131. }
  127132. interface Navigator {
  127133. getVRDisplays(): Promise<VRDisplay[]>;
  127134. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  127135. }
  127136. interface Window {
  127137. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  127138. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  127139. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  127140. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127141. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127142. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  127143. }
  127144. interface Gamepad {
  127145. readonly displayId: number;
  127146. }
  127147. type XRSessionMode =
  127148. | "inline"
  127149. | "immersive-vr"
  127150. | "immersive-ar";
  127151. type XRReferenceSpaceType =
  127152. | "viewer"
  127153. | "local"
  127154. | "local-floor"
  127155. | "bounded-floor"
  127156. | "unbounded";
  127157. type XREnvironmentBlendMode =
  127158. | "opaque"
  127159. | "additive"
  127160. | "alpha-blend";
  127161. type XRVisibilityState =
  127162. | "visible"
  127163. | "visible-blurred"
  127164. | "hidden";
  127165. type XRHandedness =
  127166. | "none"
  127167. | "left"
  127168. | "right";
  127169. type XRTargetRayMode =
  127170. | "gaze"
  127171. | "tracked-pointer"
  127172. | "screen";
  127173. type XREye =
  127174. | "none"
  127175. | "left"
  127176. | "right";
  127177. interface XRSpace extends EventTarget {
  127178. }
  127179. interface XRRenderState {
  127180. depthNear?: number;
  127181. depthFar?: number;
  127182. inlineVerticalFieldOfView?: number;
  127183. baseLayer?: XRWebGLLayer;
  127184. }
  127185. interface XRInputSource {
  127186. handedness: XRHandedness;
  127187. targetRayMode: XRTargetRayMode;
  127188. targetRaySpace: XRSpace;
  127189. gripSpace: XRSpace | undefined;
  127190. gamepad: Gamepad | undefined;
  127191. profiles: Array<string>;
  127192. }
  127193. interface XRSession {
  127194. addEventListener: Function;
  127195. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127196. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  127197. requestAnimationFrame: Function;
  127198. end(): Promise<void>;
  127199. renderState: XRRenderState;
  127200. inputSources: Array<XRInputSource>;
  127201. }
  127202. interface XRReferenceSpace extends XRSpace {
  127203. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  127204. onreset: any;
  127205. }
  127206. interface XRFrame {
  127207. session: XRSession;
  127208. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  127209. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  127210. }
  127211. interface XRViewerPose extends XRPose {
  127212. views: Array<XRView>;
  127213. }
  127214. interface XRPose {
  127215. transform: XRRigidTransform;
  127216. emulatedPosition: boolean;
  127217. }
  127218. declare var XRWebGLLayer: {
  127219. prototype: XRWebGLLayer;
  127220. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  127221. };
  127222. interface XRWebGLLayer {
  127223. framebuffer: WebGLFramebuffer;
  127224. framebufferWidth: number;
  127225. framebufferHeight: number;
  127226. getViewport: Function;
  127227. }
  127228. interface XRRigidTransform {
  127229. position: DOMPointReadOnly;
  127230. orientation: DOMPointReadOnly;
  127231. matrix: Float32Array;
  127232. inverse: XRRigidTransform;
  127233. }
  127234. interface XRView {
  127235. eye: XREye;
  127236. projectionMatrix: Float32Array;
  127237. transform: XRRigidTransform;
  127238. }
  127239. interface XRInputSourceChangeEvent {
  127240. session: XRSession;
  127241. removed: Array<XRInputSource>;
  127242. added: Array<XRInputSource>;
  127243. }